mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Refactor the status package to use portbase/runtime and make system status readonly. Also adapts the code base to the new portbase/notifications package.
36 lines
582 B
Go
36 lines
582 B
Go
package status
|
|
|
|
import "context"
|
|
|
|
var runAutoPilot = make(chan struct{})
|
|
|
|
func triggerAutopilot() {
|
|
select {
|
|
case runAutoPilot <- struct{}{}:
|
|
default:
|
|
}
|
|
}
|
|
|
|
func autoPilot(ctx context.Context) error {
|
|
for {
|
|
select {
|
|
case <-ctx.Done():
|
|
return nil
|
|
case <-runAutoPilot:
|
|
}
|
|
|
|
selected := SelectedSecurityLevel()
|
|
mitigation := getHighestMitigationLevel()
|
|
|
|
active := SecurityLevelNormal
|
|
if selected != SecurityLevelOff {
|
|
active = selected
|
|
} else if mitigation != SecurityLevelOff {
|
|
active = mitigation
|
|
}
|
|
|
|
setActiveLevel(active)
|
|
|
|
pushSystemStatus()
|
|
}
|
|
}
|