From 5145729ab16ecd61cdb22d1bf56d448aaf3a80e6 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sat, 10 Feb 2024 13:08:50 +0700 Subject: [PATCH] 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. --- cmd/cli/prog.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cmd/cli/prog.go b/cmd/cli/prog.go index 3042248..7286acd 100644 --- a/cmd/cli/prog.go +++ b/cmd/cli/prog.go @@ -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.