Repository navigation
Re-read system nameservers when they change - #222
Open
MarrasFederico wants to merge 1 commit into
Open
MarrasFederico wants to merge 1 commit into
MarrasFederico wants to merge 1 commit into
Conversation
The system nameservers were read only while the server list was empty, so after a network change, e.g. a VPN reconnect, the old servers stayed in use until each one had failed maxFailures times. initSystemNameservers() now runs from pump(), still at most once every five seconds, and follows the system list: - Ports are normalized to 53 and the list is sorted and deduplicated. - An empty or unchanged list leaves the servers alone. - A changed list is used only once two consecutive reads agree. - Servers not in use are added before stale ones are removed, so requests stopped by the removal are retried on the new servers. - Nameservers added by hand or through CBANG_DNS are left alone. Re: FoldingAtHome/fah-client-bastet#337
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.
Re: FoldingAtHome/fah-client-bastet#337
DNS::Basereads the system nameservers only while its server list is empty. After a network change, such as a VPN disconnecting or reconnecting, it keeps querying the old servers. It moves on only oncepump()has dropped each of them aftermaxFailuresfailures, and until then it never uses servers that appeared later.With this change
initSystemNameservers()follows the system list. It runs at the top ofpump(), still at most once every 5 s, so noNameserveris on the stack when one is removed.add()is unchanged.Ports are normalized to 53 before comparing, because Windows reports port 0. The list is also sorted and deduplicated.
An empty or unchanged list leaves the servers alone, so servers dropped by
pump()stay dropped while the network is stable.A changed list is used only once two consecutive reads agree. While a VPN was switching protocol, Windows reported a partial list for a few seconds.
On a confirmed change:
Requests answered with
SHUTDOWNare retried on the new servers in the samepump().Nameservers added by hand are respected as before: if any was added with
addNameserver()orCBANG_DNS, the system list is not used.Testing
Linux, debug build. A test program used fake DNS servers on loopback and a
CBANG_RESOLV_CONFfile rewritten while it ran.maxFailurestimes, after 70 s. With this change, lookups worked again 10 s after the change.CBANG_DNS.Windows 11, MSVC x64 debug, NordVPN. Test programs linked against master and against this change ran side by side.
fah-client-bastet builds against this branch with no new warnings, and its unit tests pass.
Known cost: after a change, servers that had been dropped are tried again. Unreachable ones then time out for about a minute, until
pump()drops them again. Lookups were not slower in the tests.