Skip to content

Commit

Permalink
Add UdpSocket::bind (#1810)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 authored Dec 11, 2024
1 parent 38eda57 commit 4464310
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/shadowsocks/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ impl UdpSocket {
})
}

/// Binds to a specific address as an outbound socket
#[inline]
pub async fn bind(addr: &SocketAddr) -> io::Result<UdpSocket> {
UdpSocket::bind_with_opts(addr, &ConnectOpts::default()).await
}

/// Binds to a specific address with opts as an outbound socket
pub async fn bind_with_opts(addr: &SocketAddr, opts: &ConnectOpts) -> io::Result<UdpSocket> {
bind_outbound_udp_socket(addr, opts).await.map(|socket| UdpSocket {
Expand Down

0 comments on commit 4464310

Please sign in to comment.