mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-10-12 01:58:46 +02:00
The journal records the network state of the host and each change of that state. The support team reads one file to see the interfaces, the routes, the resolvers, and the recoveries around an incident. The same file shows the health of the query path. A change that touches only AirDrop or virtual interfaces runs no DNS work.
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package cli
|
|
|
|
import "github.com/Control-D-Inc/ctrld"
|
|
|
|
var initializeOsResolver = ctrld.InitializeOsResolverWithReason
|
|
|
|
// Reasons that the journal reports when the resolver set changes. Each one
|
|
// names the code path that read the resolvers of the host.
|
|
const (
|
|
osResolverReasonStart = "start"
|
|
osResolverReasonWakeProbe = "wake_probe"
|
|
osResolverReasonVPNSettle = "vpn_settle"
|
|
osResolverReasonDelayedRecheck = "delayed_recheck"
|
|
)
|
|
|
|
func (p *prog) refreshDNSAfterVPNSettle(reason string) (routes, domainlessServers, exemptions int) {
|
|
mainLog.Load().Info().Msgf("DNS intercept: refreshing OS/VPN DNS route state after VPN settle (%s)", reason)
|
|
ns := initializeOsResolver(true, osResolverReasonVPNSettle)
|
|
mainLog.Load().Debug().Msgf("DNS intercept: post-settle OS resolver nameservers: %v", ns)
|
|
|
|
if p.vpnDNS == nil {
|
|
mainLog.Load().Debug().Msg("DNS intercept: post-settle VPN DNS route refresh skipped — manager unavailable")
|
|
return 0, 0, 0
|
|
}
|
|
|
|
routes, domainlessServers, exemptions = p.vpnDNS.RefreshRoutesOnly()
|
|
mainLog.Load().Info().Msgf("DNS intercept: post-settle VPN DNS route refresh completed — %d routes, %d domainless servers, %d exemptions",
|
|
routes, domainlessServers, exemptions)
|
|
return routes, domainlessServers, exemptions
|
|
}
|
|
|
|
func vpnDNSExemptionsEqual(a, b []vpnDNSExemption) bool {
|
|
if len(a) != len(b) {
|
|
return false
|
|
}
|
|
seen := make(map[vpnDNSExemption]int, len(a))
|
|
for _, ex := range a {
|
|
seen[ex]++
|
|
}
|
|
for _, ex := range b {
|
|
if seen[ex] == 0 {
|
|
return false
|
|
}
|
|
seen[ex]--
|
|
}
|
|
return true
|
|
}
|