WIP: narrow UdpSocket down to DnsUdpSocket

This commit is contained in:
XOR-op
2023-01-08 15:24:01 +08:00
committed by Benjamin Fry
parent 6099e8ab2e
commit 3e9892d18a
8 changed files with 37 additions and 32 deletions

View File

@@ -10,6 +10,7 @@ use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
use std::pin::Pin;
use std::task::{Context, Poll};
use crate::proto::udp::DnsUdpSocket;
use async_std::task::spawn_blocking;
use async_trait::async_trait;
use futures_io::{AsyncRead, AsyncWrite};
@@ -18,7 +19,6 @@ use pin_utils::pin_mut;
use socket2::{Domain, Protocol, Socket, Type};
use trust_dns_resolver::proto::tcp::{Connect, DnsTcpStream};
use trust_dns_resolver::proto::udp::UdpSocket;
use crate::proto::udp::DnsUdpSocket;
use crate::time::AsyncStdTime;
@@ -59,9 +59,8 @@ impl DnsUdpSocket for AsyncStdUdpSocket {
}
}
#[async_trait]
impl UdpSocket for AsyncStdUdpSocket{
impl UdpSocket for AsyncStdUdpSocket {
async fn connect(addr: SocketAddr) -> io::Result<Self> {
let bind_addr: SocketAddr = match addr {
SocketAddr::V4(_addr) => (Ipv4Addr::UNSPECIFIED, 0).into(),
@@ -84,7 +83,6 @@ impl UdpSocket for AsyncStdUdpSocket{
.await
.map(AsyncStdUdpSocket)
}
}
pub struct AsyncStdTcpStream(async_std::net::TcpStream);