pub struct Socks5UdpAssociation { /* private fields */ }Expand description
A SOCKS5 UDP association (RFC 1928 §7).
The control TCP connection is owned by a watcher task that detects a
proxy-initiated close (EOF) and cancels closed, so a dead
relay surfaces as an error instead of a silent black-hole. The local UDP
socket is connected to the proxy’s relay endpoint; datagrams to arbitrary
targets carry their own address header, so one association serves a whole flow.
Implementations§
Source§impl Socks5UdpAssociation
impl Socks5UdpAssociation
Sourcepub async fn associate(proxy: &str) -> Result<Self>
pub async fn associate(proxy: &str) -> Result<Self>
Opens a UDP association via the no-auth SOCKS5 proxy (host:port),
bounded by [HANDSHAKE_TIMEOUT].
Sourcepub async fn send_to(
&self,
payload: &[u8],
host: &str,
port: u16,
) -> Result<usize>
pub async fn send_to( &self, payload: &[u8], host: &str, port: u16, ) -> Result<usize>
Sends payload to host:port through the proxy’s UDP relay. The target
is encoded by name when not an IP literal so the proxy resolves it.
Sourcepub async fn recv_from(
&self,
buf: &mut [u8],
) -> Result<Option<(usize, String, u16)>>
pub async fn recv_from( &self, buf: &mut [u8], ) -> Result<Option<(usize, String, u16)>>
Receives one relayed datagram into buf, returning Some((len, host, port)) with the inner payload moved to the front of buf, or None if
the datagram is fragmented / malformed (skip it, the flow stays up). Errors
only on a real socket error or a proxy-initiated control close.
buf must be large enough for a full UDP datagram (65 535 bytes); a
smaller buffer truncates at the OS recv as with any UDP socket.