mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
cmd/cli: log interfaces state after dns set
The data will be useful for troubleshooting later.
This commit is contained in:
committed by
Cuong Manh Le
parent
20759017e6
commit
0fbfd160c9
@@ -1251,6 +1251,7 @@ func (p *prog) reinitializeOSResolver() {
|
|||||||
mainLog.Load().Debug().Msg("setting DNS configuration")
|
mainLog.Load().Debug().Msg("setting DNS configuration")
|
||||||
p.setDNS()
|
p.setDNS()
|
||||||
mainLog.Load().Debug().Msg("DNS configuration set successfully")
|
mainLog.Load().Debug().Msg("DNS configuration set successfully")
|
||||||
|
p.logInterfacesState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,6 +273,7 @@ func (p *prog) postRun() {
|
|||||||
p.setDNS()
|
p.setDNS()
|
||||||
p.csSetDnsDone <- struct{}{}
|
p.csSetDnsDone <- struct{}{}
|
||||||
close(p.csSetDnsDone)
|
close(p.csSetDnsDone)
|
||||||
|
p.logInterfacesState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,6 +816,28 @@ func (p *prog) resetDNS() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *prog) logInterfacesState() {
|
||||||
|
withEachPhysicalInterfaces("", "", func(i *net.Interface) error {
|
||||||
|
addrs, err := i.Addrs()
|
||||||
|
if err != nil {
|
||||||
|
mainLog.Load().Warn().Str("interface", i.Name).Err(err).Msg("failed to get addresses")
|
||||||
|
}
|
||||||
|
nss, err := currentStaticDNS(i)
|
||||||
|
if err != nil {
|
||||||
|
mainLog.Load().Warn().Str("interface", i.Name).Err(err).Msg("failed to get DNS")
|
||||||
|
}
|
||||||
|
if len(nss) == 0 {
|
||||||
|
nss = currentDNS(i)
|
||||||
|
}
|
||||||
|
mainLog.Load().Debug().
|
||||||
|
Any("addrs", addrs).
|
||||||
|
Strs("nameservers", nss).
|
||||||
|
Int("index", i.Index).
|
||||||
|
Msgf("interface state: %s", i.Name)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// findWorkingInterface looks for a network interface with a valid IP configuration
|
// findWorkingInterface looks for a network interface with a valid IP configuration
|
||||||
func findWorkingInterface(currentIface string) string {
|
func findWorkingInterface(currentIface string) string {
|
||||||
// Helper to check if IP is valid (not link-local)
|
// Helper to check if IP is valid (not link-local)
|
||||||
|
|||||||
Reference in New Issue
Block a user