Struct socks5_server::connection::associate::AssociateUdpSocket
source · [−]pub struct AssociateUdpSocket { /* private fields */ }Expand description
This is a helper for managing the associated UDP socket.
It will add the socks5 UDP header to every UDP packet it sends, also try to parse the socks5 UDP header from any UDP packet received.
The receiving buffer size for each UDP packet can be set with set_recv_buffer_size(), and be read with get_max_packet_size().
You can create this struct by using AssociateUdpSocket::from::<(UdpSocket, usize)>(), the first element of the tuple is the UDP socket, the second element is the receiving buffer size.
This struct can also be revert into a raw tokio UDP socket with UdpSocket::from::<AssociateUdpSocket>().
Implementations
sourceimpl AssociateUdpSocket
impl AssociateUdpSocket
sourcepub async fn connect<A: ToSocketAddrs>(&self, addr: A) -> Result<()>
pub async fn connect<A: ToSocketAddrs>(&self, addr: A) -> Result<()>
Connects the UDP socket setting the default destination for send() and limiting packets that are read via recv from the address specified in addr.
sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the local address that this socket is bound to.
sourcepub fn peer_addr(&self) -> Result<SocketAddr>
pub fn peer_addr(&self) -> Result<SocketAddr>
Returns the socket address of the remote peer this socket was connected to.
sourcepub fn get_max_packet_size(&self) -> usize
pub fn get_max_packet_size(&self) -> usize
Get the maximum UDP packet size, with socks5 UDP header included.
sourcepub fn set_max_packet_size(&self, size: usize)
pub fn set_max_packet_size(&self, size: usize)
Set the maximum UDP packet size, with socks5 UDP header included, for adjusting the receiving buffer size.
sourcepub async fn recv(&self) -> Result<(Bytes, u8, Address)>
pub async fn recv(&self) -> Result<(Bytes, u8, Address)>
Receives a socks5 UDP relay packet on the socket from the remote address to which it is connected. On success, returns the packet itself, the fragment number and the remote target address.
The connect method will connect this socket to a remote address. This method will fail if the socket is not connected.
sourcepub async fn recv_from(&self) -> Result<(Bytes, u8, Address, SocketAddr)>
pub async fn recv_from(&self) -> Result<(Bytes, u8, Address, SocketAddr)>
Receives a socks5 UDP relay packet on the socket from the any remote address. On success, returns the packet itself, the fragment number, the remote target address and the source address.
Trait Implementations
sourceimpl Debug for AssociateUdpSocket
impl Debug for AssociateUdpSocket
sourceimpl From<AssociateUdpSocket> for UdpSocket
impl From<AssociateUdpSocket> for UdpSocket
sourcefn from(from: AssociateUdpSocket) -> Self
fn from(from: AssociateUdpSocket) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for AssociateUdpSocket
impl Send for AssociateUdpSocket
impl Sync for AssociateUdpSocket
impl Unpin for AssociateUdpSocket
impl UnwindSafe for AssociateUdpSocket
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more