pub struct Socks5Datagram<S: AsyncRead + AsyncWrite + Unpin> { /* private fields */ }
Expand description

A SOCKS5 UDP client.

Implementations§

source§

impl<S: AsyncRead + AsyncWrite + Unpin> Socks5Datagram<S>

source

pub async fn bind<U>( backing_socket: S, client_bind_addr: U ) -> Result<Socks5Datagram<S>>
where U: ToSocketAddrs,

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

§Arguments
  • backing_socket - The underlying socket carrying the socks5 traffic.
  • client_bind_addr - A socket address indicates the binding source address used to communicate with the socks5 server.
§Examples
let backing_socket = TcpStream::connect("127.0.0.1:1080").await.unwrap();
let tunnel = client::Socks5Datagram::bind(backing_socket, "[::]:0")
    .await
    .unwrap();
source

pub async fn bind_with_password<U>( backing_socket: S, client_bind_addr: U, username: &str, password: &str ) -> Result<Socks5Datagram<S>>
where 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 async fn send_to<A>(&self, data: &[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 async fn recv_from( &self, data_store: &mut [u8] ) -> Result<(usize, TargetAddr)>

Like UdpSocket::recv_from.

source

pub fn proxy_addr(&self) -> Result<&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<S: Debug + AsyncRead + AsyncWrite + Unpin> Debug for Socks5Datagram<S>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> !Freeze for Socks5Datagram<S>

§

impl<S> RefUnwindSafe for Socks5Datagram<S>
where S: RefUnwindSafe,

§

impl<S> Send for Socks5Datagram<S>
where S: Send,

§

impl<S> Sync for Socks5Datagram<S>
where S: Sync,

§

impl<S> Unpin for Socks5Datagram<S>

§

impl<S> UnwindSafe for Socks5Datagram<S>
where S: UnwindSafe,

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>,

§

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>,

§

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.