diff --git a/Cargo.lock b/Cargo.lock index 9c0ab7866d..b063b16c08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -430,6 +430,17 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "async-stream" version = "0.3.6" @@ -489,6 +500,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "atty" version = "0.2.14" @@ -1601,6 +1618,12 @@ dependencies = [ "itertools 0.10.5", ] +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + [[package]] name = "crossbeam-channel" version = "0.5.15" @@ -2964,6 +2987,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "h2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75249d144030531f8dee69fe9cea04d3edf809a017ae445e2abdff6629e86633" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.3.1", + "indexmap 2.7.1", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "2.4.1" @@ -3130,57 +3172,59 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "hickory-proto" -version = "0.24.4" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92652067c9ce6f66ce53cc38d1169daa36e6e7eb7dd3b63b5103bd9d97117248" +checksum = "6d844af74f7b799e41c78221be863bade11c430d46042c3b49ca8ae0c6d27287" dependencies = [ + "async-recursion", "async-trait", "bytes", "cfg-if", + "critical-section", "data-encoding", "enum-as-inner", "futures-channel", "futures-io", "futures-util", - "h2", - "http 0.2.12", + "h2 0.4.9", + "http 1.3.1", "idna", "ipnet", "once_cell", - "rand 0.8.5", - "rustls 0.21.12", - "rustls-pemfile 1.0.4", - "thiserror 1.0.69", + "rand 0.9.0", + "ring", + "rustls 0.23.25", + "thiserror 2.0.12", "tinyvec", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls 0.26.2", "tracing", "url", - "webpki-roots 0.25.4", + "webpki-roots 0.26.8", ] [[package]] name = "hickory-resolver" -version = "0.24.4" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbb117a1ca520e111743ab2f6688eddee69db4e0ea242545a604dce8a66fd22e" +checksum = "a128410b38d6f931fcc6ca5c107a3b02cabd6c05967841269a4ad65d23c44331" dependencies = [ "cfg-if", "futures-util", "hickory-proto", "ipconfig", - "lru-cache", + "moka", "once_cell", "parking_lot", - "rand 0.8.5", + "rand 0.9.0", "resolv-conf", - "rustls 0.21.12", + "rustls 0.23.25", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.12", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls 0.26.2", "tracing", - "webpki-roots 0.25.4", + "webpki-roots 0.26.8", ] [[package]] @@ -3372,7 +3416,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -4098,12 +4142,6 @@ dependencies = [ "vcpkg", ] -[[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.4.15" @@ -4169,15 +4207,6 @@ dependencies = [ "tracing-subscriber", ] -[[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 = "mac" version = "0.1.1" @@ -7184,6 +7213,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 = "oorandom" @@ -8164,7 +8197,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.32", @@ -8522,6 +8555,7 @@ version = "0.23.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c" dependencies = [ + "log", "once_cell", "ring", "rustls-pki-types", @@ -10278,7 +10312,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.32", diff --git a/Cargo.toml b/Cargo.toml index c037e50388..775e2710c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -251,7 +251,7 @@ handlebars = "3.5.5" headers = "0.4.0" hex = "0.4.3" hex-literal = "0.3.3" -hickory-resolver = "0.24.4" +hickory-resolver = "0.25" hkdf = "0.12.3" hmac = "0.12.1" http = "1" diff --git a/common/http-api-client/Cargo.toml b/common/http-api-client/Cargo.toml index 79a291e827..eea45af346 100644 --- a/common/http-api-client/Cargo.toml +++ b/common/http-api-client/Cargo.toml @@ -30,7 +30,7 @@ mime = { workspace = true } nym-bin-common = { path = "../bin-common" } [target."cfg(not(target_arch = \"wasm32\"))".dependencies] -hickory-resolver = { workspace = true, features = ["dns-over-https-rustls", "webpki-roots"] } +hickory-resolver = { workspace = true, features = ["https-ring", "tls-ring", "webpki-roots"] } # for request timeout until https://github.com/seanmonstar/reqwest/issues/1135 is fixed [target."cfg(target_arch = \"wasm32\")".dependencies.wasmtimer] diff --git a/common/http-api-client/src/dns.rs b/common/http-api-client/src/dns.rs index d0af6dee3f..eb93f71407 100644 --- a/common/http-api-client/src/dns.rs +++ b/common/http-api-client/src/dns.rs @@ -35,10 +35,10 @@ use std::{ }; use hickory_resolver::{ - config::{LookupIpStrategy, NameServerConfigGroup, ResolverConfig, ResolverOpts}, - error::{ResolveError, ResolveErrorKind}, + config::{LookupIpStrategy, NameServerConfigGroup, ResolverConfig, ServerOrderingStrategy}, lookup_ip::{LookupIp, LookupIpIntoIter}, - TokioAsyncResolver, + name_server::TokioConnectionProvider, + ResolveError, TokioResolver, }; use once_cell::sync::OnceCell; use reqwest::dns::{Addrs, Name, Resolve, Resolving}; @@ -92,8 +92,8 @@ pub 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>, - fallback: Arc>, + state: Arc>, + fallback: Arc>, dont_use_shared: bool, } @@ -118,11 +118,8 @@ impl Resolve for HickoryDnsResolver { Ok(res) => res, Err(e) => { // on failure use the fall back system configured DNS resolver - match e.kind() { - ResolveErrorKind::NoRecordsFound { .. } => {} - _ => { - warn!("primary DNS failed w/ error {e}: using system fallback"); - } + if !e.is_no_records_found() { + warn!("primary DNS failed w/ error {e}: using system fallback"); } let resolver = fallback.get_or_try_init(|| { // using a closure here is slightly gross, but this makes sure that if the @@ -166,11 +163,8 @@ impl HickoryDnsResolver { Ok(res) => res, Err(e) => { // on failure use the fall back system configured DNS resolver - match e.kind() { - ResolveErrorKind::NoRecordsFound { .. } => {} - _ => { - warn!("primary DNS failed w/ error {e}: using system fallback"); - } + if !e.is_no_records_found() { + warn!("primary DNS failed w/ error {e}: using system fallback"); } let resolver = self .fallback @@ -190,7 +184,7 @@ impl HickoryDnsResolver { } } - fn new_resolver(&self) -> Result { + fn new_resolver(&self) -> Result { if self.dont_use_shared { new_resolver() } else { @@ -198,7 +192,7 @@ impl HickoryDnsResolver { } } - fn new_resolver_system(&self) -> Result { + fn new_resolver_system(&self) -> Result { if self.dont_use_shared { new_resolver_system() } else { @@ -212,29 +206,30 @@ impl HickoryDnsResolver { /// Create a new resolver with a custom DoT based configuration. The options are overridden to look /// up for both IPv4 and IPv6 addresses to work with "happy eyeballs" algorithm. -fn new_resolver() -> Result { +fn new_resolver() -> Result { let mut name_servers = NameServerConfigGroup::quad9_tls(); name_servers.merge(NameServerConfigGroup::quad9_https()); name_servers.merge(NameServerConfigGroup::cloudflare_tls()); name_servers.merge(NameServerConfigGroup::cloudflare_https()); let config = ResolverConfig::from_parts(None, Vec::new(), name_servers); + let mut resolver_builder = + TokioResolver::builder_with_config(config, TokioConnectionProvider::default()); - let mut opts = ResolverOpts::default(); - opts.ip_strategy = LookupIpStrategy::Ipv4AndIpv6; - // Would like to enable this when 0.25 stabilizes - // opts.server_ordering_strategy = ServerOrderingStrategy::RoundRobin; + resolver_builder.options_mut().ip_strategy = LookupIpStrategy::Ipv4AndIpv6; + resolver_builder.options_mut().server_ordering_strategy = ServerOrderingStrategy::RoundRobin; - Ok(TokioAsyncResolver::tokio(config, opts)) + Ok(resolver_builder.build()) } /// Create a new resolver with the default configuration, which reads from the system DNS config /// (i.e. `/etc/resolve.conf` in unix). The options are overridden to look up for both IPv4 and IPv6 /// addresses to work with "happy eyeballs" algorithm. -fn new_resolver_system() -> Result { - let (config, mut opts) = hickory_resolver::system_conf::read_system_conf()?; - opts.ip_strategy = LookupIpStrategy::Ipv4AndIpv6; - Ok(TokioAsyncResolver::tokio(config, opts)) +fn new_resolver_system() -> Result { + let mut resolver_builder = TokioResolver::builder_tokio()?; + resolver_builder.options_mut().ip_strategy = LookupIpStrategy::Ipv4AndIpv6; + + Ok(resolver_builder.build()) } #[cfg(test)]