summaryrefslogtreecommitdiff
path: root/pkg/standalone
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2019-09-05 01:14:06 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2019-09-05 01:18:47 +0200
commit80993915cad062e7b1efe86bfe18faae809d25bb (patch)
tree7b54a34a634b221563ac7d200db6eb4665e460d2 /pkg/standalone
parent1259bed3f1d316874fc4eb790fd9ef31bffeab0f (diff)
[bug] parse the result of firewall/isup for osx
Diffstat (limited to 'pkg/standalone')
-rw-r--r--pkg/standalone/launcher.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/pkg/standalone/launcher.go b/pkg/standalone/launcher.go
index 36d7ab0..ed9ea5d 100644
--- a/pkg/standalone/launcher.go
+++ b/pkg/standalone/launcher.go
@@ -23,6 +23,7 @@ import (
"io"
"io/ioutil"
"net/http"
+ "strconv"
"0xacab.org/leap/bitmask-vpn/pkg/standalone/bonafide"
)
@@ -75,13 +76,29 @@ func (l *launcher) firewallStop() error {
}
func (l *launcher) firewallIsUp() bool {
+ var isup bool = false
res, err := http.Post(helperAddr+"/firewall/isup", "", nil)
if err != nil {
return false
}
defer res.Body.Close()
- return res.StatusCode == http.StatusOK
+ if res.StatusCode != http.StatusOK {
+ fmt.Printf("Got an error status code for firewall/isup: %v\n", res.StatusCode)
+ isup = false
+ } else {
+ upStr, err := ioutil.ReadAll(res.Body)
+ if err != nil {
+ fmt.Errorf("Error getting body for firewall/isup: %q", err)
+ return false
+ }
+ isup, err = strconv.ParseBool(string(upStr))
+ if err != nil {
+ fmt.Errorf("Error parsing body for firewall/isup: %q", err)
+ return false
+ }
+ }
+ return isup
}
func (l *launcher) send(path string, body []byte) error {