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

This commit is contained in:
Cuong Manh Le
2024-02-21 15:48:40 +07:00
committed by Cuong Manh Le
parent 8f189c919a
commit 7dc5138e91
6 changed files with 148 additions and 69 deletions
+7
View File
@@ -468,6 +468,13 @@ func (p *prog) setDNS() {
return
}
logger.Debug().Msg("setting DNS successfully")
if shouldWatchResolvconf() {
servers := make([]netip.Addr, len(nameservers))
for i := range nameservers {
servers[i] = netip.MustParseAddr(nameservers[i])
}
go watchResolvConf(netIface, servers, setResolvConf)
}
if allIfaces {
withEachPhysicalInterfaces(netIface.Name, "set DNS", func(i *net.Interface) error {
return setDNS(i, nameservers)