Skip to content
Snippets Groups Projects

[feat] add /firewall/isup

Closed meskio requested to merge meskio/riseup_vpn:feat/firewall_isup into master
4 files
+ 31
0
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 10
0
@@ -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()
Loading