mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
cmd/cli: do not remove forwarders when set DNS on Windows
It seems to be a Windows bug when removing a forwarder and adding a new one immediately then causing both of them to be added to forwarders list. This could be verified easily using powershell commands. Since the forwarder will be removed when ctrld stop/uninstall, ctrld run could avoid that action, not only help mitigate above bug, but also not waste host resources.
This commit is contained in:
committed by
Cuong Manh Le
parent
b8155e6182
commit
1012bf063f
@@ -41,13 +41,6 @@ func setDNS(iface *net.Interface, nameservers []string) error {
|
||||
// Configuring the Dns server to forward queries to ctrld instead.
|
||||
if windowsHasLocalDnsServerRunning() {
|
||||
file := absHomeDir(forwardersFilename)
|
||||
if data, _ := os.ReadFile(file); len(data) > 0 {
|
||||
if err := removeDnsServerForwarders(strings.Split(string(data), ",")); err != nil {
|
||||
mainLog.Load().Error().Err(err).Msg("could not remove current forwarders settings")
|
||||
} else {
|
||||
mainLog.Load().Debug().Msg("removed current forwarders settings.")
|
||||
}
|
||||
}
|
||||
if err := os.WriteFile(file, []byte(strings.Join(nameservers, ",")), 0600); err != nil {
|
||||
mainLog.Load().Warn().Err(err).Msg("could not save forwarders settings")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user