From 66084c01c8ecdb8430118754bf4307dd455794d9 Mon Sep 17 00:00:00 2001 From: Rain Date: Sun, 5 Nov 2023 14:07:40 -0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- Cargo.lock | 168 ++++++++++++++++--------- Cargo.toml | 8 +- clients/oxide-client/Cargo.toml | 2 +- clients/oxide-client/src/lib.rs | 22 ++-- dev-tools/omdb/src/bin/omdb/main.rs | 16 +-- dns-server/Cargo.toml | 11 +- dns-server/src/dns_server.rs | 24 ++-- dns-server/src/lib.rs | 20 ++- dns-server/src/storage.rs | 10 +- dns-server/tests/basic_test.rs | 17 ++- end-to-end-tests/Cargo.toml | 2 +- end-to-end-tests/src/helpers/ctx.rs | 2 +- internal-dns-cli/Cargo.toml | 2 +- internal-dns-cli/src/bin/dnswait.rs | 5 +- internal-dns/Cargo.toml | 6 +- internal-dns/src/resolver.rs | 60 ++++----- nexus/Cargo.toml | 3 +- nexus/src/app/external_dns.rs | 21 ++-- nexus/src/context.rs | 2 - nexus/test-utils/Cargo.toml | 4 +- nexus/test-utils/src/lib.rs | 30 ++--- nexus/tests/integration_tests/silos.rs | 3 +- oximeter/collector/src/lib.rs | 2 +- sled-agent/src/rack_setup/service.rs | 2 +- sled-agent/src/server.rs | 11 +- sled-agent/src/services.rs | 2 +- wicketd/Cargo.toml | 4 +- wicketd/src/http_entrypoints.rs | 8 +- wicketd/src/lib.rs | 18 +-- wicketd/src/preflight_check/uplink.rs | 35 ++---- workspace-hack/Cargo.toml | 4 +- 31 files changed, 257 insertions(+), 267 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7aa3aa153..59985ff4be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2021,6 +2021,10 @@ dependencies = [ "dns-service-client 0.1.0", "dropshot", "expectorate", + "hickory-client", + "hickory-proto", + "hickory-resolver", + "hickory-server", "http", "omicron-test-utils", "omicron-workspace-hack", @@ -2041,10 +2045,6 @@ dependencies = [ "thiserror", "tokio", "toml 0.8.6", - "trust-dns-client", - "trust-dns-proto", - "trust-dns-resolver", - "trust-dns-server", "uuid", ] @@ -2294,6 +2294,7 @@ dependencies = [ "camino", "chrono", "futures", + "hickory-resolver", "http", "omicron-sled-agent", "omicron-test-utils", @@ -2306,7 +2307,6 @@ dependencies = [ "serde_json", "tokio", "toml 0.8.6", - "trust-dns-resolver", "uuid", ] @@ -2328,6 +2328,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "enum-as-inner" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.32", +] + [[package]] name = "env_logger" version = "0.9.3" @@ -3064,6 +3076,90 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "hickory-client" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f3e08124cf0ddda93b1186d4af73599de401f3b52f14cd9aaa719049379462e" +dependencies = [ + "cfg-if 1.0.0", + "data-encoding", + "futures-channel", + "futures-util", + "hickory-proto", + "once_cell", + "radix_trie", + "rand 0.8.5", + "thiserror", + "tokio", + "tracing", +] + +[[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 1.0.0", + "data-encoding", + "enum-as-inner 0.6.0", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.4.0", + "ipnet", + "once_cell", + "rand 0.8.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 1.0.0", + "futures-util", + "hickory-proto", + "ipconfig", + "lru-cache", + "once_cell", + "parking_lot 0.12.1", + "rand 0.8.5", + "resolv-conf", + "smallvec 1.11.0", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "hickory-server" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fbbb45bc4dcb456445732c705e3cfdc7393b8bcae5c36ecec36b9d76bd67cb5" +dependencies = [ + "async-trait", + "bytes", + "cfg-if 1.0.0", + "enum-as-inner 0.6.0", + "futures-util", + "hickory-proto", + "serde", + "thiserror", + "time", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "highway" version = "1.1.0" @@ -3605,6 +3701,8 @@ dependencies = [ "dropshot", "expectorate", "futures", + "hickory-proto", + "hickory-resolver", "hyper", "omicron-common 0.1.0", "omicron-test-utils", @@ -3618,8 +3716,6 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "trust-dns-proto", - "trust-dns-resolver", "uuid", ] @@ -3649,12 +3745,12 @@ dependencies = [ "anyhow", "clap 4.4.3", "dropshot", + "hickory-resolver", "internal-dns 0.1.0", "omicron-common 0.1.0", "omicron-workspace-hack", "slog", "tokio", - "trust-dns-resolver", ] [[package]] @@ -4504,6 +4600,8 @@ dependencies = [ "gateway-messages", "gateway-test-utils", "headers", + "hickory-proto", + "hickory-resolver", "http", "hyper", "internal-dns 0.1.0", @@ -4525,8 +4623,6 @@ dependencies = [ "serde_urlencoded", "slog", "tempfile", - "trust-dns-proto", - "trust-dns-resolver", "uuid", ] @@ -5080,6 +5176,7 @@ dependencies = [ "gateway-test-utils", "headers", "hex", + "hickory-resolver", "http", "httptest", "hyper", @@ -5158,7 +5255,6 @@ dependencies = [ "tokio-postgres", "toml 0.8.6", "tough", - "trust-dns-resolver", "usdt", "uuid", ] @@ -5439,6 +5535,7 @@ dependencies = [ "hashbrown 0.13.2", "hashbrown 0.14.2", "hex", + "hickory-proto", "hyper", "hyper-rustls", "indexmap 2.1.0", @@ -5493,7 +5590,6 @@ dependencies = [ "toml_datetime", "toml_edit 0.19.15", "tracing", - "trust-dns-proto", "unicode-bidi", "unicode-normalization", "unicode-xid", @@ -5702,6 +5798,7 @@ dependencies = [ "base64 0.21.5", "chrono", "futures", + "hickory-resolver", "http", "hyper", "omicron-workspace-hack", @@ -5713,7 +5810,6 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "trust-dns-resolver", "uuid", ] @@ -9349,26 +9445,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "trust-dns-client" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c408c32e6a9dbb38037cece35740f2cf23c875d8ca134d33631cec83f74d3fe" -dependencies = [ - "cfg-if 1.0.0", - "data-encoding", - "futures-channel", - "futures-util", - "lazy_static", - "radix_trie", - "rand 0.8.5", - "thiserror", - "time", - "tokio", - "tracing", - "trust-dns-proto", -] - [[package]] name = "trust-dns-proto" version = "0.22.0" @@ -9378,7 +9454,7 @@ dependencies = [ "async-trait", "cfg-if 1.0.0", "data-encoding", - "enum-as-inner", + "enum-as-inner 0.5.1", "futures-channel", "futures-io", "futures-util", @@ -9414,28 +9490,6 @@ dependencies = [ "trust-dns-proto", ] -[[package]] -name = "trust-dns-server" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99022f9befa6daec2a860be68ac28b1f0d9d7ccf441d8c5a695e35a58d88840d" -dependencies = [ - "async-trait", - "bytes", - "cfg-if 1.0.0", - "enum-as-inner", - "futures-executor", - "futures-util", - "serde", - "thiserror", - "time", - "tokio", - "toml 0.5.11", - "tracing", - "trust-dns-client", - "trust-dns-proto", -] - [[package]] name = "try-lock" version = "0.2.4" @@ -10204,6 +10258,7 @@ dependencies = [ "gateway-messages", "gateway-test-utils", "hex", + "hickory-resolver", "http", "hubtools", "hyper", @@ -10240,7 +10295,6 @@ dependencies = [ "tokio-util", "toml 0.8.6", "tough", - "trust-dns-resolver", "tufaceous", "tufaceous-lib", "update-engine", diff --git a/Cargo.toml b/Cargo.toml index 8aaae347d5..11504840dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -203,6 +203,10 @@ headers = "0.3.9" heck = "0.4" hex = "0.4.3" hex-literal = "0.4.1" +hickory-client = "0.24.0" +hickory-proto = "0.24.0" +hickory-resolver = "0.24.0" +hickory-server = "0.24.0" highway = "1.1.0" hkdf = "0.12.3" http = "0.2.9" @@ -366,10 +370,6 @@ toml = "0.8.6" toml_edit = "0.20.7" topological-sort = "0.2.2" tough = { version = "0.12", features = [ "http" ] } -trust-dns-client = "0.22" -trust-dns-proto = "0.22" -trust-dns-resolver = "0.22" -trust-dns-server = "0.22" trybuild = "1.0.85" tufaceous = { path = "tufaceous" } tufaceous-lib = { path = "tufaceous-lib" } diff --git a/clients/oxide-client/Cargo.toml b/clients/oxide-client/Cargo.toml index 3cb411729d..854411bb6c 100644 --- a/clients/oxide-client/Cargo.toml +++ b/clients/oxide-client/Cargo.toml @@ -9,6 +9,7 @@ anyhow.workspace = true base64.workspace = true chrono.workspace = true futures.workspace = true +hickory-resolver.workspace = true http.workspace = true hyper.workspace = true progenitor.workspace = true @@ -19,6 +20,5 @@ serde.workspace = true serde_json.workspace = true thiserror.workspace = true tokio = { workspace = true, features = [ "net" ] } -trust-dns-resolver.workspace = true uuid.workspace = true omicron-workspace-hack.workspace = true diff --git a/clients/oxide-client/src/lib.rs b/clients/oxide-client/src/lib.rs index 07a190c38e..76f4746411 100644 --- a/clients/oxide-client/src/lib.rs +++ b/clients/oxide-client/src/lib.rs @@ -7,13 +7,13 @@ use anyhow::anyhow; use anyhow::Context; use futures::FutureExt; +use hickory_resolver::config::{ + NameServerConfig, Protocol, ResolverConfig, ResolverOpts, +}; +use hickory_resolver::TokioAsyncResolver; use std::net::SocketAddr; use std::sync::Arc; use thiserror::Error; -use trust_dns_resolver::config::{ - NameServerConfig, Protocol, ResolverConfig, ResolverOpts, -}; -use trust_dns_resolver::TokioAsyncResolver; progenitor::generate_api!( spec = "../../openapi/nexus.json", @@ -40,21 +40,21 @@ pub struct CustomDnsResolver { impl CustomDnsResolver { /// Make a new custom resolver that uses the DNS server at the specified /// address - pub fn new(dns_addr: SocketAddr) -> anyhow::Result { + pub fn new(dns_addr: SocketAddr) -> Self { let mut resolver_config = ResolverConfig::new(); resolver_config.add_name_server(NameServerConfig { socket_addr: dns_addr, protocol: Protocol::Udp, tls_dns_name: None, - trust_nx_responses: false, + trust_negative_responses: false, bind_addr: None, }); - let resolver = Arc::new( - TokioAsyncResolver::tokio(resolver_config, ResolverOpts::default()) - .context("failed to create resolver")?, - ); - Ok(CustomDnsResolver { dns_addr, resolver }) + let resolver = Arc::new(TokioAsyncResolver::tokio( + resolver_config, + ResolverOpts::default(), + )); + Self { dns_addr, resolver } } /// Returns the address of the DNS server that we're using to resolve names diff --git a/dev-tools/omdb/src/bin/omdb/main.rs b/dev-tools/omdb/src/bin/omdb/main.rs index 32141d2809..3fbb844076 100644 --- a/dev-tools/omdb/src/bin/omdb/main.rs +++ b/dev-tools/omdb/src/bin/omdb/main.rs @@ -94,7 +94,7 @@ impl Omdb { log: slog::Logger, service_name: internal_dns::ServiceName, ) -> Result, anyhow::Error> { - let resolver = self.dns_resolver(log).await?; + let resolver = self.dns_resolver(log).await; resolver .lookup_all_socket_v6(service_name) .await @@ -104,19 +104,13 @@ impl Omdb { async fn dns_resolver( &self, log: slog::Logger, - ) -> Result { + ) -> internal_dns::resolver::Resolver { match &self.dns_server { Some(dns_server) => { internal_dns::resolver::Resolver::new_from_addrs( log, &[*dns_server], ) - .with_context(|| { - format!( - "creating DNS resolver for DNS server {:?}", - dns_server - ) - }) } None => { // In principle, we should look at /etc/resolv.conf to find the @@ -141,12 +135,6 @@ impl Omdb { to specify an alternate DNS server)", ); internal_dns::resolver::Resolver::new_from_subnet(log, subnet) - .with_context(|| { - format!( - "creating DNS resolver for subnet {}", - subnet.net() - ) - }) } } } diff --git a/dns-server/Cargo.toml b/dns-server/Cargo.toml index f91cbfafdb..5871f28767 100644 --- a/dns-server/Cargo.toml +++ b/dns-server/Cargo.toml @@ -11,6 +11,10 @@ chrono.workspace = true clap.workspace = true dns-service-client.workspace = true dropshot.workspace = true +hickory-client.workspace = true +hickory-proto.workspace = true +hickory-resolver.workspace = true +hickory-server.workspace = true http.workspace = true pretty-hex.workspace = true schemars.workspace = true @@ -23,12 +27,8 @@ slog-async.workspace = true slog-envlogger.workspace = true tempfile.workspace = true thiserror.workspace = true -tokio = { workspace = true, features = [ "full" ] } +tokio = { workspace = true, features = ["full"] } toml.workspace = true -trust-dns-client.workspace = true -trust-dns-proto.workspace = true -trust-dns-resolver.workspace = true -trust-dns-server.workspace = true uuid.workspace = true omicron-workspace-hack.workspace = true @@ -40,4 +40,3 @@ openapi-lint.workspace = true serde_json.workspace = true subprocess.workspace = true tempdir.workspace = true -trust-dns-resolver.workspace = true diff --git a/dns-server/src/dns_server.rs b/dns-server/src/dns_server.rs index 01a8430b62..699c638edd 100644 --- a/dns-server/src/dns_server.rs +++ b/dns-server/src/dns_server.rs @@ -13,6 +13,15 @@ use crate::storage::QueryError; use crate::storage::Store; use anyhow::anyhow; use anyhow::Context; +use hickory_proto::op::header::Header; +use hickory_proto::op::response_code::ResponseCode; +use hickory_proto::rr::rdata::{A, AAAA, SRV}; +use hickory_proto::rr::record_data::RData; +use hickory_proto::rr::record_type::RecordType; +use hickory_proto::rr::{Name, Record}; +use hickory_proto::serialize::binary::{BinDecodable, BinDecoder, BinEncoder}; +use hickory_server::authority::MessageResponse; +use hickory_server::authority::{MessageRequest, MessageResponseBuilder}; use pretty_hex::*; use serde::Deserialize; use slog::{debug, error, info, o, trace, Logger}; @@ -21,17 +30,6 @@ use std::str::FromStr; use std::sync::Arc; use thiserror::Error; use tokio::net::UdpSocket; -use trust_dns_proto::op::header::Header; -use trust_dns_proto::op::response_code::ResponseCode; -use trust_dns_proto::rr::rdata::SRV; -use trust_dns_proto::rr::record_data::RData; -use trust_dns_proto::rr::record_type::RecordType; -use trust_dns_proto::rr::{Name, Record}; -use trust_dns_proto::serialize::binary::{ - BinDecodable, BinDecoder, BinEncoder, -}; -use trust_dns_server::authority::MessageResponse; -use trust_dns_server::authority::{MessageRequest, MessageResponseBuilder}; use uuid::Uuid; /// Configuration related to the DNS server @@ -222,7 +220,7 @@ fn dns_record_to_record( let mut a = Record::new(); a.set_name(name.clone()) .set_rr_type(RecordType::A) - .set_data(Some(RData::A(addr))); + .set_data(Some(RData::A(A(addr)))); Ok(a) } @@ -230,7 +228,7 @@ fn dns_record_to_record( let mut aaaa = Record::new(); aaaa.set_name(name.clone()) .set_rr_type(RecordType::AAAA) - .set_data(Some(RData::AAAA(addr))); + .set_data(Some(RData::AAAA(AAAA(addr)))); Ok(aaaa) } diff --git a/dns-server/src/lib.rs b/dns-server/src/lib.rs index ea8625a667..41d5a8632e 100644 --- a/dns-server/src/lib.rs +++ b/dns-server/src/lib.rs @@ -48,13 +48,13 @@ pub mod http_server; pub mod storage; use anyhow::{anyhow, Context}; +use hickory_resolver::config::NameServerConfig; +use hickory_resolver::config::Protocol; +use hickory_resolver::config::ResolverConfig; +use hickory_resolver::config::ResolverOpts; +use hickory_resolver::TokioAsyncResolver; use slog::o; use std::net::SocketAddr; -use trust_dns_resolver::config::NameServerConfig; -use trust_dns_resolver::config::Protocol; -use trust_dns_resolver::config::ResolverConfig; -use trust_dns_resolver::config::ResolverOpts; -use trust_dns_resolver::TokioAsyncResolver; /// Starts both the HTTP and DNS servers over a given store. pub async fn start_servers( @@ -161,18 +161,16 @@ impl TransientServer { Ok(()) } - pub async fn resolver(&self) -> Result { + pub async fn resolver(&self) -> TokioAsyncResolver { let mut resolver_config = ResolverConfig::new(); resolver_config.add_name_server(NameServerConfig { socket_addr: self.dns_server.local_address(), protocol: Protocol::Udp, tls_dns_name: None, - trust_nx_responses: false, + trust_negative_responses: false, bind_addr: None, }); - let resolver = - TokioAsyncResolver::tokio(resolver_config, ResolverOpts::default()) - .context("creating DNS resolver")?; - Ok(resolver) + + TokioAsyncResolver::tokio(resolver_config, ResolverOpts::default()) } } diff --git a/dns-server/src/storage.rs b/dns-server/src/storage.rs index 270cc500d1..c4f095c25b 100644 --- a/dns-server/src/storage.rs +++ b/dns-server/src/storage.rs @@ -95,6 +95,8 @@ use crate::dns_types::{DnsConfig, DnsConfigParams, DnsConfigZone, DnsRecord}; use anyhow::{anyhow, Context}; use camino::Utf8PathBuf; +use hickory_client::rr::Name; +use hickory_proto::rr::LowerName; use serde::{Deserialize, Serialize}; use sled::transaction::ConflictableTransactionError; use slog::{debug, error, info, o, warn}; @@ -104,8 +106,6 @@ use std::sync::atomic::Ordering; use std::sync::Arc; use thiserror::Error; use tokio::sync::Mutex; -use trust_dns_client::rr::LowerName; -use trust_dns_client::rr::Name; const KEY_CONFIG: &'static str = "config"; @@ -586,7 +586,7 @@ impl Store { /// If the returned set would have been empty, returns `QueryError::NoName`. pub(crate) fn query( &self, - mr: &trust_dns_server::authority::MessageRequest, + mr: &hickory_server::authority::MessageRequest, ) -> Result, QueryError> { let name = mr.query().name(); let orig_name = mr.query().original().name(); @@ -783,14 +783,14 @@ mod test { use crate::storage::QueryError; use anyhow::Context; use camino::Utf8PathBuf; + use hickory_client::rr::Name; + use hickory_proto::rr::LowerName; use omicron_test_utils::dev::test_setup_log; use std::collections::BTreeSet; use std::collections::HashMap; use std::net::Ipv6Addr; use std::str::FromStr; use std::sync::Arc; - use trust_dns_client::rr::LowerName; - use trust_dns_client::rr::Name; /// As usual, `TestContext` groups the various pieces we need in a bunch of /// our tests and helps make sure they get cleaned up properly. diff --git a/dns-server/tests/basic_test.rs b/dns-server/tests/basic_test.rs index 98cd1487ab..46a68af545 100644 --- a/dns-server/tests/basic_test.rs +++ b/dns-server/tests/basic_test.rs @@ -8,6 +8,12 @@ use dns_service_client::{ Client, }; use dropshot::{test_util::LogContext, HandlerTaskMode}; +use hickory_resolver::error::ResolveErrorKind; +use hickory_resolver::TokioAsyncResolver; +use hickory_resolver::{ + config::{NameServerConfig, Protocol, ResolverConfig, ResolverOpts}, + proto::op::ResponseCode, +}; use omicron_test_utils::dev::test_setup_log; use slog::o; use std::{ @@ -15,12 +21,6 @@ use std::{ net::Ipv6Addr, net::{IpAddr, Ipv4Addr}, }; -use trust_dns_resolver::error::ResolveErrorKind; -use trust_dns_resolver::TokioAsyncResolver; -use trust_dns_resolver::{ - config::{NameServerConfig, Protocol, ResolverConfig, ResolverOpts}, - proto::op::ResponseCode, -}; const TEST_ZONE: &'static str = "oxide.internal"; @@ -378,12 +378,11 @@ async fn init_client_server( socket_addr: dns_server.local_address(), protocol: Protocol::Udp, tls_dns_name: None, - trust_nx_responses: false, + trust_negative_responses: false, bind_addr: None, }); - let resolver = - TokioAsyncResolver::tokio(rc, ResolverOpts::default()).unwrap(); + let resolver = TokioAsyncResolver::tokio(rc, ResolverOpts::default()); let client = Client::new(&format!("http://{}", dropshot_server.local_addr()), log); diff --git a/end-to-end-tests/Cargo.toml b/end-to-end-tests/Cargo.toml index 732a4a2091..19cf3f10c3 100644 --- a/end-to-end-tests/Cargo.toml +++ b/end-to-end-tests/Cargo.toml @@ -11,6 +11,7 @@ base64.workspace = true camino.workspace = true chrono.workspace = true futures.workspace = true +hickory-resolver.workspace = true http.workspace = true omicron-sled-agent.workspace = true omicron-test-utils.workspace = true @@ -22,6 +23,5 @@ russh-keys = "0.38.0" serde_json.workspace = true tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } toml.workspace = true -trust-dns-resolver.workspace = true uuid.workspace = true omicron-workspace-hack.workspace = true diff --git a/end-to-end-tests/src/helpers/ctx.rs b/end-to-end-tests/src/helpers/ctx.rs index 1c95703807..0fc4510a35 100644 --- a/end-to-end-tests/src/helpers/ctx.rs +++ b/end-to-end-tests/src/helpers/ctx.rs @@ -1,6 +1,7 @@ use crate::helpers::generate_name; use anyhow::{anyhow, Context as _, Result}; use chrono::Utc; +use hickory_resolver::error::ResolveErrorKind; use omicron_sled_agent::rack_setup::config::SetupServiceConfig; use omicron_test_utils::dev::poll::{wait_for_condition, CondCheckError}; use oxide_client::types::{Name, ProjectCreate}; @@ -12,7 +13,6 @@ use std::net::IpAddr; use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; -use trust_dns_resolver::error::ResolveErrorKind; const RSS_CONFIG_STR: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), diff --git a/internal-dns-cli/Cargo.toml b/internal-dns-cli/Cargo.toml index dab92c6d7c..ce62992642 100644 --- a/internal-dns-cli/Cargo.toml +++ b/internal-dns-cli/Cargo.toml @@ -12,5 +12,5 @@ internal-dns.workspace = true omicron-common.workspace = true slog.workspace = true tokio.workspace = true -trust-dns-resolver.workspace = true +hickory-resolver.workspace = true omicron-workspace-hack.workspace = true diff --git a/internal-dns-cli/src/bin/dnswait.rs b/internal-dns-cli/src/bin/dnswait.rs index 9e003ed14f..7aad46cc4a 100644 --- a/internal-dns-cli/src/bin/dnswait.rs +++ b/internal-dns-cli/src/bin/dnswait.rs @@ -66,14 +66,13 @@ async fn main() -> Result<()> { let resolver = if opt.nameserver_addresses.is_empty() { info!(&log, "using system configuration"); let async_resolver = - trust_dns_resolver::AsyncResolver::tokio_from_system_conf() - .context("initializing resolver from system configuration")?; + hickory_resolver::AsyncResolver::tokio_from_system_conf() + .context("initializing resolver from system configuration")?; Resolver::new_with_resolver(log.clone(), async_resolver) } else { let addrs = opt.nameserver_addresses; info!(&log, "using explicit nameservers"; "nameservers" => ?addrs); Resolver::new_from_addrs(log.clone(), &addrs) - .context("creating resolver with explicit nameserver addresses")? }; let result = omicron_common::backoff::retry_notify( diff --git a/internal-dns/Cargo.toml b/internal-dns/Cargo.toml index ecb2d48bda..25d022a271 100644 --- a/internal-dns/Cargo.toml +++ b/internal-dns/Cargo.toml @@ -9,13 +9,13 @@ anyhow.workspace = true chrono.workspace = true dns-service-client.workspace = true futures.workspace = true +hickory-proto.workspace = true +hickory-resolver.workspace = true hyper.workspace = true omicron-common.workspace = true reqwest = { workspace = true, features = ["rustls-tls", "stream"] } slog.workspace = true thiserror.workspace = true -trust-dns-proto.workspace = true -trust-dns-resolver.workspace = true uuid.workspace = true omicron-workspace-hack.workspace = true @@ -30,4 +30,4 @@ serde = { workspace = true, features = ["derive"] } serde_json.workspace = true sled.workspace = true tempfile.workspace = true -tokio = { workspace = true, features = [ "full" ] } +tokio = { workspace = true, features = ["full"] } diff --git a/internal-dns/src/resolver.rs b/internal-dns/src/resolver.rs index 114333cb61..d946d5f323 100644 --- a/internal-dns/src/resolver.rs +++ b/internal-dns/src/resolver.rs @@ -2,24 +2,24 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. +use hickory_resolver::config::{ + LookupIpStrategy, NameServerConfig, Protocol, ResolverConfig, ResolverOpts, +}; +use hickory_resolver::lookup::SrvLookup; +use hickory_resolver::TokioAsyncResolver; use hyper::client::connect::dns::Name; use omicron_common::address::{ Ipv6Subnet, ReservedRackSubnet, AZ_PREFIX, DNS_PORT, }; use slog::{debug, error, info, trace}; use std::net::{IpAddr, Ipv6Addr, SocketAddr, SocketAddrV6}; -use trust_dns_resolver::config::{ - LookupIpStrategy, NameServerConfig, Protocol, ResolverConfig, ResolverOpts, -}; -use trust_dns_resolver::lookup::SrvLookup; -use trust_dns_resolver::TokioAsyncResolver; pub type DnsError = dns_service_client::Error; #[derive(Debug, Clone, thiserror::Error)] pub enum ResolveError { #[error(transparent)] - Resolve(#[from] trust_dns_resolver::error::ResolveError), + Resolve(#[from] hickory_resolver::error::ResolveError), #[error("Record not found for SRV key: {}", .0.dns_name())] NotFound(crate::ServiceName), @@ -53,10 +53,7 @@ impl reqwest::dns::Resolve for Resolver { impl Resolver { /// Construct a new DNS resolver from specific DNS server addresses. - pub fn new_from_addrs( - log: slog::Logger, - dns_addrs: &[SocketAddr], - ) -> Result { + pub fn new_from_addrs(log: slog::Logger, dns_addrs: &[SocketAddr]) -> Self { info!(log, "new DNS resolver"; "addresses" => ?dns_addrs); let mut rc = ResolverConfig::new(); @@ -66,7 +63,7 @@ impl Resolver { socket_addr, protocol: Protocol::Udp, tls_dns_name: None, - trust_nx_responses: false, + trust_negative_responses: false, bind_addr: None, }); } @@ -77,18 +74,15 @@ impl Resolver { // the IPv4 variant. opts.ip_strategy = LookupIpStrategy::Ipv6Only; opts.negative_max_ttl = Some(std::time::Duration::from_secs(15)); - let resolver = TokioAsyncResolver::tokio(rc, opts)?; + let resolver = TokioAsyncResolver::tokio(rc, opts); - Ok(Self { log, resolver }) + Self { log, resolver } } /// Convenience wrapper for [`Resolver::new_from_subnet`] that determines /// the subnet based on a provided IP address and then uses the DNS /// resolvers for that subnet. - pub fn new_from_ip( - log: slog::Logger, - address: Ipv6Addr, - ) -> Result { + pub fn new_from_ip(log: slog::Logger, address: Ipv6Addr) -> Self { let subnet = Ipv6Subnet::::new(address); Self::new_from_subnet(log, subnet) } @@ -135,7 +129,7 @@ impl Resolver { pub fn new_from_subnet( log: slog::Logger, subnet: Ipv6Subnet, - ) -> Result { + ) -> Self { let dns_ips = Self::servers_from_subnet(subnet); Resolver::new_from_addrs(log, &dns_ips) } @@ -163,7 +157,7 @@ impl Resolver { .iter() .next() .ok_or_else(|| ResolveError::NotFound(srv))?; - Ok(*address) + Ok(address.0) } /// Returns the targets of the SRV records for a DNS name @@ -313,7 +307,7 @@ impl Resolver { // (1) it returns `IpAddr`'s rather than `SocketAddr`'s // (2) it doesn't actually return all the addresses from the Additional // section of the DNS server's response. - // See bluejekyll/trust-dns#1980 + // See hickory-dns/hickory-dns#1980 // // (1) is not a huge deal as we can try to match up the targets ourselves // to grab the port for creating a `SocketAddr` but (2) means we need to do @@ -352,7 +346,7 @@ impl Resolver { .flat_map(move |target| match target { Ok((ips, port)) => Some( ips.into_iter() - .map(move |ip| SocketAddrV6::new(ip, port, 0, 0)), + .map(move |ip| SocketAddrV6::new(ip.0, port, 0, 0)), ), Err((target, err)) => { error!( @@ -463,10 +457,9 @@ mod test { drop(self) } - fn resolver(&self) -> anyhow::Result { + fn resolver(&self) -> Resolver { let log = self.log.new(o!("component" => "DnsResolver")); Resolver::new_from_addrs(log, &[self.dns_server_address()]) - .context("creating resolver for test DNS server") } async fn update( @@ -496,7 +489,7 @@ mod test { async fn lookup_nonexistent_record_fails() { let logctx = test_setup_log("lookup_nonexistent_record_fails"); let dns_server = DnsServer::create(&logctx.log).await; - let resolver = dns_server.resolver().unwrap(); + let resolver = dns_server.resolver(); let err = resolver .lookup_ip(ServiceName::Cockroach) @@ -510,7 +503,7 @@ mod test { assert!( matches!( dns_error.kind(), - trust_dns_resolver::error::ResolveErrorKind::NoRecordsFound { .. }, + hickory_resolver::error::ResolveErrorKind::NoRecordsFound { .. }, ), "Saw error: {dns_error}", ); @@ -533,7 +526,7 @@ mod test { let dns_config = dns_config.build(); dns_server.update(&dns_config).await.unwrap(); - let resolver = dns_server.resolver().unwrap(); + let resolver = dns_server.resolver(); let found_ip = resolver .lookup_ipv6(ServiceName::Cockroach) .await @@ -612,7 +605,7 @@ mod test { dns_server.update(&dns_config).await.unwrap(); // Look up Cockroach - let resolver = dns_server.resolver().unwrap(); + let resolver = dns_server.resolver(); let ip = resolver .lookup_ipv6(ServiceName::Cockroach) .await @@ -660,7 +653,7 @@ mod test { error, ResolveError::Resolve(error) if matches!(error.kind(), - trust_dns_resolver::error::ResolveErrorKind::NoRecordsFound { .. } + hickory_resolver::error::ResolveErrorKind::NoRecordsFound { .. } ) ); @@ -679,7 +672,7 @@ mod test { async fn update_record() { let logctx = test_setup_log("update_record"); let dns_server = DnsServer::create(&logctx.log).await; - let resolver = dns_server.resolver().unwrap(); + let resolver = dns_server.resolver(); // Insert a record, observe that it exists. let mut dns_builder = DnsConfigBuilder::new(); @@ -791,8 +784,7 @@ mod test { let resolver = Resolver::new_from_addrs( logctx.log.clone(), &[dns_server.dns_server.local_address()], - ) - .unwrap(); + ); // Start a test server, but don't register it with the DNS server (yet). let label = 1234; @@ -871,8 +863,7 @@ mod test { dns_server1.dns_server.local_address(), dns_server2.dns_server.local_address(), ], - ) - .unwrap(); + ); // Start a test server, but don't register it with the DNS server (yet). let label = 1234; @@ -944,8 +935,7 @@ mod test { let resolver = Resolver::new_from_addrs( logctx.log.clone(), &[dns_server.dns_server.local_address()], - ) - .unwrap(); + ); // Create DNS config with a single service and multiple backends. let mut dns_config = DnsConfigBuilder::new(); diff --git a/nexus/Cargo.toml b/nexus/Cargo.toml index feb25eb1f1..731f75e497 100644 --- a/nexus/Cargo.toml +++ b/nexus/Cargo.toml @@ -29,6 +29,7 @@ futures.workspace = true gateway-client.workspace = true headers.workspace = true hex.workspace = true +hickory-resolver.workspace = true http.workspace = true hyper.workspace = true internal-dns.workspace = true @@ -77,7 +78,6 @@ tokio = { workspace = true, features = ["full"] } tokio-postgres = { workspace = true, features = ["with-serde_json-1"] } toml.workspace = true tough.workspace = true -trust-dns-resolver.workspace = true uuid.workspace = true usdt.workspace = true @@ -120,7 +120,6 @@ similar-asserts.workspace = true rustls = { workspace = true } subprocess.workspace = true term.workspace = true -trust-dns-resolver.workspace = true httptest.workspace = true strum.workspace = true diff --git a/nexus/src/app/external_dns.rs b/nexus/src/app/external_dns.rs index c6a8d833c2..4a0cbb34fd 100644 --- a/nexus/src/app/external_dns.rs +++ b/nexus/src/app/external_dns.rs @@ -5,15 +5,15 @@ use std::net::IpAddr; use std::net::SocketAddr; +use hickory_resolver::config::NameServerConfig; +use hickory_resolver::config::Protocol; +use hickory_resolver::config::ResolverConfig; +use hickory_resolver::config::ResolverOpts; +use hickory_resolver::TokioAsyncResolver; use hyper::client::connect::dns::Name; use omicron_common::address::DNS_PORT; -use trust_dns_resolver::config::NameServerConfig; -use trust_dns_resolver::config::Protocol; -use trust_dns_resolver::config::ResolverConfig; -use trust_dns_resolver::config::ResolverOpts; -use trust_dns_resolver::TokioAsyncResolver; -/// Wrapper around trust-dns-resolver to provide name resolution +/// Wrapper around hickory-resolver to provide name resolution /// using a given set of DNS servers for use with reqwest. pub struct Resolver(TokioAsyncResolver); @@ -26,7 +26,7 @@ impl Resolver { socket_addr: SocketAddr::new(*addr, DNS_PORT), protocol: Protocol::Udp, tls_dns_name: None, - trust_nx_responses: false, + trust_negative_responses: false, bind_addr: None, }); } @@ -34,10 +34,7 @@ impl Resolver { opts.use_hosts_file = false; // Do as many requests in parallel as we have configured servers opts.num_concurrent_reqs = dns_servers.len(); - Resolver( - TokioAsyncResolver::tokio(rc, opts) - .expect("creating resovler shouldn't fail"), - ) + Resolver(TokioAsyncResolver::tokio(rc, opts)) } } @@ -48,7 +45,7 @@ impl reqwest::dns::Resolve for Resolver { let ips = resolver.lookup_ip(name.as_str()).await?; let addrs = ips .into_iter() - // trust-dns-resolver returns `IpAddr`s but reqwest wants + // hickory-resolver returns `IpAddr`s but reqwest wants // `SocketAddr`s (useful if you have a custom resolver that // returns a scoped IPv6 address). The port provided here // is ignored in favour of the scheme default (http/80, diff --git a/nexus/src/context.rs b/nexus/src/context.rs index 7fd0a33c30..d8e9de7ef9 100644 --- a/nexus/src/context.rs +++ b/nexus/src/context.rs @@ -148,7 +148,6 @@ impl ServerContext { log.new(o!("component" => "DnsResolver")), az_subnet, ) - .map_err(|e| format!("Failed to create DNS resolver: {}", e))? } nexus_config::InternalDns::FromAddress { address } => { info!( @@ -160,7 +159,6 @@ impl ServerContext { log.new(o!("component" => "DnsResolver")), &[address], ) - .map_err(|e| format!("Failed to create DNS resolver: {}", e))? } }; diff --git a/nexus/test-utils/Cargo.toml b/nexus/test-utils/Cargo.toml index 56cee27b37..aa569f6ec4 100644 --- a/nexus/test-utils/Cargo.toml +++ b/nexus/test-utils/Cargo.toml @@ -37,8 +37,8 @@ serde_json.workspace = true serde_urlencoded.workspace = true slog.workspace = true tempfile.workspace = true -trust-dns-proto.workspace = true -trust-dns-resolver.workspace = true +hickory-proto.workspace = true +hickory-resolver.workspace = true uuid.workspace = true omicron-workspace-hack.workspace = true diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index 647232031d..51052e1b2c 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -15,6 +15,11 @@ use dropshot::ConfigLogging; use dropshot::ConfigLoggingLevel; use dropshot::HandlerTaskMode; use gateway_test_utils::setup::GatewayTestContext; +use hickory_resolver::config::NameServerConfig; +use hickory_resolver::config::Protocol; +use hickory_resolver::config::ResolverConfig; +use hickory_resolver::config::ResolverOpts; +use hickory_resolver::TokioAsyncResolver; use nexus_test_interface::NexusServer; use nexus_types::external_api::params::UserId; use nexus_types::internal_api::params::Certificate; @@ -43,11 +48,6 @@ use std::collections::HashMap; use std::fmt::Debug; use std::net::{IpAddr, Ipv6Addr, SocketAddr, SocketAddrV6}; use std::time::Duration; -use trust_dns_resolver::config::NameServerConfig; -use trust_dns_resolver::config::Protocol; -use trust_dns_resolver::config::ResolverConfig; -use trust_dns_resolver::config::ResolverOpts; -use trust_dns_resolver::TokioAsyncResolver; use uuid::Uuid; pub mod db; @@ -1156,14 +1156,11 @@ pub fn assert_same_items(v1: Vec, v2: Vec) { pub async fn start_dns_server( log: slog::Logger, storage_path: &Utf8Path, -) -> Result< - ( - dns_server::dns_server::ServerHandle, - dropshot::HttpServer, - TokioAsyncResolver, - ), - anyhow::Error, -> { +) -> ( + dns_server::dns_server::ServerHandle, + dropshot::HttpServer, + TokioAsyncResolver, +) { let config_store = dns_server::storage::Config { keep_old_generations: 3, storage_path: storage_path.into(), @@ -1194,12 +1191,11 @@ pub async fn start_dns_server( socket_addr: dns_server.local_address(), protocol: Protocol::Udp, tls_dns_name: None, - trust_nx_responses: false, + trust_negative_responses: false, bind_addr: None, }); let resolver = - TokioAsyncResolver::tokio(resolver_config, ResolverOpts::default()) - .context("creating DNS resolver")?; + TokioAsyncResolver::tokio(resolver_config, ResolverOpts::default()); - Ok((dns_server, http_server, resolver)) + (dns_server, http_server, resolver) } diff --git a/nexus/tests/integration_tests/silos.rs b/nexus/tests/integration_tests/silos.rs index e5f41d294d..276a1af48e 100644 --- a/nexus/tests/integration_tests/silos.rs +++ b/nexus/tests/integration_tests/silos.rs @@ -34,6 +34,7 @@ use std::fmt::Write; use std::str::FromStr; use base64::Engine; +use hickory_resolver::error::ResolveErrorKind; use http::method::Method; use http::StatusCode; use httptest::{matchers::*, responders::*, Expectation, Server}; @@ -41,7 +42,6 @@ use nexus_types::external_api::shared::{FleetRole, SiloRole}; use std::convert::Infallible; use std::net::Ipv4Addr; use std::time::Duration; -use trust_dns_resolver::error::ResolveErrorKind; use uuid::Uuid; type ControlPlaneTestContext = @@ -2151,7 +2151,6 @@ pub async fn verify_silo_dns_name( .external_dns .resolver() .await - .expect("Failed to create external DNS resolver") .ipv4_lookup(&dns_name) .await { diff --git a/oximeter/collector/src/lib.rs b/oximeter/collector/src/lib.rs index b7a14cec45..0c7fb89475 100644 --- a/oximeter/collector/src/lib.rs +++ b/oximeter/collector/src/lib.rs @@ -731,7 +731,7 @@ impl Oximeter { let resolver = Resolver::new_from_ip( log.new(o!("component" => "DnsResolver")), *args.address.ip(), - )?; + ); let make_agent = || async { debug!(log, "creating ClickHouse client"); diff --git a/sled-agent/src/rack_setup/service.rs b/sled-agent/src/rack_setup/service.rs index 7f6469d2c0..eb106364c5 100644 --- a/sled-agent/src/rack_setup/service.rs +++ b/sled-agent/src/rack_setup/service.rs @@ -775,7 +775,7 @@ impl ServiceInner { let resolver = DnsResolver::new_from_subnet( self.log.new(o!("component" => "DnsResolver")), config.az_subnet(), - )?; + ); let marker_paths: Vec = storage_resources .all_m2_mountpoints(sled_hardware::disk::CONFIG_DATASET) diff --git a/sled-agent/src/server.rs b/sled-agent/src/server.rs index 156547627c..dafcbbfb2a 100644 --- a/sled-agent/src/server.rs +++ b/sled-agent/src/server.rs @@ -46,13 +46,10 @@ impl Server { info!(log, "setting up sled agent server"); let sled_address = request.sled_address(); - let resolver = Arc::new( - Resolver::new_from_ip( - log.new(o!("component" => "DnsResolver")), - *sled_address.ip(), - ) - .map_err(|e| e.to_string())?, - ); + let resolver = Arc::new(Resolver::new_from_ip( + log.new(o!("component" => "DnsResolver")), + *sled_address.ip(), + )); let nexus_client = NexusClientWithResolver::new(&log, resolver) .map_err(|e| e.to_string())?; diff --git a/sled-agent/src/services.rs b/sled-agent/src/services.rs index d1d8dbfff0..e3a66fcdca 100644 --- a/sled-agent/src/services.rs +++ b/sled-agent/src/services.rs @@ -631,7 +631,7 @@ impl ServiceManager { resolver: Resolver::new_from_ip( self.inner.log.new(o!("component" => "DnsResolver")), underlay_address, - )?, + ), underlay_address, rack_id, rack_network_config, diff --git a/wicketd/Cargo.toml b/wicketd/Cargo.toml index 655f3bb803..46bfadd59f 100644 --- a/wicketd/Cargo.toml +++ b/wicketd/Cargo.toml @@ -21,6 +21,7 @@ flume.workspace = true futures.workspace = true gateway-messages.workspace = true hex.workspace = true +hickory-resolver.workspace = true hubtools.workspace = true http.workspace = true hyper.workspace = true @@ -36,11 +37,10 @@ serde_json.workspace = true slog.workspace = true slog-dtrace.workspace = true thiserror.workspace = true -tokio = { workspace = true, features = [ "full" ] } +tokio = { workspace = true, features = ["full"] } tokio-stream.workspace = true tokio-util.workspace = true tough.workspace = true -trust-dns-resolver.workspace = true snafu.workspace = true toml.workspace = true uuid.workspace = true diff --git a/wicketd/src/http_entrypoints.rs b/wicketd/src/http_entrypoints.rs index be0f681601..00346d9c03 100644 --- a/wicketd/src/http_entrypoints.rs +++ b/wicketd/src/http_entrypoints.rs @@ -1274,13 +1274,7 @@ async fn post_reload_config( let resolver = Resolver::new_from_subnet( rqctx.log.new(o!("component" => "InternalDnsResolver")), rack_subnet, - ) - .map_err(|err| { - HttpError::for_unavail( - None, - format!("failed to create internal DNS resolver: {err}"), - ) - })?; + ); *rqctx.internal_dns_resolver.lock().unwrap() = Some(resolver); } diff --git a/wicketd/src/lib.rs b/wicketd/src/lib.rs index ada1902654..4261d54a87 100644 --- a/wicketd/src/lib.rs +++ b/wicketd/src/lib.rs @@ -165,18 +165,12 @@ impl Server { )); let bootstrap_peers = BootstrapPeers::new(&log); - let internal_dns_resolver = args - .rack_subnet - .map(|addr| { - Resolver::new_from_subnet( - log.new(o!("component" => "InternalDnsResolver")), - addr, - ) - .map_err(|err| { - format!("Could not create internal DNS resolver: {err}") - }) - }) - .transpose()?; + let internal_dns_resolver = args.rack_subnet.map(|addr| { + Resolver::new_from_subnet( + log.new(o!("component" => "InternalDnsResolver")), + addr, + ) + }); let internal_dns_resolver = Arc::new(Mutex::new(internal_dns_resolver)); let nexus_tcp_proxy = NexusTcpProxy::start( diff --git a/wicketd/src/preflight_check/uplink.rs b/wicketd/src/preflight_check/uplink.rs index d94baf1995..67f1ba59c3 100644 --- a/wicketd/src/preflight_check/uplink.rs +++ b/wicketd/src/preflight_check/uplink.rs @@ -15,6 +15,11 @@ use dpd_client::types::RouteSettingsV4; use dpd_client::Client as DpdClient; use dpd_client::ClientState as DpdClientState; use either::Either; +use hickory_resolver::config::NameServerConfigGroup; +use hickory_resolver::config::ResolverConfig; +use hickory_resolver::config::ResolverOpts; +use hickory_resolver::error::ResolveErrorKind; +use hickory_resolver::TokioAsyncResolver; use illumos_utils::zone::SVCCFG; use illumos_utils::PFEXEC; use ipnetwork::IpNetwork; @@ -42,12 +47,6 @@ use std::time::Instant; use thiserror::Error; use tokio::process::Command; use tokio::sync::mpsc; -use trust_dns_resolver::config::NameServerConfigGroup; -use trust_dns_resolver::config::ResolverConfig; -use trust_dns_resolver::config::ResolverOpts; -use trust_dns_resolver::error::ResolveError; -use trust_dns_resolver::error::ResolveErrorKind; -use trust_dns_resolver::TokioAsyncResolver; use update_engine::StepSpec; const DNS_PORT: u16 = 53; @@ -1002,16 +1001,7 @@ impl DnsLookupStep { }; 'dns_servers: for &dns_ip in dns_servers { - let resolver = match self.build_resolver(dns_ip) { - Ok(resolver) => resolver, - Err(err) => { - self.warnings.push(format!( - "failed to create resolver for {dns_ip}: {}", - DisplayErrorChain::new(&err) - )); - continue; - } - }; + let resolver = self.build_resolver(dns_ip); // Attempt to resolve any NTP servers that aren't IP addresses. for &ntp_name in &ntp_names_to_resolve { @@ -1124,14 +1114,18 @@ impl DnsLookupStep { ( "A", resolver.ipv4_lookup(name).await.map(|records| { - Either::Left(records.into_iter().map(IpAddr::V4)) + Either::Left( + records.into_iter().map(|a| IpAddr::V4(a.0)), + ) }), ) } else { ( "AAAA", resolver.ipv6_lookup(name).await.map(|records| { - Either::Right(records.into_iter().map(IpAddr::V6)) + Either::Right( + records.into_iter().map(|aaaa| IpAddr::V6(aaaa.0)), + ) }), ) }; @@ -1247,10 +1241,7 @@ impl DnsLookupStep { /// /// If building it fails, we'll append to our internal `warnings` and return /// `None`. - fn build_resolver( - &mut self, - dns_ip: IpAddr, - ) -> Result { + fn build_resolver(&mut self, dns_ip: IpAddr) -> TokioAsyncResolver { let mut options = ResolverOpts::default(); // We will retry ourselves; we don't want the resolver diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index 49077eac77..81b3a71f90 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -49,6 +49,7 @@ getrandom = { version = "0.2.10", default-features = false, features = ["js", "r hashbrown-582f2526e08bb6a0 = { package = "hashbrown", version = "0.14.2", features = ["raw"] } hashbrown-594e8ee84c453af0 = { package = "hashbrown", version = "0.13.2" } hex = { version = "0.4.3", features = ["serde"] } +hickory-proto = { version = "0.24.0", features = ["text-parsing"] } hyper = { version = "0.14.27", features = ["full"] } indexmap = { version = "2.1.0", features = ["serde"] } inout = { version = "0.1.3", default-features = false, features = ["std"] } @@ -95,7 +96,6 @@ tokio-postgres = { version = "0.7.10", features = ["with-chrono-0_4", "with-serd tokio-stream = { version = "0.1.14", features = ["net"] } toml = { version = "0.7.8" } tracing = { version = "0.1.37", features = ["log"] } -trust-dns-proto = { version = "0.22.0" } unicode-bidi = { version = "0.3.13" } unicode-normalization = { version = "0.1.22" } usdt = { version = "0.3.5" } @@ -141,6 +141,7 @@ getrandom = { version = "0.2.10", default-features = false, features = ["js", "r hashbrown-582f2526e08bb6a0 = { package = "hashbrown", version = "0.14.2", features = ["raw"] } hashbrown-594e8ee84c453af0 = { package = "hashbrown", version = "0.13.2" } hex = { version = "0.4.3", features = ["serde"] } +hickory-proto = { version = "0.24.0", features = ["text-parsing"] } hyper = { version = "0.14.27", features = ["full"] } indexmap = { version = "2.1.0", features = ["serde"] } inout = { version = "0.1.3", default-features = false, features = ["std"] } @@ -189,7 +190,6 @@ tokio-postgres = { version = "0.7.10", features = ["with-chrono-0_4", "with-serd tokio-stream = { version = "0.1.14", features = ["net"] } toml = { version = "0.7.8" } tracing = { version = "0.1.37", features = ["log"] } -trust-dns-proto = { version = "0.22.0" } unicode-bidi = { version = "0.3.13" } unicode-normalization = { version = "0.1.22" } unicode-xid = { version = "0.2.4" }