Merge pull request #900 from safing/fix/privacy-filter-module-config

Move all filter/interception config to interception module
This commit is contained in:
Daniel Hovie 2022-09-29 11:06:30 +02:00 committed by GitHub
commit a5f916f047
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 27 deletions

View file

@ -1,8 +1,10 @@
package firewall
import (
"github.com/safing/portbase/api"
"github.com/safing/portbase/config"
"github.com/safing/portbase/notifications"
"github.com/safing/portmaster/core"
"github.com/safing/spn/captain"
)
@ -107,13 +109,22 @@ func registerConfig() error {
return nil
}
// Config variables for interception and filter module.
// Everything is registered by the interception module, as the filter module
// can be disabled.
var (
devMode config.BoolOption
apiListenAddress config.StringOption
filterEnabled config.BoolOption
tunnelEnabled config.BoolOption
useCommunityNodes config.BoolOption
)
func getConfig() {
devMode = config.Concurrent.GetAsBool(core.CfgDevModeKey, false)
apiListenAddress = config.GetAsString(api.CfgDefaultListenAddressKey, "")
filterEnabled = config.Concurrent.GetAsBool(CfgOptionEnableFilterKey, true)
tunnelEnabled = config.Concurrent.GetAsBool(captain.CfgOptionEnableSPNKey, false)
useCommunityNodes = config.Concurrent.GetAsBool(captain.CfgOptionUseCommunityNodesKey, true)

View file

@ -10,7 +10,7 @@ import (
var filterModule *modules.Module
func init() {
filterModule = modules.Register("filter", filterPrep, filterStart, nil, "core", "intel")
filterModule = modules.Register("filter", nil, nil, nil, "core", "interception", "intel")
subsystems.Register(
"filter",
"Privacy Filter",
@ -31,18 +31,3 @@ func init() {
},
)
}
func filterPrep() (err error) {
err = registerConfig()
if err != nil {
return err
}
return nil
}
func filterStart() error {
getConfig()
return nil
}

View file

@ -13,12 +13,9 @@ import (
"github.com/tevino/abool"
"golang.org/x/sync/singleflight"
"github.com/safing/portbase/api"
"github.com/safing/portbase/config"
"github.com/safing/portbase/log"
"github.com/safing/portbase/modules"
"github.com/safing/portmaster/compat"
"github.com/safing/portmaster/core"
_ "github.com/safing/portmaster/core/base"
"github.com/safing/portmaster/firewall/inspection"
"github.com/safing/portmaster/firewall/interception"
@ -46,12 +43,6 @@ var (
ownPID = os.Getpid()
)
// Config variables for interception module.
var (
devMode config.BoolOption
apiListenAddress config.StringOption
)
func init() {
// TODO: Move interception module to own package (dir).
interceptionModule = modules.Register("interception", interceptionPrep, interceptionStart, interceptionStop, "base", "updates", "network", "notifications")
@ -60,12 +51,15 @@ func init() {
}
func interceptionPrep() error {
if err := registerConfig(); err != nil {
return err
}
return prepAPIAuth()
}
func interceptionStart() error {
devMode = config.Concurrent.GetAsBool(core.CfgDevModeKey, false)
apiListenAddress = config.GetAsString(api.CfgDefaultListenAddressKey, "")
getConfig()
if err := registerMetrics(); err != nil {
return err