refactor(dns): fall back to Cloudflare DNS instead of Google - #614
Merged
Merged
Conversation
ResolverConfig::default() is ResolverConfig::google(), so when the system resolver config cannot be read the fallback is 8.8.8.8. That is not reachable from mainland China, where the lookup then times out. Use ResolverConfig::cloudflare() instead, and say so in the message and the doc comment. Closes 0x676e67#608
This branch was successfully deployed
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.
Closes #608.
When
TokioResolver::builder_tokio()fails to read the system resolver config,src/dns.rsfalls back toResolverConfig::default(). In hickory-resolver 0.25.2 that isResolverConfig::google():So the fallback is 8.8.8.8, which does not work from mainland China and the lookup times out. This is the path Termux takes, since it has no
/etc/resolv.conf.Checked against 0.25.2 rather than assumed — the two configs resolve to:
ResolverConfig::cloudflare()is plain UDP/TCP on port 53 and carries no feature gate, unlikecloudflare_tls(), so it is a drop-in swap at the same call site.The
eprintln!and the doc comment said "defaults" and now name Cloudflare, so they don't drift from the code.Notes
builder_tokio()success path is untouched.DnsOptions(system_dns=True)remains the way to bypass hickory entirely.tests/, and the crate has no#[cfg(test)]modules to extend. Say if you want the config extracted into a helper so it can be asserted on.ResolverConfighas noDefaultand the providers areServerGroupconstants. This line has to change either way; happy to rebase whichever lands second.What I did not verify
The crate does not build on my machine —
btls-sysneeds nasm for BoringSSL — so I rancargo fmt --all -- --checkonly, notcargo clippy. The swap and the call site were type-checked against hickory-resolver 0.25.2 in a separate crate, which is where the two lines of output above come from. I also could not reproduce the original timeout: no Android device here.