From f9db4cc9901d41d4a1d0e8f4890c7f8ba5e565d6 Mon Sep 17 00:00:00 2001 From: lucus Date: Mon, 4 Jun 2018 17:40:02 +0900 Subject: [PATCH 1/2] Fix issue #89 Better handle dns on macOS --- security/dns.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/dns.go b/security/dns.go index 7360d801..69edfcc3 100644 --- a/security/dns.go +++ b/security/dns.go @@ -42,7 +42,8 @@ func dnsLinux() []string { } func dnsMacOS() []string { - cmd := exec.Command("networksetup", "-getdnsservers", "Wi-Fi") + cmdString := `scutil --dns | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'` + cmd := exec.Command("sh", "-c", cmdString) out := wtf.ExecuteCommand(cmd) lines := strings.Split(out, "\n") From 4e93b040bcb48a09c0fa48eced3048d54613c34a Mon Sep 17 00:00:00 2001 From: lucus Date: Mon, 4 Jun 2018 20:58:44 +0900 Subject: [PATCH 2/2] Fix duplicated output produced by scutil --- security/dns.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/dns.go b/security/dns.go index 69edfcc3..2408c2c1 100644 --- a/security/dns.go +++ b/security/dns.go @@ -42,7 +42,7 @@ func dnsLinux() []string { } func dnsMacOS() []string { - cmdString := `scutil --dns | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'` + cmdString := `scutil --dns | head -n 7 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'` cmd := exec.Command("sh", "-c", cmdString) out := wtf.ExecuteCommand(cmd)