Skip to content

Commit 636d9c5

Browse files
committed
feat: impls AsSocket, AsRawSocket for UdpSocket
1 parent 393e09c commit 636d9c5

File tree

1 file changed

+16
-2
lines changed
  • crates/shadowsocks/src/net

1 file changed

+16
-2
lines changed

crates/shadowsocks/src/net/udp.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ use futures::ready;
3535
use tokio::io::Interest;
3636
use tokio::{io::ReadBuf, net::ToSocketAddrs};
3737

38-
use crate::{ServerAddr, context::Context, relay::socks5::Address};
38+
use crate::{context::Context, relay::socks5::Address, ServerAddr};
3939

4040
use super::{
41-
AcceptOpts, AddrFamily, ConnectOpts,
4241
sys::{bind_outbound_udp_socket, create_inbound_udp_socket, create_outbound_udp_socket},
42+
AcceptOpts, AddrFamily, ConnectOpts,
4343
};
4444

4545
/// Message struct for `batch_send`
@@ -414,3 +414,17 @@ impl std::os::fd::AsFd for UdpSocket {
414414
self.socket.as_fd()
415415
}
416416
}
417+
418+
#[cfg(windows)]
419+
impl std::os::windows::io::AsRawSocket for UdpSocket {
420+
fn as_raw_socket(&self) -> std::os::windows::io::RawSocket {
421+
self.socket.as_raw_socket()
422+
}
423+
}
424+
425+
#[cfg(windows)]
426+
impl std::os::windows::io::AsSocket for UdpSocket {
427+
fn as_socket(&self) -> std::os::windows::io::BorrowedSocket<'_> {
428+
self.socket.as_socket()
429+
}
430+
}

0 commit comments

Comments
 (0)