diff options
Diffstat (limited to 'pkg/helper/darwin.go')
-rw-r--r-- | pkg/helper/darwin.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/pkg/helper/darwin.go b/pkg/helper/darwin.go index 7269981..a9f8e00 100644 --- a/pkg/helper/darwin.go +++ b/pkg/helper/darwin.go @@ -29,11 +29,11 @@ package helper import ( "errors" "fmt" - "path/filepath" "log" "os" "os/exec" "path" + "path/filepath" "strconv" "strings" @@ -43,8 +43,8 @@ import ( const ( bitmask_anchor = "com.apple/250.BitmaskFirewall" gateways_table = "bitmask_gateways" - pfctl = "/sbin/pfctl" - LogFolder = "/var/log/" + pfctl = "/sbin/pfctl" + LogFolder = "/var/log/" ) func _getExecPath() string { @@ -119,9 +119,9 @@ func kill(cmd *exec.Cmd) error { return nil } -func firewallStart(gateways []string) error { +func firewallStart(gateways []string, mode string) error { enablePf() - err := resetGatewaysTable(gateways) + err := resetGatewaysTable(gateways, mode) if err != nil { return err } @@ -155,7 +155,7 @@ func enablePf() { cmd.Run() } -func resetGatewaysTable(gateways []string) error { +func resetGatewaysTable(gateways []string, mode string) error { log.Println("Resetting gateways") cmd := exec.Command(pfctl, "-a", bitmask_anchor, "-t", gateways_table, "-T", "delete") err := cmd.Run() @@ -172,6 +172,11 @@ func resetGatewaysTable(gateways []string) error { } } + nameserver := nameserverTCP + if mode == "udp" { + nameserver = nameserverUDP + } + cmd = exec.Command(pfctl, "-a", bitmask_anchor, "-t", gateways_table, "-T", "add", nameserver) return cmd.Run() |