From 4bf82475c6a425bcf6f7d5880009fb9e47be998b Mon Sep 17 00:00:00 2001 From: salam4ik <72976946+thesalam4ik@users.noreply.github.com> Date: Wed, 4 Feb 2026 08:45:17 +0500 Subject: 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. --- azalea-protocol/src/resolve.rs | 13 +++++++++++-- 1 file 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 = 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() }); -- cgit v1.2.3