Skip to content
Snippets Groups Projects
Unverified Commit 80993915 authored by Kali Kaneko's avatar Kali Kaneko
Browse files

[bug] parse the result of firewall/isup for osx

parent 1259bed3
Branches
Tags
No related merge requests found
......@@ -27,7 +27,6 @@ To inspect the rules in the firewall manually, use the bitmask anchor:
package helper
import (
"bytes"
"errors"
"fmt"
"log"
......@@ -124,7 +123,7 @@ func firewallIsUp() bool {
log.Printf(string(out))
return false
}
return bytes.Contains(out, []byte("block out proto udp to any port 53"))
return strings.Contains(string(out), "block drop out proto udp from any to any port = 53")
}
func enablePf() {
......
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment