diff options
Diffstat (limited to 'pkg/backend')
-rw-r--r-- | pkg/backend/actions.go | 6 | ||||
-rw-r--r-- | pkg/backend/api.go | 6 | ||||
-rw-r--r-- | pkg/backend/init.go | 11 |
3 files changed, 14 insertions, 9 deletions
diff --git a/pkg/backend/actions.go b/pkg/backend/actions.go index 725a550..e45b026 100644 --- a/pkg/backend/actions.go +++ b/pkg/backend/actions.go @@ -2,14 +2,14 @@ package backend import ( "log" - "os" ) func startVPN() { + setError("") err := ctx.bm.StartVPN(ctx.Provider) if err != nil { - log.Println(err) - os.Exit(1) + log.Println("ERROR: ", err) + setError(err.Error()) } } diff --git a/pkg/backend/api.go b/pkg/backend/api.go index a799b0e..293dd9e 100644 --- a/pkg/backend/api.go +++ b/pkg/backend/api.go @@ -38,6 +38,12 @@ func Login(username, password string) { go ctx.updateStatus() } +func setError(err string) { + ctx.Errors = err + go setStatus(off) + go ctx.updateStatus() +} + func SwitchOn() { go setStatus(starting) go startVPN() diff --git a/pkg/backend/init.go b/pkg/backend/init.go index f76ab49..7d7a534 100644 --- a/pkg/backend/init.go +++ b/pkg/backend/init.go @@ -47,7 +47,7 @@ func checkErrors(errCh chan string) { func initializeBitmask(errCh chan string, opts *InitOpts) { if ctx == nil { - log.Println("bug: cannot initialize bitmask, ctx is nil!") + log.Println("BUG: cannot initialize bitmask, ctx is nil!") os.Exit(1) } bitmask.InitializeLogger() @@ -63,7 +63,7 @@ func initializeBitmask(errCh chan string, opts *InitOpts) { b, err := bitmask.InitializeBitmask(ctx.cfg) if err != nil { - log.Println("error: cannot initialize bitmask") + log.Println("ERROR: cannot initialize bitmask") errCh <- err.Error() return } @@ -72,19 +72,18 @@ func initializeBitmask(errCh chan string, opts *InitOpts) { helpers, privilege, err := b.VPNCheck() if err != nil { - log.Println("error doing vpn check") + log.Println("ERROR: vpn check") errCh <- err.Error() } if helpers == false { - log.Println("no helpers") + log.Println("ERROR: no helpers") errCh <- "nohelpers" } if privilege == false { - log.Println("no polkit") + log.Println("ERROR: no polkit") errCh <- "nopolkit" } - ctx.bm = b } |