cmd/cli: watch resolv.conf on all unix platforms

This commit is contained in:
Cuong Manh Le
2024-02-22 18:15:36 +07:00
committed by Cuong Manh Le
parent 8f189c919a
commit 7dc5138e91
6 changed files with 148 additions and 69 deletions
+20
View File
@@ -0,0 +1,20 @@
package cli
import (
"net"
"net/netip"
)
// setResolvConf sets the content of resolv.conf file using the given nameservers list.
func setResolvConf(iface *net.Interface, ns []netip.Addr) error {
servers := make([]string, len(ns))
for i := range ns {
servers[i] = ns[i].String()
}
return setDNS(iface, servers)
}
// shouldWatchResolvconf reports whether ctrld should watch changes to resolv.conf file with given OS configurator.
func shouldWatchResolvconf() bool {
return true
}