Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91372ad

Browse files
committed
also add the fallback logic to TokioDns
1 parent 285810f commit 91372ad

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/net/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,20 @@ impl<P: StoreParams> NetworkService<P> {
142142
};
143143
#[cfg(all(feature = "tokio", not(feature = "async_global")))]
144144
let transport = if let Some(config) = config.dns {
145-
Dns::custom(quic_or_tcp, config.config, config.opts)?.boxed()
145+
match config {
146+
DnsConfig::Custom { config, opts } => {
147+
Dns::custom(quic_or_tcp, config, opts)?.boxed()
148+
}
149+
DnsConfig::SystemWithFallback { config, opts } => {
150+
match trust_dns_resolver::system_conf::read_system_conf() {
151+
Ok((config, opts)) => Dns::custom(quic_or_tcp, config, opts)?.boxed(),
152+
Err(e) => {
153+
tracing::warn!("falling back to custom DNS config, system default yielded error `${:#}`", e);
154+
Dns::custom(quic_or_tcp, config, opts)?.boxed()
155+
}
156+
}
157+
}
158+
}
146159
} else {
147160
Dns::system(quic_or_tcp)?.boxed()
148161
};

0 commit comments

Comments
 (0)