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:
Cuong Manh Le authored and Cuong Manh Le committed 2024-02-19 18:29:22 +07:00
1 parent 18e8616834
commit 4d810261a4
6 files changed
+122 -26

No files matched your search

+5
View File
@@ -203,6 +203,11 @@ func currentDNS(iface *net.Interface) []string {
return nil
}
// currentStaticDNS returns the current static DNS settings of given interface.
func currentStaticDNS(iface *net.Interface) []string {
return currentDNS(iface)
}
func getDNSByResolvectl(iface string) []string {
b, err := exec.Command("resolvectl", "dns", "-i", iface).Output()
if err != nil {