cmd/cli: always set/reset DNS regardless of interfaces state

The interface may be down during ctrld uninstall, so the previous set
DNS won't be restored, causing bad state when interface is up again.
This commit is contained in:
Cuong Manh Le
2024-02-10 13:08:50 +07:00
committed by Cuong Manh Le
parent 4d810261a4
commit 5145729ab1

View File

@@ -682,12 +682,8 @@ func canBeLocalUpstream(addr string) bool {
// log message when error happens.
func withEachPhysicalInterfaces(excludeIfaceName, context string, f func(i *net.Interface) error) {
interfaces.ForeachInterface(func(i interfaces.Interface, prefixes []netip.Prefix) {
// Skip not-running/local/virtual interface.
if !i.IsUp() || i.IsLoopback() || len(i.HardwareAddr) == 0 {
return
}
// Skip non-configured interfaces.
if addrs, _ := i.Addrs(); len(addrs) == 0 {
// Skip loopback/virtual interface.
if i.IsLoopback() || len(i.HardwareAddr) == 0 {
return
}
// Skip invalid interface.