diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2020-06-17 21:14:35 +0200 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2020-06-26 12:13:44 +0200 |
commit | 20266b063c1be8818d4582bff7b59486551ee447 (patch) | |
tree | 2f7bd97624104e7defecd6d29fff8dad2446c0ce /pkg/bitmask/init.go | |
parent | 9b8009cfaf6707d23a20494cd5467aed9c98513b (diff) |
[feat] pass initialization errors to gui
Diffstat (limited to 'pkg/bitmask/init.go')
-rw-r--r-- | pkg/bitmask/init.go | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/pkg/bitmask/init.go b/pkg/bitmask/init.go index 7f10ab9..33a5911 100644 --- a/pkg/bitmask/init.go +++ b/pkg/bitmask/init.go @@ -68,15 +68,17 @@ func InitializeBitmask() (Bitmask, error) { defer pid.ReleasePID() conf := config.ParseConfig() - conf.Version = "unknown" conf.Printer = initPrinter() b, err := initBitmask(conf.Printer) if err != nil { - // TODO notify failure - log.Fatal(err) + return nil, err + } + + err = checkAndStartBitmask(b, conf) + if err != nil { + return nil, err } - go checkAndStartBitmask(b, conf) var as Autostart if conf.DisableAustostart { @@ -84,6 +86,7 @@ func InitializeBitmask() (Bitmask, error) { } else { as = newAutostart(config.ApplicationName, "") } + err = as.Enable() if err != nil { log.Printf("Error enabling autostart: %v", err) @@ -100,40 +103,20 @@ func initPrinter() *message.Printer { return message.NewPrinter(message.MatchLanguage(locale, "en")) } -func checkAndStartBitmask(b Bitmask, conf *config.Config) { +func checkAndStartBitmask(b Bitmask, conf *config.Config) error { if conf.Obfs4 { err := b.UseTransport("obfs4") if err != nil { log.Printf("Error setting transport: %v", err) + return err } } - err := checkAndInstallHelpers(b) - if err != nil { - log.Printf("Is bitmask running? %v", err) - os.Exit(1) - } - err = maybeStartVPN(b, conf) + + err := maybeStartVPN(b, conf) if err != nil { log.Println("Error starting VPN: ", err) - } -} - -func checkAndInstallHelpers(b Bitmask) error { - helpers, privilege, err := b.VPNCheck() - if (err != nil && err.Error() == "nopolkit") || (err == nil && !privilege) { - log.Printf("No polkit found") - os.Exit(1) - } else if err != nil { - log.Printf("Error checking vpn: %v", err) return err } - - if !helpers { - err = b.InstallHelpers() - if err != nil { - log.Println("Error installing helpers: ", err) - } - } return nil } |