pub struct Socks5Datagram { /* private fields */ }
Expand description

A SOCKS5 UDP client.

Implementations§

source§

impl Socks5Datagram

source

pub fn bind<T, U>( proxy: T, addr: U, timeout: Option<Duration> ) -> Result<Socks5Datagram>where T: ToSocketAddrs, U: ToSocketAddrs,

Creates a UDP socket bound to the specified address which will have its traffic routed through the specified proxy.

source

pub fn bind_with_password<T, U>( proxy: T, addr: U, username: &str, password: &str, timeout: Option<Duration> ) -> Result<Socks5Datagram>where T: ToSocketAddrs, U: ToSocketAddrs,

Creates a UDP socket bound to the specified address which will have its traffic routed through the specified proxy. The given username and password is used to authenticate to the SOCKS proxy.

source

pub fn send_to<A>(&self, buf: &[u8], addr: A) -> Result<usize>where A: ToTargetAddr,

Like UdpSocket::send_to.

Note

The SOCKS protocol inserts a header at the beginning of the message. The header will be 10 bytes for an IPv4 address, 22 bytes for an IPv6 address, and 7 bytes plus the length of the domain for a domain address.

source

pub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, TargetAddr)>

Like UdpSocket::recv_from.

source

pub fn proxy_addr(&self) -> &TargetAddr

Returns the address of the proxy-side UDP socket through which all messages will be routed.

source

pub fn get_ref(&self) -> &UdpSocket

Returns a shared reference to the inner socket.

source

pub fn get_mut(&mut self) -> &mut UdpSocket

Returns a mutable reference to the inner socket.

Trait Implementations§

source§

impl Debug for Socks5Datagram

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.