Skip to content

Commit 528478b

Browse files
committed
feat(awc): replace trust dns by hickory dns
1 parent 002c1b5 commit 528478b

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

awc/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Update `brotli` dependency to `7`.
66
- Prevent panics on connection pool drop when Tokio runtime is shutdown early.
77
- Minimum supported Rust version (MSRV) is now 1.75.
8+
- Replace `trust-dns-resolver` with `hickory-resolver` for DNS resolution in awc when using `trust-dns` feature.
89

910
## 3.5.1
1011

awc/Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ compress-zstd = ["actix-http/compress-zstd", "__compress"]
8383
# Cookie parsing and cookie jar
8484
cookies = ["dep:cookie"]
8585

86-
# Use `trust-dns-resolver` crate as DNS resolver
87-
trust-dns = ["trust-dns-resolver"]
86+
# Use `trust-dns-resolver` crate as DNS resolver, deprecated in favor of `hickory-dns` which is a drop-in replacement
87+
trust-dns = ["hickory-dns"]
88+
# Use `hickory-dns-resolver` crate as DNS resolver
89+
hickory-dns = ["hickory-resolver"]
8890

8991
# Internal (PRIVATE!) features used to aid testing and checking feature status.
9092
# Don't rely on these whatsoever. They may disappear at anytime.
@@ -130,7 +132,7 @@ tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true, featu
130132
tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true }
131133
tls-rustls-0_23 = { package = "rustls", version = "0.23", optional = true, default-features = false }
132134

133-
trust-dns-resolver = { version = "0.23", optional = true }
135+
hickory-resolver = { version = "0.24.2", optional = true }
134136

135137
[dev-dependencies]
136138
actix-http = { version = "3.7", features = ["openssl"] }

awc/src/client/connector.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ where
10321032
}
10331033
}
10341034

1035-
#[cfg(not(feature = "trust-dns"))]
1035+
#[cfg(not(feature = "hickory-dns"))]
10361036
mod resolver {
10371037
use super::*;
10381038

@@ -1041,12 +1041,12 @@ mod resolver {
10411041
}
10421042
}
10431043

1044-
#[cfg(feature = "trust-dns")]
1044+
#[cfg(feature = "hickory-dns")]
10451045
mod resolver {
10461046
use std::{cell::RefCell, net::SocketAddr};
10471047

10481048
use actix_tls::connect::Resolve;
1049-
use trust_dns_resolver::{
1049+
use hickory_resolver::{
10501050
config::{ResolverConfig, ResolverOpts},
10511051
system_conf::read_system_conf,
10521052
TokioAsyncResolver,
@@ -1056,9 +1056,9 @@ mod resolver {
10561056

10571057
pub(super) fn resolver() -> Resolver {
10581058
// new type for impl Resolve trait for TokioAsyncResolver.
1059-
struct TrustDnsResolver(TokioAsyncResolver);
1059+
struct HickoryDnsResolver(TokioAsyncResolver);
10601060

1061-
impl Resolve for TrustDnsResolver {
1061+
impl Resolve for HickoryDnsResolver {
10621062
fn lookup<'a>(
10631063
&'a self,
10641064
host: &'a str,
@@ -1080,11 +1080,11 @@ mod resolver {
10801080

10811081
// resolver struct is cached in thread local so new clients can reuse the existing instance
10821082
thread_local! {
1083-
static TRUST_DNS_RESOLVER: RefCell<Option<Resolver>> = const { RefCell::new(None) };
1083+
static HICKORY_DNS_RESOLVER: RefCell<Option<Resolver>> = const { RefCell::new(None) };
10841084
}
10851085

1086-
// get from thread local or construct a new trust-dns resolver.
1087-
TRUST_DNS_RESOLVER.with(|local| {
1086+
// get from thread local or construct a new hickory dns resolver.
1087+
HICKORY_DNS_RESOLVER.with(|local| {
10881088
let resolver = local.borrow().as_ref().map(Clone::clone);
10891089

10901090
match resolver {
@@ -1094,15 +1094,15 @@ mod resolver {
10941094
let (cfg, opts) = match read_system_conf() {
10951095
Ok((cfg, opts)) => (cfg, opts),
10961096
Err(err) => {
1097-
log::error!("Trust-DNS can not load system config: {err}");
1097+
log::error!("Hickory-DNS can not load system config: {err}");
10981098
(ResolverConfig::default(), ResolverOpts::default())
10991099
}
11001100
};
11011101

11021102
let resolver = TokioAsyncResolver::tokio(cfg, opts);
11031103

1104-
// box trust dns resolver and put it in thread local.
1105-
let resolver = Resolver::custom(TrustDnsResolver(resolver));
1104+
// box hickory dns resolver and put it in thread local.
1105+
let resolver = Resolver::custom(HickoryDnsResolver(resolver));
11061106
*local.borrow_mut() = Some(resolver.clone());
11071107

11081108
resolver

0 commit comments

Comments
 (0)