Skip to content

Upgrade to hickory-resolver 0.25 #2611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ tokio-util = { version = "0.7.9", default-features = false, features = ["codec",
tokio-socks = { version = "0.5.2", optional = true }

## hickory-dns
hickory-resolver = { version = "0.24", optional = true, features = ["tokio-runtime"] }
hickory-resolver = { version = "0.25", optional = true, features = ["tokio"] }

# HTTP/3 experimental support
h3 = { version = "0.0.7", optional = true }
Expand Down
14 changes: 8 additions & 6 deletions src/dns/hickory.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! DNS resolution via the [hickory-resolver](https://github.com/hickory-dns/hickory-dns) crate

use hickory_resolver::{
config::LookupIpStrategy, error::ResolveError, lookup_ip::LookupIpIntoIter, system_conf,
TokioAsyncResolver,
config::LookupIpStrategy, lookup_ip::LookupIpIntoIter, name_server::TokioConnectionProvider,
ResolveError, TokioResolver,
};
use once_cell::sync::OnceCell;

Expand All @@ -18,7 +18,7 @@ pub(crate) struct HickoryDnsResolver {
/// Since we might not have been called in the context of a
/// Tokio Runtime in initialization, so we must delay the actual
/// construction of the resolver.
state: Arc<OnceCell<TokioAsyncResolver>>,
state: Arc<OnceCell<TokioResolver>>,
}

struct SocketAddrs {
Expand Down Expand Up @@ -55,10 +55,12 @@ impl Iterator for SocketAddrs {
/// which reads from `/etc/resolve.conf`. The options are
/// overridden to look up for both IPv4 and IPv6 addresses
/// to work with "happy eyeballs" algorithm.
fn new_resolver() -> Result<TokioAsyncResolver, HickoryDnsSystemConfError> {
let (config, mut opts) = system_conf::read_system_conf().map_err(HickoryDnsSystemConfError)?;
fn new_resolver() -> Result<TokioResolver, HickoryDnsSystemConfError> {
let mut builder = TokioResolver::builder(TokioConnectionProvider::default())
.map_err(HickoryDnsSystemConfError)?;
let opts = builder.options_mut();
opts.ip_strategy = LookupIpStrategy::Ipv4AndIpv6;
Ok(TokioAsyncResolver::tokio(config, opts))
Ok(builder.build())
}

impl fmt::Display for HickoryDnsSystemConfError {
Expand Down
Loading