mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Fix tests: split core package into core and base
This commit is contained in:
parent
3ce67133e4
commit
f4b8ad7d7c
10 changed files with 51 additions and 38 deletions
|
@ -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
|
||||
}
|
|
@ -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)
|
||||
|
25
core/base/module.go
Normal file
25
core/base/module.go
Normal file
|
@ -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,
|
||||
)
|
||||
*/
|
||||
}
|
28
core/core.go
28
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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue