From 6c86569215b58efcab1fbeaa6b99423d54a2a818 Mon Sep 17 00:00:00 2001 From: asonix Date: Mon, 23 Oct 2023 17:00:48 -0500 Subject: [PATCH] Update to hickory dns --- Cargo.toml | 4 ++-- src/lib.rs | 33 ++++++++++++++++----------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9f84367..8f2711a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ futures-io = "0.3.21" jive = { git = "https://git.asonix.dog/safe-async/jive", features = [ "futures-io-compat", ] } -trust-dns-proto = { version = "0.23.0", default-features = false } -trust-dns-resolver = { version = "0.23.0", default-features = false, features = [ +hickory-proto = { version = "0.24.0", default-features = false } +hickory-resolver = { version = "0.24.0", default-features = false, features = [ "system-config", ] } diff --git a/src/lib.rs b/src/lib.rs index 36b4da1..189436c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,22 +1,21 @@ use futures_io::{AsyncRead, AsyncWrite}; +use hickory_resolver::config::{ResolverConfig, ResolverOpts}; use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; -use trust_dns_resolver::config::{ResolverConfig, ResolverOpts}; pub fn resolver(config: ResolverConfig, options: ResolverOpts) -> JiveResolver { JiveResolver::new( config, options, - trust_dns_resolver::name_server::GenericConnector::new(JiveRuntime), + hickory_resolver::name_server::GenericConnector::new(JiveRuntime), ) } -pub fn resolver_from_system_conf() -> Result -{ - JiveResolver::from_system_conf(trust_dns_resolver::name_server::GenericConnector::new( +pub fn resolver_from_system_conf() -> Result { + JiveResolver::from_system_conf(hickory_resolver::name_server::GenericConnector::new( JiveRuntime, )) } @@ -32,10 +31,10 @@ pub struct JiveUdpSocket { io: jive::io::Async, } -pub type JiveResolver = trust_dns_resolver::AsyncResolver; +pub type JiveResolver = hickory_resolver::AsyncResolver; -pub type JiveConnection = trust_dns_resolver::name_server::GenericConnection; -pub type JiveConnectionProvider = trust_dns_resolver::name_server::GenericConnector; +pub type JiveConnection = hickory_resolver::name_server::GenericConnection; +pub type JiveConnectionProvider = hickory_resolver::name_server::GenericConnector; #[derive(Clone, Copy)] pub struct JiveRuntimeHandle; @@ -52,7 +51,7 @@ impl JiveTcpStream { } } -impl trust_dns_resolver::name_server::RuntimeProvider for JiveRuntime { +impl hickory_resolver::name_server::RuntimeProvider for JiveRuntime { type Handle = JiveRuntimeHandle; type Tcp = JiveTcpStream; type Timer = JiveTimer; @@ -86,17 +85,17 @@ impl trust_dns_resolver::name_server::RuntimeProvider for JiveRuntime { } } -impl trust_dns_resolver::name_server::Spawn for JiveRuntimeHandle { +impl hickory_resolver::name_server::Spawn for JiveRuntimeHandle { fn spawn_bg(&mut self, future: F) where - F: Future> + Send + 'static, + F: Future> + Send + 'static, { let _join = jive::spawn(future); } } #[async_trait::async_trait] -impl trust_dns_proto::tcp::Connect for JiveTcpStream { +impl hickory_proto::tcp::Connect for JiveTcpStream { async fn connect_with_bind( addr: std::net::SocketAddr, bind_addr: Option, @@ -111,7 +110,7 @@ impl trust_dns_proto::tcp::Connect for JiveTcpStream { } } -impl trust_dns_proto::tcp::DnsTcpStream for JiveTcpStream { +impl hickory_proto::tcp::DnsTcpStream for JiveTcpStream { type Time = JiveTimer; } @@ -144,7 +143,7 @@ impl AsyncWrite for JiveTcpStream { } #[async_trait::async_trait] -impl trust_dns_proto::udp::DnsUdpSocket for JiveUdpSocket { +impl hickory_proto::udp::DnsUdpSocket for JiveUdpSocket { type Time = JiveTimer; fn poll_send_to( @@ -166,7 +165,7 @@ impl trust_dns_proto::udp::DnsUdpSocket for JiveUdpSocket { } #[async_trait::async_trait] -impl trust_dns_proto::udp::UdpSocket for JiveUdpSocket { +impl hickory_proto::udp::UdpSocket for JiveUdpSocket { async fn connect(addr: std::net::SocketAddr) -> std::io::Result { let bind_addr: std::net::SocketAddr = match addr { std::net::SocketAddr::V4(_) => (std::net::Ipv4Addr::UNSPECIFIED, 0).into(), @@ -191,7 +190,7 @@ impl trust_dns_proto::udp::UdpSocket for JiveUdpSocket { } #[async_trait::async_trait] -impl trust_dns_proto::Time for JiveTimer { +impl hickory_proto::Time for JiveTimer { async fn delay_for(duration: std::time::Duration) { jive::time::sleep(duration).await } @@ -204,7 +203,7 @@ impl trust_dns_proto::Time for JiveTimer { } } -impl trust_dns_proto::Executor for JiveRuntime { +impl hickory_proto::Executor for JiveRuntime { fn new() -> Self { Self }