Update to hickory dns

This commit is contained in:
asonix 2023-10-23 17:00:48 -05:00
parent 84816c2d14
commit 6c86569215
2 changed files with 18 additions and 19 deletions

View file

@ -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",
] }

View file

@ -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, trust_dns_resolver::error::ResolveError>
{
JiveResolver::from_system_conf(trust_dns_resolver::name_server::GenericConnector::new(
pub fn resolver_from_system_conf() -> Result<JiveResolver, hickory_resolver::error::ResolveError> {
JiveResolver::from_system_conf(hickory_resolver::name_server::GenericConnector::new(
JiveRuntime,
))
}
@ -32,10 +31,10 @@ pub struct JiveUdpSocket {
io: jive::io::Async<jive::net::UdpSocket>,
}
pub type JiveResolver = trust_dns_resolver::AsyncResolver<JiveConnectionProvider>;
pub type JiveResolver = hickory_resolver::AsyncResolver<JiveConnectionProvider>;
pub type JiveConnection = trust_dns_resolver::name_server::GenericConnection;
pub type JiveConnectionProvider = trust_dns_resolver::name_server::GenericConnector<JiveRuntime>;
pub type JiveConnection = hickory_resolver::name_server::GenericConnection;
pub type JiveConnectionProvider = hickory_resolver::name_server::GenericConnector<JiveRuntime>;
#[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<F>(&mut self, future: F)
where
F: Future<Output = Result<(), trust_dns_proto::error::ProtoError>> + Send + 'static,
F: Future<Output = Result<(), hickory_proto::error::ProtoError>> + 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<std::net::SocketAddr>,
@ -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<Self> {
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
}