cmd/cli: only emit error for running interfaces

While at it, also ensure setDNS/resetDNS return a wrapped error on
Darwin/Windows, so the caller can decide whether to print the error to
users.
This commit is contained in:
Cuong Manh Le
2024-02-13 18:11:53 +07:00
committed by Cuong Manh Le
parent 5145729ab1
commit fdb82f6ec3
4 changed files with 23 additions and 14 deletions
+3 -1
View File
@@ -704,7 +704,9 @@ func withEachPhysicalInterfaces(excludeIfaceName, context string, f func(i *net.
return
}
if err := f(netIface); err != nil {
mainLog.Load().Warn().Err(err).Msgf("failed to %s for interface: %q", context, i.Name)
if ifaceUp(netIface) {
mainLog.Load().Warn().Err(err).Msgf("failed to %s for interface: %q", context, i.Name)
}
} else {
mainLog.Load().Debug().Msgf("%s for interface %q successfully", context, i.Name)
}