diff --git a/Cargo.lock b/Cargo.lock index 98d0a971eff..c7118a5f776 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -402,17 +402,17 @@ dependencies = [ [[package]] name = "async-std-resolver" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0354a68a52265a3bde76005ddd2726624ef8624614f7f58871301de205a58a59" +checksum = "3c0ed2b6671c13d2c28756c5a64e04759c1e0b5d3d7ac031f521c3561e21fbcb" dependencies = [ "async-std", "async-trait", "futures-io", "futures-util", + "hickory-resolver", "pin-utils", "socket2 0.5.5", - "trust-dns-resolver", ] [[package]] @@ -1900,6 +1900,52 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" +[[package]] +name = "hickory-proto" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "091a6fbccf4860009355e3efc52ff4acf37a63489aad7435372d44ceeb6fbbcf" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna", + "ipnet", + "once_cell", + "rand 0.8.5", + "socket2 0.5.5", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "hickory-resolver" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35b8f021164e6a984c9030023544c57789c51760065cd510572fedcfb04164e8" +dependencies = [ + "cfg-if", + "futures-util", + "hickory-proto", + "ipconfig", + "lru-cache", + "once_cell", + "parking_lot", + "rand 0.8.5", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "hkdf" version = "0.12.3" @@ -2048,7 +2094,7 @@ dependencies = [ "rustls 0.20.8", "rustls-native-certs", "tokio", - "tokio-rustls 0.23.4", + "tokio-rustls", ] [[package]] @@ -2555,6 +2601,7 @@ dependencies = [ "async-std-resolver", "async-trait", "futures", + "hickory-resolver", "libp2p-core", "libp2p-identity", "parking_lot", @@ -2562,7 +2609,6 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", - "trust-dns-resolver", ] [[package]] @@ -2719,6 +2765,7 @@ dependencies = [ "async-std", "data-encoding", "futures", + "hickory-proto", "if-watch", "libp2p-core", "libp2p-identity", @@ -2733,7 +2780,6 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", - "trust-dns-proto", "void", ] @@ -5728,16 +5774,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.8", - "tokio", -] - [[package]] name = "tokio-stream" version = "0.1.14" @@ -5927,64 +5963,6 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "trust-dns-proto" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc775440033cb114085f6f2437682b194fa7546466024b1037e82a48a052a69" -dependencies = [ - "async-trait", - "bytes", - "cfg-if", - "data-encoding", - "enum-as-inner", - "futures-channel", - "futures-io", - "futures-util", - "h2", - "http", - "idna", - "ipnet", - "once_cell", - "rand 0.8.5", - "rustls 0.21.8", - "rustls-pemfile", - "rustls-webpki", - "smallvec", - "socket2 0.5.5", - "thiserror", - "tinyvec", - "tokio", - "tokio-rustls 0.24.1", - "tracing", - "url", - "webpki-roots", -] - -[[package]] -name = "trust-dns-resolver" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff7aed33ef3e8bf2c9966fccdfed93f93d46f432282ea875cd66faabc6ef2f" -dependencies = [ - "cfg-if", - "futures-util", - "ipconfig", - "lru-cache", - "once_cell", - "parking_lot", - "rand 0.8.5", - "resolv-conf", - "rustls 0.21.8", - "smallvec", - "thiserror", - "tokio", - "tokio-rustls 0.24.1", - "tracing", - "trust-dns-proto", - "webpki-roots", -] - [[package]] name = "try-lock" version = "0.2.4" diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index ef67a7e51b1..90ee633a9c4 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -24,7 +24,7 @@ smallvec = "1.11.1" socket2 = { version = "0.5.5", features = ["all"] } tokio = { version = "1.33", default-features = false, features = ["net", "time"], optional = true} tracing = "0.1.37" -trust-dns-proto = { version = "0.23.0", default-features = false, features = ["mdns"] } +hickory-proto = { version = "0.24.0", default-features = false, features = ["mdns"] } void = "1.0.2" [features] diff --git a/protocols/mdns/src/behaviour/iface/dns.rs b/protocols/mdns/src/behaviour/iface/dns.rs index 61fd5d329b9..6cc5550dbe5 100644 --- a/protocols/mdns/src/behaviour/iface/dns.rs +++ b/protocols/mdns/src/behaviour/iface/dns.rs @@ -395,9 +395,9 @@ impl error::Error for MdnsResponseError {} #[cfg(test)] mod tests { use super::*; + use hickory_proto::op::Message; use libp2p_identity as identity; use std::time::Duration; - use trust_dns_proto::op::Message; #[test] fn build_query_correct() { diff --git a/protocols/mdns/src/behaviour/iface/query.rs b/protocols/mdns/src/behaviour/iface/query.rs index 0185028f6ff..421ea10284c 100644 --- a/protocols/mdns/src/behaviour/iface/query.rs +++ b/protocols/mdns/src/behaviour/iface/query.rs @@ -20,6 +20,10 @@ use super::dns; use crate::{META_QUERY_SERVICE_FQDN, SERVICE_NAME_FQDN}; +use hickory_proto::{ + op::Message, + rr::{Name, RData}, +}; use libp2p_core::{ address_translation, multiaddr::{Multiaddr, Protocol}, @@ -27,10 +31,6 @@ use libp2p_core::{ use libp2p_identity::PeerId; use std::time::Instant; use std::{fmt, net::SocketAddr, str, time::Duration}; -use trust_dns_proto::{ - op::Message, - rr::{Name, RData}, -}; /// A valid mDNS packet received by the service. #[derive(Debug)] @@ -47,7 +47,7 @@ impl MdnsPacket { pub(crate) fn new_from_bytes( buf: &[u8], from: SocketAddr, - ) -> Result, trust_dns_proto::error::ProtoError> { + ) -> Result, hickory_proto::error::ProtoError> { let packet = Message::from_vec(buf)?; if packet.query().is_none() { diff --git a/transports/dns/CHANGELOG.md b/transports/dns/CHANGELOG.md index 9d9b4c09d92..734e7f08740 100644 --- a/transports/dns/CHANGELOG.md +++ b/transports/dns/CHANGELOG.md @@ -4,6 +4,10 @@ See [PR 4464](https://github.com/libp2p/rust-libp2p/pull/4464). - Remove deprecated type-aliases. See [PR 4739](https://github.com/libp2p/rust-libp2p/pull/4739). +- Migrate to the `hickory-dns` project which has rebranded from `trust-dns`. + We also remove the `tokio-dns-over-rustls` and `tokio-dns-over-https-rustls` features. + Users should activate these features themselves on `hickory-resolver` if so desired. + See [PR 4780](https://github.com/libp2p/rust-libp2p/pull/4780). ## 0.40.1 diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index df769161c55..e318e99476a 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -11,15 +11,15 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -async-std-resolver = { version = "0.23", optional = true } +async-std-resolver = { version = "0.24", optional = true } async-trait = "0.1.74" futures = "0.3.28" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } parking_lot = "0.12.0" +hickory-resolver = { version = "0.24.0", default-features = false, features = ["system-config"] } smallvec = "1.11.1" tracing = "0.1.37" -trust-dns-resolver = { version = "0.23", default-features = false, features = ["system-config"] } [dev-dependencies] libp2p-identity = { workspace = true, features = ["rand"] } @@ -29,12 +29,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } [features] async-std = ["async-std-resolver"] -tokio = ["trust-dns-resolver/tokio-runtime"] -# The `tokio-` prefix and feature dependency is just to be explicit, -# since these features of `trust-dns-resolver` are currently only -# available for `tokio`. -tokio-dns-over-rustls = ["tokio", "trust-dns-resolver/dns-over-rustls"] -tokio-dns-over-https-rustls = ["tokio", "trust-dns-resolver/dns-over-https-rustls"] +tokio = ["hickory-resolver/tokio-runtime"] # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/dns/src/lib.rs b/transports/dns/src/lib.rs index 13ad93952c9..483d50be15b 100644 --- a/transports/dns/src/lib.rs +++ b/transports/dns/src/lib.rs @@ -60,12 +60,12 @@ #[cfg(feature = "async-std")] pub mod async_std { use async_std_resolver::AsyncStdResolver; - use parking_lot::Mutex; - use std::{io, sync::Arc}; - use trust_dns_resolver::{ + use hickory_resolver::{ config::{ResolverConfig, ResolverOpts}, system_conf, }; + use parking_lot::Mutex; + use std::{io, sync::Arc}; /// A `Transport` wrapper for performing DNS lookups when dialing `Multiaddr`esses /// using `async-std` for all async I/O. @@ -90,9 +90,9 @@ pub mod async_std { #[cfg(feature = "tokio")] pub mod tokio { + use hickory_resolver::{system_conf, TokioAsyncResolver}; use parking_lot::Mutex; use std::sync::Arc; - use trust_dns_resolver::{system_conf, TokioAsyncResolver}; /// A `Transport` wrapper for performing DNS lookups when dialing `Multiaddr`esses /// using `tokio` for all async I/O. @@ -109,8 +109,8 @@ pub mod tokio { /// and options. pub fn custom( inner: T, - cfg: trust_dns_resolver::config::ResolverConfig, - opts: trust_dns_resolver::config::ResolverOpts, + cfg: hickory_resolver::config::ResolverConfig, + opts: hickory_resolver::config::ResolverOpts, ) -> Transport { Transport { inner: Arc::new(Mutex::new(inner)), @@ -141,12 +141,12 @@ use std::{ task::{Context, Poll}, }; -pub use trust_dns_resolver::config::{ResolverConfig, ResolverOpts}; -pub use trust_dns_resolver::error::{ResolveError, ResolveErrorKind}; -use trust_dns_resolver::lookup::{Ipv4Lookup, Ipv6Lookup, TxtLookup}; -use trust_dns_resolver::lookup_ip::LookupIp; -use trust_dns_resolver::name_server::ConnectionProvider; -use trust_dns_resolver::AsyncResolver; +pub use hickory_resolver::config::{ResolverConfig, ResolverOpts}; +pub use hickory_resolver::error::{ResolveError, ResolveErrorKind}; +use hickory_resolver::lookup::{Ipv4Lookup, Ipv6Lookup, TxtLookup}; +use hickory_resolver::lookup_ip::LookupIp; +use hickory_resolver::name_server::ConnectionProvider; +use hickory_resolver::AsyncResolver; /// The prefix for `dnsaddr` protocol TXT record lookups. const DNSADDR_PREFIX: &str = "_dnsaddr.";