diff --git a/Cargo.lock b/Cargo.lock index e351d3c9e..e470a0b68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,7 +548,7 @@ dependencies = [ "indexmap", "js-sys", "once_cell", - "rand 0.9.1", + "rand", "serde", "serde_bytes", "serde_json", @@ -570,12 +570,12 @@ dependencies = [ "indexmap", "js-sys", "once_cell", - "rand 0.9.1", + "rand", "serde", "serde_bytes", "serde_json", "simdutf8", - "thiserror 2.0.12", + "thiserror", "time", "uuid", ] @@ -759,6 +759,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + [[package]] name = "cross-krb5" version = "0.4.2" @@ -772,6 +778,15 @@ dependencies = [ "windows", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.6" @@ -1261,9 +1276,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hickory-proto" -version = "0.24.4" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92652067c9ce6f66ce53cc38d1169daa36e6e7eb7dd3b63b5103bd9d97117248" +checksum = "f8a6fe56c0038198998a6f217ca4e7ef3a5e51f46163bd6dd60b5c71ca6c6502" dependencies = [ "async-trait", "cfg-if", @@ -1275,8 +1290,9 @@ dependencies = [ "idna", "ipnet", "once_cell", - "rand 0.8.5", - "thiserror 1.0.69", + "rand", + "ring", + "thiserror", "tinyvec", "tokio", "tracing", @@ -1285,21 +1301,21 @@ dependencies = [ [[package]] name = "hickory-resolver" -version = "0.24.4" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbb117a1ca520e111743ab2f6688eddee69db4e0ea242545a604dce8a66fd22e" +checksum = "dc62a9a99b0bfb44d2ab95a7208ac952d31060efc16241c87eaf36406fecf87a" dependencies = [ "cfg-if", "futures-util", "hickory-proto", "ipconfig", - "lru-cache", + "moka", "once_cell", "parking_lot", - "rand 0.8.5", + "rand", "resolv-conf", "smallvec 1.15.0", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", ] @@ -1765,12 +1781,6 @@ dependencies = [ "windows-link 0.2.1", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.11.0" @@ -1798,15 +1808,6 @@ version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "lru-slab" version = "0.1.2" @@ -1916,6 +1917,24 @@ dependencies = [ "windows-sys 0.61.0", ] +[[package]] +name = "moka" +version = "0.12.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8261cd88c312e0004c1d51baad2980c66528dfdb2bee62003e643a4d8f86b077" +dependencies = [ + "crossbeam-channel", + "crossbeam-epoch", + "crossbeam-utils", + "equivalent", + "parking_lot", + "portable-atomic", + "rustc_version", + "smallvec 1.15.0", + "tagptr", + "uuid", +] + [[package]] name = "mongocrypt" version = "0.3.1" @@ -1979,7 +1998,7 @@ dependencies = [ "percent-encoding", "pkcs8", "pretty_assertions", - "rand 0.9.1", + "rand", "rayon", "regex", "reqwest", @@ -2000,7 +2019,7 @@ dependencies = [ "stringprep", "strsim", "take_mut", - "thiserror 2.0.12", + "thiserror", "time", "tokio", "tokio-openssl", @@ -2105,6 +2124,10 @@ name = "once_cell" version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +dependencies = [ + "critical-section", + "portable-atomic", +] [[package]] name = "openssl" @@ -2160,7 +2183,7 @@ dependencies = [ "futures-sink", "js-sys", "pin-project-lite", - "thiserror 2.0.12", + "thiserror", "tracing", ] @@ -2175,8 +2198,8 @@ dependencies = [ "futures-util", "opentelemetry", "percent-encoding", - "rand 0.9.1", - "thiserror 2.0.12", + "rand", + "thiserror", "tokio", "tokio-stream", ] @@ -2312,6 +2335,12 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + [[package]] name = "potential_utf" version = "0.1.3" @@ -2388,7 +2417,7 @@ dependencies = [ "rustc-hash", "rustls", "socket2 0.6.0", - "thiserror 2.0.12", + "thiserror", "tokio", "tracing", "web-time", @@ -2403,13 +2432,13 @@ dependencies = [ "bytes", "getrandom 0.3.2", "lru-slab", - "rand 0.9.1", + "rand", "ring", "rustc-hash", "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.12", + "thiserror", "tinyvec", "tracing", "web-time", @@ -2426,7 +2455,7 @@ dependencies = [ "once_cell", "socket2 0.6.0", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -2450,37 +2479,16 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - [[package]] name = "rand" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ - "rand_chacha 0.9.0", + "rand_chacha", "rand_core 0.9.3", ] -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - [[package]] name = "rand_chacha" version = "0.9.0" @@ -2496,9 +2504,6 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.16", -] [[package]] name = "rand_core" @@ -3128,6 +3133,12 @@ dependencies = [ "libc", ] +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + [[package]] name = "take_mut" version = "0.2.2" @@ -3153,33 +3164,13 @@ dependencies = [ "windows-sys 0.61.0", ] -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] - [[package]] name = "thiserror" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.12", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", + "thiserror-impl", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 4d6e3a870..8df61a428 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,8 +98,8 @@ futures-io = "0.3.21" futures-core = "0.3.14" futures-util = { version = "0.3.14", features = ["io"] } hex = "0.4.0" -hickory-proto = { version = "0.24.2", optional = true } -hickory-resolver = { version = "0.24.2", optional = true } +hickory-proto = { version = "0.25", optional = true } +hickory-resolver = { version = "0.25", optional = true } hmac = "0.12.1" log = { version = "0.4.17", optional = true } md-5 = "0.10.1" diff --git a/src/client/options/resolver_config.rs b/src/client/options/resolver_config.rs index 3c7b20da6..e28567757 100644 --- a/src/client/options/resolver_config.rs +++ b/src/client/options/resolver_config.rs @@ -5,12 +5,41 @@ use hickory_resolver::config::ResolverConfig as HickoryResolverConfig; /// /// This is a thin wrapper around a `hickory_resolver::config::ResolverConfig` provided to ensure /// API stability. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "dns-resolver"), derive(PartialEq))] pub struct ResolverConfig { #[cfg(feature = "dns-resolver")] pub(crate) inner: HickoryResolverConfig, } +#[cfg(feature = "dns-resolver")] +impl PartialEq for ResolverConfig { + fn eq(&self, other: &Self) -> bool { + let (left, right) = (&self.inner, &other.inner); + + if !(left.domain() == right.domain() + && left.search() == right.search() + && left.name_servers().len() == right.name_servers().len()) + { + return false; + } + + for (a, b) in std::iter::zip(left.name_servers(), right.name_servers()) { + if !(a.socket_addr == b.socket_addr + && a.protocol == b.protocol + && a.tls_dns_name == b.tls_dns_name + && a.http_endpoint == b.http_endpoint + && a.trust_negative_responses == b.trust_negative_responses + && a.bind_addr == b.bind_addr) + { + return false; + } + } + + true + } +} + #[cfg(feature = "dns-resolver")] impl ResolverConfig { /// Creates a default configuration, using 1.1.1.1, 1.0.0.1 and 2606:4700:4700::1111, diff --git a/src/error.rs b/src/error.rs index 4fb3578ea..f5fbed585 100644 --- a/src/error.rs +++ b/src/error.rs @@ -317,7 +317,7 @@ impl Error { } #[cfg(feature = "dns-resolver")] - pub(crate) fn from_resolve_error(error: hickory_resolver::error::ResolveError) -> Self { + pub(crate) fn from_resolve_error(error: hickory_resolver::ResolveError) -> Self { ErrorKind::DnsResolve { message: error.to_string(), } @@ -325,7 +325,7 @@ impl Error { } #[cfg(feature = "dns-resolver")] - pub(crate) fn from_resolve_proto_error(error: hickory_proto::error::ProtoError) -> Self { + pub(crate) fn from_resolve_proto_error(error: hickory_proto::ProtoError) -> Self { ErrorKind::DnsResolve { message: error.to_string(), } diff --git a/src/runtime/resolver.rs b/src/runtime/resolver.rs index 94ba80123..2c1359bc1 100644 --- a/src/runtime/resolver.rs +++ b/src/runtime/resolver.rs @@ -1,7 +1,6 @@ use crate::error::{Error, Result}; use hickory_resolver::{ config::ResolverConfig, - error::ResolveErrorKind, lookup::{SrvLookup, TxtLookup}, Name, }; @@ -17,16 +16,19 @@ use std::net::IpAddr; /// An async runtime agnostic DNS resolver. pub(crate) struct AsyncResolver { - resolver: hickory_resolver::TokioAsyncResolver, + resolver: hickory_resolver::TokioResolver, } impl AsyncResolver { pub(crate) async fn new(config: Option) -> Result { let resolver = match config { - Some(config) => hickory_resolver::TokioAsyncResolver::tokio(config, Default::default()), - None => hickory_resolver::TokioAsyncResolver::tokio_from_system_conf() + Some(config) => { + hickory_resolver::TokioResolver::builder_with_config(config, Default::default()) + } + None => hickory_resolver::TokioResolver::builder_tokio() .map_err(Error::from_resolve_error)?, - }; + } + .build(); Ok(Self { resolver }) } @@ -80,10 +82,8 @@ impl AsyncResolver { let lookup_result = self.resolver.txt_lookup(name).await; match lookup_result { Ok(lookup) => Ok(Some(lookup)), - Err(e) => match e.kind() { - ResolveErrorKind::NoRecordsFound { .. } => Ok(None), - _ => Err(Error::from_resolve_error(e)), - }, + Err(e) if e.is_no_records_found() => Ok(None), + Err(e) => Err(Error::from_resolve_error(e)), } } } diff --git a/src/srv.rs b/src/srv.rs index f5bcd8db9..7d388e7aa 100644 --- a/src/srv.rs +++ b/src/srv.rs @@ -133,9 +133,8 @@ impl SrvResolver { let mut hosts = vec![]; let mut min_ttl = u32::MAX; for record in srv_lookup.as_lookup().record_iter() { - let srv = match record.data() { - Some(RData::SRV(s)) => s, - _ => continue, + let RData::SRV(srv) = record.data() else { + continue; }; let mut host = srv.target().to_utf8(); // Remove the trailing '.'