mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-15 00:50:25 +02:00
cmd/cli: only save/restore static DNS
The save/restore DNS functionality always perform its job, even though the DNS is not static, aka set by DHCP. That may lead to confusion to users. Since DHCP settings was changed to static settings, even though the namesers set are the same. To fix this, ctrld should save/restore only there's actual static DNS set. For DHCP, thing should work as-is like we are doing.
This commit is contained in:
committed by
Cuong Manh Le
parent
18e8616834
commit
4d810261a4
+3
-5
@@ -270,10 +270,7 @@ func initCLI() {
|
||||
{func() error { return ensureUninstall(s) }, false},
|
||||
{func() error {
|
||||
// Save current DNS so we can restore later.
|
||||
withEachPhysicalInterfaces("", "save DNS settings", func(i *net.Interface) error {
|
||||
saveCurrentDNS(i)
|
||||
return nil
|
||||
})
|
||||
withEachPhysicalInterfaces("", "save DNS settings", saveCurrentStaticDNS)
|
||||
return nil
|
||||
}, false},
|
||||
{s.Install, false},
|
||||
@@ -2197,7 +2194,8 @@ func exchangeContextWithTimeout(c *dns.Client, timeout time.Duration, msg *dns.M
|
||||
|
||||
// powershell runs the given powershell command.
|
||||
func powershell(cmd string) ([]byte, error) {
|
||||
return exec.Command("powershell", "-Command", cmd).CombinedOutput()
|
||||
out, err := exec.Command("powershell", "-Command", cmd).CombinedOutput()
|
||||
return bytes.TrimSpace(out), err
|
||||
}
|
||||
|
||||
// windowsHasLocalDnsServerRunning reports whether we are on Windows and having Dns server running.
|
||||
|
||||
Reference in New Issue
Block a user