Struct fast_socks5::client::Socks5Datagram
source · pub struct Socks5Datagram<S: AsyncRead + AsyncWrite + Unpin> { /* private fields */ }
Expand description
A SOCKS5 UDP client.
Implementations§
source§impl<S: AsyncRead + AsyncWrite + Unpin> Socks5Datagram<S>
impl<S: AsyncRead + AsyncWrite + Unpin> Socks5Datagram<S>
sourcepub async fn bind<U>(
backing_socket: S,
client_bind_addr: U
) -> Result<Socks5Datagram<S>>where
U: ToSocketAddrs,
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();
sourcepub async fn bind_with_password<U>(
backing_socket: S,
client_bind_addr: U,
username: &str,
password: &str
) -> Result<Socks5Datagram<S>>where
U: ToSocketAddrs,
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.
sourcepub async fn send_to<A>(&self, data: &[u8], addr: A) -> Result<usize>where
A: ToTargetAddr,
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.
sourcepub async fn recv_from(
&self,
data_store: &mut [u8]
) -> Result<(usize, TargetAddr)>
pub async fn recv_from( &self, data_store: &mut [u8] ) -> Result<(usize, TargetAddr)>
Like UdpSocket::recv_from
.
sourcepub fn proxy_addr(&self) -> Result<&TargetAddr>
pub fn proxy_addr(&self) -> Result<&TargetAddr>
Returns the address of the proxy-side UDP socket through which all messages will be routed.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more