diff options
| author | salam4ik <72976946+thesalam4ik@users.noreply.github.com> | 2026-02-04 08:45:17 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-03 21:45:17 -0600 |
| commit | 4bf82475c6a425bcf6f7d5880009fb9e47be998b (patch) | |
| tree | fecaa8ea7fc1572fbe816cebc1c7167c27648bbb | |
| parent | 90b964fb6c1501accc529a47b2d6b37db65622fe (diff) | |
| download | azalea-drasl-4bf82475c6a425bcf6f7d5880009fb9e47be998b.tar.xz | |
Fallback to Google DNS in resolver initialization (#315)
* Fallback to Google DNS in resolver initialization
If the default TokioResolver builder fails, the resolver now falls back to using Google's DNS configuration. This improves reliability in environments where the system DNS configuration may be unavailable or invalid.
* Add warning when falling back to Google DNS
A tracing warning is now logged if the system DNS resolver is unavailable and the resolver falls back to using Google DNS. This improves visibility into resolver configuration issues.
| -rw-r--r-- | azalea-protocol/src/resolve.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/azalea-protocol/src/resolve.rs b/azalea-protocol/src/resolve.rs index 92939c8c..cd76ea43 100644 --- a/azalea-protocol/src/resolve.rs +++ b/azalea-protocol/src/resolve.rs @@ -6,7 +6,10 @@ use std::{ }; pub use hickory_resolver::ResolveError; -use hickory_resolver::{Name, TokioResolver, name_server::TokioConnectionProvider}; +use hickory_resolver::{ + Name, TokioResolver, config::ResolverConfig, name_server::TokioConnectionProvider, +}; +use tracing::warn; use crate::address::ServerAddr; @@ -16,7 +19,13 @@ pub type ResolverError = ResolveError; static RESOLVER: LazyLock<TokioResolver> = LazyLock::new(|| { TokioResolver::builder(TokioConnectionProvider::default()) - .unwrap() + .unwrap_or_else(|_| { + warn!("System DNS resolver unavailable; falling back to Google DNS."); + TokioResolver::builder_with_config( + ResolverConfig::google(), + TokioConnectionProvider::default(), + ) + }) .build() }); |
