Skip to content

Commit faf237f

Browse files
committed
Update to hickory-resolver 0.25
1 parent c7ba346 commit faf237f

File tree

6 files changed

+104
-72
lines changed

6 files changed

+104
-72
lines changed

Cargo.lock

Lines changed: 66 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ futures-io = "0.3.21"
9898
futures-core = "0.3.14"
9999
futures-util = { version = "0.3.14", features = ["io"] }
100100
hex = "0.4.0"
101-
hickory-proto = { version = "0.24.2", optional = true }
102-
hickory-resolver = { version = "0.24.2", optional = true }
101+
hickory-proto = { version = "0.25", optional = true }
102+
hickory-resolver = { version = "0.25", optional = true }
103103
hmac = "0.12.1"
104104
log = { version = "0.4.17", optional = true }
105105
md-5 = "0.10.1"

src/client/options/resolver_config.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,33 @@ use hickory_resolver::config::ResolverConfig as HickoryResolverConfig;
55
///
66
/// This is a thin wrapper around a `hickory_resolver::config::ResolverConfig` provided to ensure
77
/// API stability.
8-
#[derive(Clone, Debug, PartialEq)]
8+
#[derive(Clone, Debug)]
99
pub struct ResolverConfig {
1010
#[cfg(feature = "dns-resolver")]
1111
pub(crate) inner: HickoryResolverConfig,
1212
}
1313

14+
impl PartialEq for ResolverConfig {
15+
fn eq(&self, other: &Self) -> bool {
16+
let (left, right) = (&self.inner, &other.inner);
17+
18+
if !(left.domain() == right.domain()
19+
&& left.search() == right.search()
20+
&& left.name_servers().len() == right.name_servers().len())
21+
{
22+
return false;
23+
}
24+
25+
for (a, b) in std::iter::zip(left.name_servers(), right.name_servers()) {
26+
if !(a.socket_addr == b.socket_addr && a.protocol == b.protocol) {
27+
return false;
28+
}
29+
}
30+
31+
true
32+
}
33+
}
34+
1435
#[cfg(feature = "dns-resolver")]
1536
impl ResolverConfig {
1637
/// Creates a default configuration, using 1.1.1.1, 1.0.0.1 and 2606:4700:4700::1111,

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,15 @@ impl Error {
317317
}
318318

319319
#[cfg(feature = "dns-resolver")]
320-
pub(crate) fn from_resolve_error(error: hickory_resolver::error::ResolveError) -> Self {
320+
pub(crate) fn from_resolve_error(error: hickory_resolver::ResolveError) -> Self {
321321
ErrorKind::DnsResolve {
322322
message: error.to_string(),
323323
}
324324
.into()
325325
}
326326

327327
#[cfg(feature = "dns-resolver")]
328-
pub(crate) fn from_resolve_proto_error(error: hickory_proto::error::ProtoError) -> Self {
328+
pub(crate) fn from_resolve_proto_error(error: hickory_proto::ProtoError) -> Self {
329329
ErrorKind::DnsResolve {
330330
message: error.to_string(),
331331
}

src/runtime/resolver.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::error::{Error, Result};
22
use hickory_resolver::{
33
config::ResolverConfig,
4-
error::ResolveErrorKind,
54
lookup::{SrvLookup, TxtLookup},
65
Name,
76
};
@@ -17,16 +16,20 @@ use std::net::IpAddr;
1716

1817
/// An async runtime agnostic DNS resolver.
1918
pub(crate) struct AsyncResolver {
20-
resolver: hickory_resolver::TokioAsyncResolver,
19+
resolver: hickory_resolver::TokioResolver,
2120
}
2221

2322
impl AsyncResolver {
2423
pub(crate) async fn new(config: Option<ResolverConfig>) -> Result<Self> {
2524
let resolver = match config {
26-
Some(config) => hickory_resolver::TokioAsyncResolver::tokio(config, Default::default()),
27-
None => hickory_resolver::TokioAsyncResolver::tokio_from_system_conf()
25+
Some(config) => hickory_resolver::TokioResolver::builder_with_config(
26+
config,
27+
hickory_resolver::name_server::TokioConnectionProvider::default(),
28+
),
29+
None => hickory_resolver::TokioResolver::builder_tokio()
2830
.map_err(Error::from_resolve_error)?,
29-
};
31+
}
32+
.build();
3033

3134
Ok(Self { resolver })
3235
}
@@ -80,10 +83,8 @@ impl AsyncResolver {
8083
let lookup_result = self.resolver.txt_lookup(name).await;
8184
match lookup_result {
8285
Ok(lookup) => Ok(Some(lookup)),
83-
Err(e) => match e.kind() {
84-
ResolveErrorKind::NoRecordsFound { .. } => Ok(None),
85-
_ => Err(Error::from_resolve_error(e)),
86-
},
86+
Err(e) if e.is_no_records_found() => Ok(None),
87+
Err(e) => Err(Error::from_resolve_error(e)),
8788
}
8889
}
8990
}

src/srv.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,8 @@ impl SrvResolver {
133133
let mut hosts = vec![];
134134
let mut min_ttl = u32::MAX;
135135
for record in srv_lookup.as_lookup().record_iter() {
136-
let srv = match record.data() {
137-
Some(RData::SRV(s)) => s,
138-
_ => continue,
136+
let RData::SRV(srv) = record.data() else {
137+
continue;
139138
};
140139
let mut host = srv.target().to_utf8();
141140
// Remove the trailing '.'

0 commit comments

Comments
 (0)