cmd/cli: preserve static DNS on Windows/Mac

This commit is contained in:
Cuong Manh Le
2024-02-07 14:29:20 +07:00
committed by Cuong Manh Le
parent 891b7cb2c6
commit a163be3584
3 changed files with 44 additions and 0 deletions
+5
View File
@@ -44,6 +44,11 @@ func setDNS(iface *net.Interface, nameservers []string) error {
// TODO(cuonglm): use system API
func resetDNS(iface *net.Interface) error {
if ns := savedNameservers(iface); len(ns) > 0 {
if err := setDNS(iface, ns); err == nil {
return nil
}
}
cmd := "networksetup"
args := []string{"-setdnsservers", iface.Name, "empty"}