indicate socket creating fail
This commit is contained in:
parent
079e724948
commit
f3cb84e5c4
@ -64,6 +64,8 @@ pub enum Error {
|
||||
AuthFailed(Uuid),
|
||||
#[error("received packet from unexpected source")]
|
||||
UnexpectedPacketSource,
|
||||
#[error("create UDP session socket failed: {0}")]
|
||||
CreateUdpSessionSocket(IoError),
|
||||
#[error("{0} resolved to {1} but IPv6 UDP relay disabled")]
|
||||
UdpRelayIpv6Disabled(Address, SocketAddr),
|
||||
}
|
||||
|
@ -492,14 +492,18 @@ impl Connection {
|
||||
(session.socket_v4.clone(), session.socket_v6.clone())
|
||||
}
|
||||
Entry::Vacant(entry) => {
|
||||
let session = entry
|
||||
.insert(UdpSession::new(assoc_id, self.clone(), self.udp_relay_ipv6).await?);
|
||||
let session = entry.insert(
|
||||
UdpSession::new(assoc_id, self.clone(), self.udp_relay_ipv6)
|
||||
.await
|
||||
.map_err(Error::CreateUdpSessionSocket)?,
|
||||
);
|
||||
|
||||
(session.socket_v4.clone(), session.socket_v6.clone())
|
||||
}
|
||||
};
|
||||
|
||||
let Some(socket_addr) = resolve_dns(&addr).await?.next() else {
|
||||
Err(IoError::new(ErrorKind::NotFound, "no address resolved"))?
|
||||
return Err(Error::from(IoError::new(ErrorKind::NotFound, "no address resolved")));
|
||||
};
|
||||
|
||||
let socket = match socket_addr {
|
||||
@ -588,7 +592,7 @@ struct UdpSession {
|
||||
}
|
||||
|
||||
impl UdpSession {
|
||||
async fn new(assoc_id: u16, conn: Connection, udp_relay_ipv6: bool) -> Result<Self, Error> {
|
||||
async fn new(assoc_id: u16, conn: Connection, udp_relay_ipv6: bool) -> Result<Self, IoError> {
|
||||
let socket_v4 =
|
||||
Arc::new(UdpSocket::bind(SocketAddr::from((Ipv4Addr::UNSPECIFIED, 0))).await?);
|
||||
let socket_v6 = if udp_relay_ipv6 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user