summaryrefslogtreecommitdiff
path: root/pkg/bitmask
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-06-18 20:42:29 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-06-26 12:17:30 +0200
commitcdb42f0d6b47a60ceb647e3ac6a6ce66352dbae4 (patch)
tree40f76de30181eb1036d44516e5dd05488c8c31dc /pkg/bitmask
parent4de5748e25678dce9c5a344afc5fd40508c0860f (diff)
[test] minimal qml tests
just a minimal boilerplate. the idea is to import the qml files and assert that the states/widgets change accordingly if we mock the backend status. - Closes: #300
Diffstat (limited to 'pkg/bitmask')
-rw-r--r--pkg/bitmask/init.go28
1 files changed, 17 insertions, 11 deletions
diff --git a/pkg/bitmask/init.go b/pkg/bitmask/init.go
index 33a5911..a96ab87 100644
--- a/pkg/bitmask/init.go
+++ b/pkg/bitmask/init.go
@@ -56,14 +56,18 @@ func initBitmask(printer *message.Printer) (Bitmask, error) {
return b, err
}
-func InitializeBitmask() (Bitmask, error) {
+func InitializeBitmask(skipLaunch bool) (Bitmask, error) {
+ if skipLaunch {
+ log.Println("Initializing bitmask, but not launching it...")
+ }
if _, err := os.Stat(config.Path); os.IsNotExist(err) {
os.MkdirAll(config.Path, os.ModePerm)
}
err := pid.AcquirePID()
if err != nil {
- log.Fatal(err)
+ log.Println("Error acquiring PID:", err)
+ return nil, err
}
defer pid.ReleasePID()
@@ -75,13 +79,21 @@ func InitializeBitmask() (Bitmask, error) {
return nil, err
}
- err = checkAndStartBitmask(b, conf)
+ err = setTransport(b, conf)
if err != nil {
return nil, err
}
+ if !skipLaunch {
+ err := maybeStartVPN(b, conf)
+ if err != nil {
+ log.Println("Error starting VPN: ", err)
+ return nil, err
+ }
+ }
+
var as Autostart
- if conf.DisableAustostart {
+ if skipLaunch || conf.DisableAustostart {
as = &dummyAutostart{}
} else {
as = newAutostart(config.ApplicationName, "")
@@ -103,7 +115,7 @@ func initPrinter() *message.Printer {
return message.NewPrinter(message.MatchLanguage(locale, "en"))
}
-func checkAndStartBitmask(b Bitmask, conf *config.Config) error {
+func setTransport(b Bitmask, conf *config.Config) error {
if conf.Obfs4 {
err := b.UseTransport("obfs4")
if err != nil {
@@ -111,12 +123,6 @@ func checkAndStartBitmask(b Bitmask, conf *config.Config) error {
return err
}
}
-
- err := maybeStartVPN(b, conf)
- if err != nil {
- log.Println("Error starting VPN: ", err)
- return err
- }
return nil
}