fix(dns): preserve NRPT rules on startup and improve hosts file retry#114
Draft
fix(dns): preserve NRPT rules on startup and improve hosts file retry#114
Conversation
Two changes to improve DNS resilience on Windows when GlobalProtect or other VPNs cause engine restarts: 1. Don't delete NRPT rules in nrptRuleDatabase constructor. Previously, newNRPTRuleDatabase() called DelAllRuleKeys() unconditionally, wiping all .coder DNS routing rules on engine startup. Now, existing rules are tracked as 'stale' and only cleaned up after replacement rules are confirmed written in WriteSplitDNSConfig(). This preserves DNS routing during the gap between engine creation and first successful configuration. 2. Replace hosts file retry (5x10ms) with exponential backoff. Endpoint security tools (GlobalProtect, CrowdStrike, Windows Defender) can hold the hosts file for seconds. The new retry uses 50ms initial backoff, 2x multiplier, 5s max, 30s deadline, with debug logging on each attempt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two changes to improve DNS resilience on Windows when GlobalProtect or other VPNs cause engine restarts.
Problem
When the Coder Desktop tunnel binary restarts (e.g., after a GlobalProtect VPN reconnect), the Tailscale engine is recreated. During this process:
newNRPTRuleDatabase()calledDelAllRuleKeys()unconditionally, deleting all.coderNRPT routing rules from the Windows registry — even though they were valid and working.dns.Set()call often fails because thehostsfile is locked by endpoint security (GP, CrowdStrike, Defender), and the retry window was only 50ms (5×10ms).Fix
1. Preserve NRPT rules on startup (
nrpt_windows.go)newNRPTRuleDatabase()no longer callsDelAllRuleKeys()staleRuleIDsfieldWriteSplitDNSConfig()call, after replacement rules are confirmed writtenDelAllRuleKeys()also cleans up stale rules if called directly (e.g., during teardown).coderDNS routing during the gap between engine creation and first successful configuration2. Exponential backoff for hosts file retry (
manager_windows.go)Fixes https://linear.app/codercom/issue/PLAT-110
Companion to coder/coder#24253