Add debug/core endpoint to add more Portmaster debug data

This commit is contained in:
Daniel
2021-02-23 13:00:54 +01:00
parent 6c0df1155e
commit 0e51a9523a
4 changed files with 62 additions and 9 deletions

View File

@@ -2,8 +2,10 @@ package status
import (
"context"
"fmt"
"github.com/safing/portbase/modules"
"github.com/safing/portbase/utils/debug"
"github.com/safing/portmaster/netenv"
)
@@ -39,3 +41,16 @@ func start() error {
return nil
}
// AddToDebugInfo adds the system status to the given debug.Info.
func AddToDebugInfo(di *debug.Info) {
di.AddSection(
fmt.Sprintf("Status: %s", SecurityLevelString(ActiveSecurityLevel())),
debug.UseCodeSection|debug.AddContentLineBreaks,
fmt.Sprintf("ActiveSecurityLevel: %s", SecurityLevelString(ActiveSecurityLevel())),
fmt.Sprintf("SelectedSecurityLevel: %s", SecurityLevelString(SelectedSecurityLevel())),
fmt.Sprintf("ThreatMitigationLevel: %s", SecurityLevelString(getHighestMitigationLevel())),
fmt.Sprintf("CaptivePortal: %s", netenv.GetCaptivePortal().URL),
fmt.Sprintf("OnlineStatus: %s", netenv.GetOnlineStatus()),
)
}

View File

@@ -99,19 +99,19 @@ func SecurityLevelString(level uint8) string {
case SecurityLevelOff:
return "Off"
case SecurityLevelNormal:
return "Normal"
return "Trusted"
case SecurityLevelHigh:
return "High"
return "Untrusted"
case SecurityLevelExtreme:
return "Extreme"
return "Danger"
case SecurityLevelsNormalAndHigh:
return "Normal and High"
return "Trusted and Untrusted"
case SecurityLevelsNormalAndExtreme:
return "Normal and Extreme"
return "Trusted and Danger"
case SecurityLevelsHighAndExtreme:
return "High and Extreme"
return "Untrusted and Danger"
case SecurityLevelsAll:
return "Normal, High and Extreme"
return "Trusted, Untrusted and Danger"
default:
return "INVALID"
}