WIP
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/safing/portmaster/base/api"
|
||||
"github.com/safing/portmaster/base/info"
|
||||
"github.com/safing/portmaster/service/mgr"
|
||||
)
|
||||
|
||||
// Default Values (changeable for testing).
|
||||
var (
|
||||
DefaultAPIListenAddress = "127.0.0.1:817"
|
||||
|
||||
showVersion bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&showVersion, "version", false, "show version and exit")
|
||||
}
|
||||
|
||||
func prep(instance instance) error {
|
||||
// check if meta info is ok
|
||||
err := info.CheckVersion()
|
||||
if err != nil {
|
||||
return errors.New("compile error: please compile using the provided build script")
|
||||
}
|
||||
|
||||
// print version
|
||||
if showVersion {
|
||||
instance.SetCmdLineOperation(printVersion)
|
||||
return mgr.ErrExecuteCmdLineOp
|
||||
}
|
||||
|
||||
// set api listen address
|
||||
api.SetDefaultAPIListenAddress(DefaultAPIListenAddress)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func printVersion() error {
|
||||
fmt.Println(info.FullVersion())
|
||||
return nil
|
||||
}
|
||||
@@ -4,9 +4,13 @@ import (
|
||||
"errors"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/safing/portmaster/base/api"
|
||||
"github.com/safing/portmaster/service/mgr"
|
||||
)
|
||||
|
||||
// DefaultAPIListenAddress is the default listen address for the API.
|
||||
var DefaultAPIListenAddress = "127.0.0.1:817"
|
||||
|
||||
// Base is the base module.
|
||||
type Base struct {
|
||||
mgr *mgr.Manager
|
||||
@@ -47,9 +51,9 @@ func New(instance instance) (*Base, error) {
|
||||
instance: instance,
|
||||
}
|
||||
|
||||
if err := prep(instance); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Set api listen address.
|
||||
api.SetDefaultAPIListenAddress(DefaultAPIListenAddress)
|
||||
|
||||
if err := registerDatabases(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user