diff --git a/cmd/bitmask-vpn/main.go b/cmd/bitmask-vpn/main.go index ad85b0eff8462bddcd6770a9d3a415d7510579f7..77ace31a57783a739bf4773ccdc07645b2aa1da2 100644 --- a/cmd/bitmask-vpn/main.go +++ b/cmd/bitmask-vpn/main.go @@ -51,12 +51,20 @@ func main() { selectGateway := flag.Bool("select-gateway", false, "Enable gateway selection") disableAutostart := flag.Bool("disable-autostart", false, "Disable the autostart for the next run") + startVPN := flag.String("start-vpn", "", "Start the vpn in turned 'on' or 'off'") versionFlag := flag.Bool("version", false, "Version of the bitmask-systray") flag.Parse() if *versionFlag { fmt.Println(version) os.Exit(0) } + if *startVPN != "" { + if *startVPN != "on" && *startVPN != "off" { + fmt.Println("-start-vpn should be 'on' or 'off'") + os.Exit(1) + } + conf.StartVPN = *startVPN == "on" + } if *selectGateway { conf.SelectGateway = *selectGateway } diff --git a/pkg/systray/config.go b/pkg/systray/config.go index 2755851033651ecdec7dca7c2e070e5d10298b87..e53dea9a49f23c7d160af50212f97c0a079d014f 100644 --- a/pkg/systray/config.go +++ b/pkg/systray/config.go @@ -45,6 +45,7 @@ type Config struct { } SelectGateway bool DisableAustostart bool + StartVPN bool Version string Printer *message.Printer } @@ -65,6 +66,7 @@ func ParseConfig() *Config { conf.SelectGateway = conf.file.SelectGateway conf.DisableAustostart = conf.file.DisableAustostart + conf.StartVPN = !conf.file.UserStoppedVPN return &conf } @@ -73,10 +75,6 @@ func (c *Config) setUserStoppedVPN(vpnStopped bool) error { return c.save() } -func (c *Config) wasUserStopped() bool { - return c.file.UserStoppedVPN -} - func (c *Config) hasDonated() bool { return c.file.Donated.Add(oneMonth).After(time.Now()) } diff --git a/pkg/systray/run.go b/pkg/systray/run.go index 28789287594feab2523a3c53bee7aaf2b1128b02..172b9e85a10d29a9aa72ec5ce398aa25e2454928 100644 --- a/pkg/systray/run.go +++ b/pkg/systray/run.go @@ -98,7 +98,7 @@ func checkAndInstallHelpers(b bitmask.Bitmask, notify *notificator) error { } func maybeStartVPN(b bitmask.Bitmask, conf *Config) error { - if conf.wasUserStopped() { + if !conf.StartVPN { return nil }