Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update hickory dns crates #27137

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
294 changes: 181 additions & 113 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fs3 = "0.5.0"
futures = "0.3.21"
glob = "0.3.1"
h2 = "0.4.4"
hickory-resolver = { version = "0.24", features = ["tokio-runtime", "serde-config"] }
hickory-resolver = { version = "0.25.0-alpha.4", features = ["tokio-runtime", "serde"] }
http = "1.0"
http-body = "1.0"
http-body-util = "0.1.2"
Expand Down Expand Up @@ -191,7 +191,7 @@ spki = "0.7.2"
tar = "=0.4.40"
tempfile = "3.4.0"
termcolor = "1.1.3"
thiserror = "1.0.61"
thiserror = "2.0.3"
tokio = { version = "1.36.0", features = ["full"] }
tokio-metrics = { version = "0.3.0", features = ["rt"] }
tokio-rustls = { version = "0.26.0", default-features = false, features = ["ring", "tls12"] }
Expand Down
15 changes: 6 additions & 9 deletions ext/fetch/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use std::task::Poll;
use std::task::{self};
use std::vec;

use hickory_resolver::error::ResolveError;
use hickory_resolver::name_server::GenericConnector;
use hickory_resolver::name_server::TokioRuntimeProvider;
use hickory_resolver::AsyncResolver;
use hickory_resolver::name_server::TokioConnectionProvider;
use hyper_util::client::legacy::connect::dns::GaiResolver;
use hyper_util::client::legacy::connect::dns::Name;
use tokio::task::JoinHandle;
Expand All @@ -21,7 +18,7 @@ pub enum Resolver {
/// A resolver using blocking `getaddrinfo` calls in a threadpool.
Gai(GaiResolver),
/// hickory-resolver's userspace resolver.
Hickory(AsyncResolver<GenericConnector<TokioRuntimeProvider>>),
Hickory(hickory_resolver::Resolver<TokioConnectionProvider>),
}

impl Default for Resolver {
Expand All @@ -36,14 +33,14 @@ impl Resolver {
}

/// Create a [`AsyncResolver`] from system conf.
pub fn hickory() -> Result<Self, ResolveError> {
pub fn hickory() -> Result<Self, hickory_resolver::ResolveError> {
Ok(Self::Hickory(
hickory_resolver::AsyncResolver::tokio_from_system_conf()?,
hickory_resolver::Resolver::tokio_from_system_conf()?,
))
}

pub fn hickory_from_async_resolver(
resolver: AsyncResolver<GenericConnector<TokioRuntimeProvider>>,
pub fn hickory_from_resolver(
resolver: hickory_resolver::Resolver<TokioConnectionProvider>,
) -> Self {
Self::Hickory(resolver)
}
Expand Down
4 changes: 2 additions & 2 deletions ext/fetch/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn test_userspace_resolver() {
// use `localhost` to ensure dns step happens.
let addr = format!("localhost:{}", src_addr.port());

let hickory = hickory_resolver::AsyncResolver::tokio(
let hickory = hickory_resolver::Resolver::tokio(
Default::default(),
Default::default(),
);
Expand All @@ -52,7 +52,7 @@ fn test_userspace_resolver() {
addr.clone(),
"https",
http::Version::HTTP_2,
dns::Resolver::hickory_from_async_resolver(hickory),
dns::Resolver::hickory_from_resolver(hickory),
)
.await;
assert_eq!(thread_counter.load(SeqCst), 0, "userspace resolver shouldn't spawn new threads.");
Expand Down
2 changes: 1 addition & 1 deletion ext/net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path = "lib.rs"
deno_core.workspace = true
deno_permissions.workspace = true
deno_tls.workspace = true
hickory-proto = "0.24"
hickory-proto = "0.25.0-alpha.4"
hickory-resolver.workspace = true
pin-project.workspace = true
rustls-tokio-stream.workspace = true
Expand Down
25 changes: 18 additions & 7 deletions ext/net/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ use deno_core::ResourceId;
use hickory_proto::rr::rdata::caa::Value;
use hickory_proto::rr::record_data::RData;
use hickory_proto::rr::record_type::RecordType;
use hickory_proto::ProtoError;
use hickory_proto::ProtoErrorKind;
use hickory_resolver::config::NameServerConfigGroup;
use hickory_resolver::config::ResolverConfig;
use hickory_resolver::config::ResolverOpts;
use hickory_resolver::error::ResolveError;
use hickory_resolver::error::ResolveErrorKind;
use hickory_resolver::system_conf;
use hickory_resolver::AsyncResolver;
use hickory_resolver::ResolveError;
use hickory_resolver::ResolveErrorKind;
use serde::Deserialize;
use serde::Serialize;
use socket2::Domain;
Expand Down Expand Up @@ -646,7 +647,7 @@ where
}
}

let resolver = AsyncResolver::tokio(config, opts);
let resolver = hickory_resolver::Resolver::tokio(config, opts);

let lookup_fut = resolver.lookup(query, record_type);

Expand Down Expand Up @@ -674,11 +675,21 @@ where

lookup
.map_err(|e| match e.kind() {
ResolveErrorKind::NoRecordsFound { .. } => NetError::DnsNotFound(e),
ResolveErrorKind::Message("No connections available") => {
ResolveErrorKind::Proto(ProtoError { kind, .. })
if matches!(**kind, ProtoErrorKind::NoRecordsFound { .. }) =>
{
NetError::DnsNotFound(e)
}
ResolveErrorKind::Proto(ProtoError { kind, .. })
Copy link

@djc djc Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is the correct change -- in fact, the previous version of the match arm (for ResolveErrorKind::Message("No connections available"), originally from 25771b3) hasn't been effective for a while now (a NoConnections variant, first in ResolveErrorKind, now in ProtoErrorKind, has been around since trust-dns-resolver 0.21, from Feb 2022).

if matches!(**kind, ProtoErrorKind::NoConnections { .. }) =>
{
NetError::DnsNotConnected(e)
}
ResolveErrorKind::Timeout => NetError::DnsTimedOut(e),
ResolveErrorKind::Proto(ProtoError { kind, .. })
if matches!(**kind, ProtoErrorKind::Timeout { .. }) =>
{
NetError::DnsTimedOut(e)
}
_ => NetError::Dns(e),
})?
.iter()
Expand Down
5 changes: 3 additions & 2 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ deno_tls.workspace = true
fastwebsockets = { workspace = true, features = ["upgrade", "unstable-split"] }
file_test_runner = "0.7.3"
flaky_test = "=0.2.2"
hickory-client = "=0.24"
hickory-server = "=0.24"
hickory-client = "0.25.0-alpha.4"
hickory-proto = "0.25.0-alpha.4"
hickory-server = "0.25.0-alpha.4"
http.workspace = true
http-body-util.workspace = true
hyper.workspace = true
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use deno_tls::rustls;
use deno_tls::rustls::ClientConnection;
use deno_tls::rustls_pemfile;
use deno_tls::TlsStream;
use hickory_client::serialize::txt::Parser;
use hickory_proto::serialize::txt::Parser;
use hickory_server::authority::AuthorityObject;
use pretty_assertions::assert_eq;
use test_util as util;
use test_util::itest;
Expand Down Expand Up @@ -2245,10 +2246,10 @@ async fn test_resolve_dns() {
panic!("failed to parse: {:?}", records.err())
}
let (origin, records) = records.unwrap();
let authority = Box::new(Arc::new(
let authority: Vec<Arc<dyn AuthorityObject>> = vec![Arc::new(
InMemoryAuthority::new(origin, records, ZoneType::Primary, false)
.unwrap(),
));
)];
let mut catalog: Catalog = Catalog::new();
catalog.upsert(Name::root().into(), authority);

Expand Down