diff options
author | Ruben Pollan <meskio@sindominio.net> | 2019-01-09 12:35:19 +0100 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2019-01-10 00:25:55 +0100 |
commit | a9876d6803f281db299ba64f5c7d377303ee8bdb (patch) | |
tree | a90e7baf3e3f81641a3dc4c7f3999d7164b1e2b7 /helper/darwin.go | |
parent | 18f313693543132e8c1e627a3da9facd6f984c40 (diff) |
[feat] add /firewall/isup
- Related: bitmask-systray#97
Diffstat (limited to 'helper/darwin.go')
-rw-r--r-- | helper/darwin.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/helper/darwin.go b/helper/darwin.go index 10bab31..99e0d46 100644 --- a/helper/darwin.go +++ b/helper/darwin.go @@ -27,6 +27,7 @@ To inspect the rules in the firewall manually, use the bitmask anchor: package main import ( + "bytes" "errors" "fmt" "log" @@ -103,6 +104,15 @@ func firewallStop() error { return exec.Command(pfctl, "-a", bitmask_anchor, "-F", "all").Run() } +func firewallIsUp() bool { + out, err := exec.Command(pfctl, "-a", bitmask_anchor, "-sr").Output() + if err != nil { + log.Printf("An error ocurred getting the status of the firewall: %v", err) + return false + } + return bytes.Contains(out, []byte("block out proto udp to any port 53")) +} + func enablePf() { cmd := exec.Command(pfctl, "-e") cmd.Run() |