diff --git a/core/databases.go b/core/base/databases.go similarity index 95% rename from core/databases.go rename to core/base/databases.go index df8f37ae..cf8bd8f8 100644 --- a/core/databases.go +++ b/core/base/databases.go @@ -1,4 +1,4 @@ -package core +package base import ( "github.com/safing/portbase/database" @@ -46,5 +46,5 @@ func registerDatabases() error { // return err // } - return registerControlDatabase() + return nil } diff --git a/core/global.go b/core/base/global.go similarity index 92% rename from core/global.go rename to core/base/global.go index d76bbaa5..813f74de 100644 --- a/core/global.go +++ b/core/base/global.go @@ -1,4 +1,4 @@ -package core +package base import ( "errors" @@ -48,13 +48,6 @@ func globalPrep() error { } } - // init config - logFlagOverrides() - err := registerConfig() - if err != nil { - return err - } - // set api listen address api.SetDefaultAPIListenAddress(DefaultAPIListenAddress) diff --git a/core/base/module.go b/core/base/module.go new file mode 100644 index 00000000..f3fdc92d --- /dev/null +++ b/core/base/module.go @@ -0,0 +1,25 @@ +package base + +import ( + "github.com/safing/portbase/modules" + + // module dependencies + _ "github.com/safing/portbase/config" + _ "github.com/safing/portbase/rng" +) + +func init() { + modules.Register("base", nil, registerDatabases, nil, "database", "config", "rng") + + // For prettier subsystem graph, printed with --print-subsystem-graph + /* + subsystems.Register( + "base", + "Base", + "THE GROUND.", + baseModule, + "", + nil, + ) + */ +} diff --git a/core/core.go b/core/core.go index f7a6d13a..a322f37e 100644 --- a/core/core.go +++ b/core/core.go @@ -7,7 +7,7 @@ import ( "github.com/safing/portbase/modules/subsystems" // module dependencies - _ "github.com/safing/portbase/rng" + _ "github.com/safing/portmaster/netenv" _ "github.com/safing/portmaster/status" _ "github.com/safing/portmaster/ui" _ "github.com/safing/portmaster/updates" @@ -18,20 +18,6 @@ var ( ) func init() { - modules.Register("base", nil, registerDatabases, nil, "database", "config", "rng") - - // For prettier subsystem graph, printed with --print-subsystem-graph - /* - subsystems.Register( - "base", - "Base", - "THE GROUND.", - baseModule, - "", - nil, - ) - */ - module = modules.Register("core", prep, start, nil, "base", "subsystems", "status", "updates", "api", "notifications", "ui", "netenv", "network", "interception") subsystems.Register( "core", @@ -45,6 +31,14 @@ func init() { func prep() error { registerEvents() + + // init config + logFlagOverrides() + err := registerConfig() + if err != nil { + return err + } + return nil } @@ -57,5 +51,9 @@ func start() error { return err } + if err := registerControlDatabase(); err != nil { + return err + } + return nil } diff --git a/core/pmtesting/testing.go b/core/pmtesting/testing.go index f2aa215a..a3091586 100644 --- a/core/pmtesting/testing.go +++ b/core/pmtesting/testing.go @@ -27,7 +27,7 @@ import ( "github.com/safing/portbase/dataroot" "github.com/safing/portbase/log" "github.com/safing/portbase/modules" - "github.com/safing/portmaster/core" + "github.com/safing/portmaster/core/base" // module dependencies _ "github.com/safing/portbase/database/storage/hashmap" @@ -57,10 +57,10 @@ func TestMainWithHooks(m *testing.M, module *modules.Module, afterStartFn, befor module.Enable() // switch databases to memory only - core.DefaultDatabaseStorageType = "hashmap" + base.DefaultDatabaseStorageType = "hashmap" // switch API to high port - core.DefaultAPIListenAddress = "127.0.0.1:10817" + base.DefaultAPIListenAddress = "127.0.0.1:10817" // set log level log.SetLogLevel(log.TraceLevel) diff --git a/firewall/config.go b/firewall/config.go index 2a9308b3..4a6a3abf 100644 --- a/firewall/config.go +++ b/firewall/config.go @@ -12,8 +12,6 @@ var ( CfgOptionAskWithSystemNotificationsKey = "filter/askWithSystemNotifications" CfgOptionAskWithSystemNotificationsOrder = 2 - askWithSystemNotifications config.BoolOption - useSystemNotifications config.BoolOption CfgOptionAskTimeoutKey = "filter/askTimeout" CfgOptionAskTimeoutOrder = 3 @@ -56,8 +54,6 @@ func registerConfig() error { if err != nil { return err } - askWithSystemNotifications = config.Concurrent.GetAsBool(CfgOptionAskWithSystemNotificationsKey, true) - useSystemNotifications = config.Concurrent.GetAsBool(core.CfgUseSystemNotificationsKey, true) err = config.Register(&config.Option{ Name: "Timeout for Ask Notifications", diff --git a/intel/filterlists/module.go b/intel/filterlists/module.go index 38d9deaa..1f683d42 100644 --- a/intel/filterlists/module.go +++ b/intel/filterlists/module.go @@ -33,7 +33,7 @@ var ( func init() { ignoreNetEnvEvents.Set() - module = modules.Register("filterlists", prep, start, stop, "core") + module = modules.Register("filterlists", prep, start, stop, "base", "updates") } func prep() error { diff --git a/intel/geoip/module.go b/intel/geoip/module.go index be6a02ff..015eb349 100644 --- a/intel/geoip/module.go +++ b/intel/geoip/module.go @@ -12,7 +12,7 @@ var ( ) func init() { - module = modules.Register("geoip", prep, nil, nil, "core") + module = modules.Register("geoip", prep, nil, nil, "base", "updates") } func prep() error { diff --git a/profile/module.go b/profile/module.go index 1cc83688..3bd002ba 100644 --- a/profile/module.go +++ b/profile/module.go @@ -6,7 +6,8 @@ import ( "github.com/safing/portbase/modules" // module dependencies - _ "github.com/safing/portmaster/core" + _ "github.com/safing/portmaster/core/base" + _ "github.com/safing/portmaster/updates" // dependency of semi-dependency filterlists ) var ( @@ -14,7 +15,7 @@ var ( ) func init() { - module = modules.Register("profiles", prep, start, nil, "base") + module = modules.Register("profiles", prep, start, nil, "base", "updates") } func prep() error { diff --git a/resolver/main.go b/resolver/main.go index df54b793..9c71f5db 100644 --- a/resolver/main.go +++ b/resolver/main.go @@ -9,7 +9,7 @@ import ( "github.com/safing/portmaster/intel" // module dependencies - _ "github.com/safing/portmaster/core" + _ "github.com/safing/portmaster/core/base" ) var ( @@ -17,7 +17,7 @@ var ( ) func init() { - module = modules.Register("resolver", prep, start, nil, "core", "netenv") + module = modules.Register("resolver", prep, start, nil, "base", "netenv") } func prep() error {