mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-16 13:17:19 +02:00
cmd/cli: only set DNS for physical interfaces on Windows
By filtering the interfaces by MAC address instead of name.
This commit is contained in:
committed by
Cuong Manh Le
parent
73a697b2fa
commit
e89021ec3a
+5
-5
@@ -707,13 +707,11 @@ func withEachPhysicalInterfaces(excludeIfaceName, context string, f func(i *net.
|
||||
if netIface.Name == excludeIfaceName {
|
||||
return
|
||||
}
|
||||
// Skip Windows Hyper-V Default Switch.
|
||||
if strings.Contains(netIface.Name, "vEthernet") {
|
||||
return
|
||||
}
|
||||
// TODO: investigate whether we should report this error?
|
||||
if err := f(netIface); err == nil {
|
||||
mainLog.Load().Debug().Msgf("%s for interface %q successfully", context, i.Name)
|
||||
} else if !errors.Is(err, errSaveCurrentStaticDNSNotSupported) {
|
||||
mainLog.Load().Err(err).Msgf("%s for interface %q failed", context, i.Name)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -728,13 +726,15 @@ func requiredMultiNICsConfig() bool {
|
||||
}
|
||||
}
|
||||
|
||||
var errSaveCurrentStaticDNSNotSupported = errors.New("saving current DNS is not supported on this platform")
|
||||
|
||||
// saveCurrentStaticDNS saves the current static DNS settings for restoring later.
|
||||
// Only works on Windows and Mac.
|
||||
func saveCurrentStaticDNS(iface *net.Interface) error {
|
||||
switch runtime.GOOS {
|
||||
case "windows", "darwin":
|
||||
default:
|
||||
return nil
|
||||
return errSaveCurrentStaticDNSNotSupported
|
||||
}
|
||||
file := savedStaticDnsSettingsFilePath(iface)
|
||||
ns, _ := currentStaticDNS(iface)
|
||||
|
||||
Reference in New Issue
Block a user