diff --git a/standalone/launcher.go b/standalone/launcher.go index 03178c513fbc61f663852b9254107e0af59f604d..0a95dd143e162930c01adbf474257b1019886676 100644 --- a/standalone/launcher.go +++ b/standalone/launcher.go @@ -68,6 +68,16 @@ func (l *launcher) firewallStop() error { return l.send("/firewall/stop", nil) } +func (l *launcher) firewallIsUp() bool { + res, err := http.Post(helperAddr+"/firewall/isup", "", nil) + if err != nil { + return false + } + defer res.Body.Close() + + return res.StatusCode == http.StatusOK +} + func (l *launcher) send(path string, body []byte) error { var reader io.Reader if body != nil { diff --git a/standalone/launcher_linux.go b/standalone/launcher_linux.go index a434ecd499c4b8a59caf2f45489131f71972052f..5266fa1fa288ec3de65990bb4bb36a4cf54ea196 100644 --- a/standalone/launcher_linux.go +++ b/standalone/launcher_linux.go @@ -75,6 +75,11 @@ func (l *launcher) firewallStop() error { return runBitmaskRoot("firewall", "stop") } +func (l *launcher) firewallIsUp() bool { + err := runBitmaskRoot("firewall", "isup") + return err == nil +} + func (l *launcher) openvpnRunner(arg ...string) { running := false runOpenvpn := func(arg []string) { diff --git a/standalone/vpn.go b/standalone/vpn.go index e3ecca4739158de03d9b9108455244e6fd36693e..0ff090cfb23889ca3e800f341d67e54fbb2fa066 100644 --- a/standalone/vpn.go +++ b/standalone/vpn.go @@ -88,6 +88,9 @@ func (b *Bitmask) GetStatus() (string, error) { if err != nil { status = Off } + if status == Off && b.launch.firewallIsUp() { + return Failed, nil + } return status, nil }