mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-16 13:17:19 +02:00
fix: restore v1 intercept parity on master
Restore the previously merged macOS VPN DNS post-settle refresh, unchanged-exemption suppression, forced pf state flush, and self-upgrade test after they were removed by the firewall-mode merge. Also keep Windows NRPT pointed at loopback when the listener is configured on a wildcard address.
This commit is contained in:
committed by
Cuong Manh Le
parent
7f3d332b64
commit
c43739e42d
@@ -1233,6 +1233,10 @@ func (p *prog) pfStabilizationLoop(ctx context.Context, stableRequired time.Dura
|
||||
p.pfStabilizing.Store(false)
|
||||
mainLog.Load().Info().Msgf("DNS intercept: pf stable for %s — restoring anchor rules", stableRequired)
|
||||
p.ensurePFAnchorActive()
|
||||
routes, domainlessServers, exemptions := p.refreshDNSAfterVPNSettle("pf_stabilized")
|
||||
if routes == 0 && domainlessServers == 0 && exemptions == 0 {
|
||||
p.scheduleDNSAfterVPNSettleRefresh("pf_stabilized_followup", pfAnchorRecheckDelayLong)
|
||||
}
|
||||
p.pfLastRestoreTime.Store(time.Now().UnixMilli())
|
||||
return
|
||||
}
|
||||
@@ -1459,6 +1463,15 @@ func isResourceExhaustion(err error, output []byte) bool {
|
||||
strings.Contains(msg, "cannot allocate memory")
|
||||
}
|
||||
|
||||
func (p *prog) scheduleDNSAfterVPNSettleRefresh(reason string, delay time.Duration) {
|
||||
time.AfterFunc(delay, func() {
|
||||
if p.dnsInterceptState == nil {
|
||||
return
|
||||
}
|
||||
p.refreshDNSAfterVPNSettle(reason)
|
||||
})
|
||||
}
|
||||
|
||||
// pfWatchdog periodically checks that our pf anchor is still active.
|
||||
// Other programs (e.g., Windscribe desktop app, macOS configd) can replace
|
||||
// scheduleDelayedRechecks schedules delayed re-checks after a network change event.
|
||||
@@ -1826,7 +1839,14 @@ func (p *prog) forceReloadPFMainRuleset() {
|
||||
mainLog.Load().Error().Err(err).Msgf("DNS intercept: force reload — failed to load anchor (output: %s)", strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
// Reset upstream transports — pf reload flushes state table, killing DoH connections.
|
||||
// Flush stale rdr/reply states after the forced ruleset + anchor reload.
|
||||
// Without this, macOS can keep using pre-reload state and try to send
|
||||
// redirected DNS replies directly from loopback to tunnel client addresses
|
||||
// (for example, 127.0.0.1:<listener> -> 100.64.0.0/10), which fails with
|
||||
// "sendmsg: can't assign requested address".
|
||||
flushPFStates()
|
||||
|
||||
// Reset upstream transports — pf reload/state flush kills existing DoH connections.
|
||||
p.resetUpstreamTransports()
|
||||
|
||||
mainLog.Load().Info().Msg("DNS intercept: force reload — pf ruleset and anchor reloaded successfully")
|
||||
|
||||
Reference in New Issue
Block a user