Remove network rating / security level system, add migrations
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
var module *modules.Module
|
||||
|
||||
func init() {
|
||||
module = modules.Register("status", prepare, start, nil, "base", "config")
|
||||
module = modules.Register("status", nil, start, nil, "base", "config")
|
||||
}
|
||||
|
||||
func start() error {
|
||||
@@ -20,57 +20,26 @@ func start() error {
|
||||
return err
|
||||
}
|
||||
|
||||
module.StartWorker("auto-pilot", autoPilot)
|
||||
|
||||
triggerAutopilot()
|
||||
|
||||
if err := module.RegisterEventHook(
|
||||
netenv.ModuleName,
|
||||
netenv.OnlineStatusChangedEvent,
|
||||
"update online status in system status",
|
||||
func(_ context.Context, _ interface{}) error {
|
||||
triggerAutopilot()
|
||||
pushSystemStatus()
|
||||
return nil
|
||||
},
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := module.RegisterEventHook(
|
||||
"config",
|
||||
"config change",
|
||||
"Update network rating system",
|
||||
func(_ context.Context, _ interface{}) error {
|
||||
if !NetworkRatingEnabled() && ActiveSecurityLevel() != SecurityLevelNormal {
|
||||
setSelectedLevel(SecurityLevelNormal)
|
||||
triggerAutopilot()
|
||||
}
|
||||
return nil
|
||||
},
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func prepare() error {
|
||||
if err := registerConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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())),
|
||||
fmt.Sprintf("Status: %s", netenv.GetOnlineStatus()),
|
||||
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()),
|
||||
fmt.Sprintf("CaptivePortal: %s", netenv.GetCaptivePortal().URL),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user