SocksUdpSocket

Struct SocksUdpSocket 

Source
pub struct SocksUdpSocket { /* private fields */ }
Expand description

A UDP socket that is associated through a SOCKS proxy.

Implementations§

Source§

impl SocksUdpSocket

Source

pub fn new(socket: UdpSocket, stream: TcpStream, addr: SocketAddr) -> Self

Creates a new SocksUdpSocket with the specified UDP socket, control stream, and bound address.

§Arguments
  • socket - The UDP socket.
  • stream - The control TCP stream.
  • addr - The bound address.
§Returns

A new SocksUdpSocket.

Source

pub fn get_proxy_udp_addr(&mut self) -> SocketAddr

Gets the UDP address from the SOCKS proxy.

§Returns

The bound SocketAddr.

Source

pub async fn send_udp_data( &self, buf: &[u8], target_addr: &str, ) -> Result<usize, SocksError>

Sends UDP data to the specified target address.

§Arguments
  • buf - The data to send.
  • target_addr - The target address to send the data to.
§Returns

A Result containing the number of bytes sent if successful, or a SocksError if an error occurs.

Source

pub async fn recv_udp_data( &self, tm: u64, ) -> Result<(SocketAddr, Vec<u8>), SocksError>

Receives UDP data with a timeout.

§Arguments
  • tm - The timeout duration in seconds.
§Returns

A Result containing the received data and the sender’s address if successful, or a SocksError if an error occurs.

Trait Implementations§

Source§

impl Debug for SocksUdpSocket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.