MCPcopy
hub / github.com/safing/portmaster / start

Function start

spn/access/module.go:73–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71}
72
73func start() error {
74 // Initialize zones.
75 if err := InitializeZones(); err != nil {
76 return err
77 }
78
79 if conf.Integrated() {
80 // Add config listener to enable/disable SPN.
81 module.instance.Config().EventConfigChange.AddCallback("spn enable check", func(wc *mgr.WorkerCtx, s struct{}) (bool, error) {
82 // Do not do anything when we are shutting down.
83 if module.instance.IsShuttingDown() {
84 return true, nil
85 }
86
87 enabled := config.GetAsBool("spn/enable", false)
88 if enabled() {
89 log.Info("spn: starting SPN")
90 module.mgr.Go("ensure SPN is started", module.instance.SPNGroup().EnsureStartedWorker)
91 } else {
92 log.Info("spn: stopping SPN")
93 module.mgr.Go("ensure SPN is stopped", module.instance.SPNGroup().EnsureStoppedWorker)
94 }
95 return false, nil
96 })
97
98 // Load tokens from database.
99 loadTokens()
100
101 // Check if we need to enable SPN now.
102 enabled := config.GetAsBool("spn/enable", false)
103 if enabled() {
104 module.mgr.Go("ensure SPN is started", module.instance.SPNGroup().EnsureStartedWorker)
105 }
106
107 // Register new task.
108 module.updateAccountWorkerMgr.Delay(1 * time.Minute)
109 }
110
111 return nil
112}
113
114func stop() error {
115 if conf.Integrated() {

Callers 1

StartMethod · 0.70

Calls 11

IntegratedFunction · 0.92
GetAsBoolFunction · 0.92
InfoFunction · 0.92
InitializeZonesFunction · 0.85
loadTokensFunction · 0.85
ConfigMethod · 0.65
IsShuttingDownMethod · 0.65
SPNGroupMethod · 0.65
AddCallbackMethod · 0.45
GoMethod · 0.45
DelayMethod · 0.45

Tested by

no test coverage detected