summaryrefslogtreecommitdiff
path: root/pkg/backend
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2020-08-04 19:28:43 +0200
committerRuben Pollan <meskio@sindominio.net>2020-08-13 17:16:09 +0200
commit7c4a4f5ae0c02f57eb9073fa8f412a38b8f79363 (patch)
treea261cd36e44917e6a0c5abc3c1dc4f9f0545e4e5 /pkg/backend
parentabb65c7fcf570e69480ca70c92d4e271a78ffee2 (diff)
Quit if there was an initializaton error
Let's close properly without segfaults :)
Diffstat (limited to 'pkg/backend')
-rw-r--r--pkg/backend/api.go9
-rw-r--r--pkg/backend/init.go2
2 files changed, 7 insertions, 4 deletions
diff --git a/pkg/backend/api.go b/pkg/backend/api.go
index 99e156f..ff8c1bb 100644
--- a/pkg/backend/api.go
+++ b/pkg/backend/api.go
@@ -4,7 +4,6 @@ package backend
import (
"C"
- "fmt"
"log"
"strconv"
"unsafe"
@@ -31,7 +30,9 @@ func Quit() {
} else {
ctx.cfg.SetUserStoppedVPN(true)
}
- ctx.bm.Close()
+ if ctx.bm != nil {
+ ctx.bm.Close()
+ }
}
func DonateAccepted() {
@@ -55,7 +56,9 @@ func InitializeBitmaskContext(opts *InitOpts) {
initOnce.Do(func() { initializeContext(opts) })
runDonationReminder()
- go ctx.updateStatus()
+ if ctx.bm != nil {
+ go ctx.updateStatus()
+ }
}
func RefreshContext() *C.char {
diff --git a/pkg/backend/init.go b/pkg/backend/init.go
index 79efdc7..bae9b9b 100644
--- a/pkg/backend/init.go
+++ b/pkg/backend/init.go
@@ -45,6 +45,7 @@ func initializeBitmask(errCh chan string, opts *InitOpts) {
os.Exit(1)
}
bitmask.InitializeLogger()
+ ctx.cfg = config.ParseConfig()
b, err := bitmask.InitializeBitmask(opts.SkipLaunch)
if err != nil {
@@ -70,5 +71,4 @@ func initializeBitmask(errCh chan string, opts *InitOpts) {
}
ctx.bm = b
- ctx.cfg = config.ParseConfig()
}