Struct fast_socks5::server::Socks5Socket
source · pub struct Socks5Socket<T: AsyncRead + AsyncWrite + Unpin, A: Authentication> { /* private fields */ }
Expand description
Wrap TcpStream and contains Socks5 protocol implementation.
Implementations§
source§impl<T: AsyncRead + AsyncWrite + Unpin, A: Authentication> Socks5Socket<T, A>
impl<T: AsyncRead + AsyncWrite + Unpin, A: Authentication> Socks5Socket<T, A>
pub fn new(socket: T, config: Arc<Config<A>>) -> Self
sourcepub fn set_reply_ip(&mut self, addr: IpAddr)
pub fn set_reply_ip(&mut self, addr: IpAddr)
Set the bind IP address in Socks5Reply.
Only the inner socket owner knows the correct reply bind addr, so leave this field to be populated. For those strict clients, users can use this function to set the correct IP address.
Most popular SOCKS5 clients [1] [2] ignore BND.ADDR and BND.PORT the reply of command CONNECT, but this field could be useful in some other command, such as UDP ASSOCIATE.
[1]. https://github.com/chromium/chromium/blob/bd2c7a8b65ec42d806277dd30f138a673dec233a/net/socket/socks5_client_socket.cc#L481 [2]. https://github.com/curl/curl/blob/d15692ebbad5e9cfb871b0f7f51a73e43762cee2/lib/socks.c#L978
sourcepub async fn upgrade_to_socks5(self) -> Result<Socks5Socket<T, A>>
pub async fn upgrade_to_socks5(self) -> Result<Socks5Socket<T, A>>
Process clients SOCKS requests This is the entry point where a whole request is processed.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the Socks5Socket
, returning the wrapped stream.
sourcepub async fn resolve_dns(&mut self) -> Result<()>
pub async fn resolve_dns(&mut self) -> Result<()>
This function is public, it can be call manually on your own-willing
if config flag has been turned off: Config::dns_resolve == false
.
pub fn target_addr(&self) -> Option<&TargetAddr>
pub fn auth(&self) -> &AuthenticationMethod
pub fn cmd(&self) -> &Option<Socks5Command>
sourcepub fn get_credentials(
&self
) -> Option<&<<A as Authentication>::Item as Deref>::Target>
pub fn get_credentials( &self ) -> Option<&<<A as Authentication>::Item as Deref>::Target>
Borrow the credentials of the user has authenticated with
sourcepub fn take_credentials(&mut self) -> Option<A::Item>
pub fn take_credentials(&mut self) -> Option<A::Item>
Get the credentials of the user has authenticated with
Trait Implementations§
source§impl<T, A: Authentication> AsyncRead for Socks5Socket<T, A>
impl<T, A: Authentication> AsyncRead for Socks5Socket<T, A>
Allow us to read directly from the struct
source§impl<T, A: Authentication> AsyncWrite for Socks5Socket<T, A>
impl<T, A: Authentication> AsyncWrite for Socks5Socket<T, A>
Allow us to write directly into the struct
source§fn poll_write(
self: Pin<&mut Self>,
context: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, context: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize>>
buf
into the object. Read moresource§fn poll_flush(
self: Pin<&mut Self>,
context: &mut Context<'_>
) -> Poll<Result<()>>
fn poll_flush( self: Pin<&mut Self>, context: &mut Context<'_> ) -> Poll<Result<()>>
source§fn poll_shutdown(
self: Pin<&mut Self>,
context: &mut Context<'_>
) -> Poll<Result<()>>
fn poll_shutdown( self: Pin<&mut Self>, context: &mut Context<'_> ) -> Poll<Result<()>>
source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
poll_write
, except that it writes from a slice of buffers. Read moresource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read moreimpl<T, A: Authentication> Unpin for Socks5Socket<T, A>
Auto Trait Implementations§
impl<T, A> Freeze for Socks5Socket<T, A>
impl<T, A> RefUnwindSafe for Socks5Socket<T, A>
impl<T, A> Send for Socks5Socket<T, A>
impl<T, A> Sync for Socks5Socket<T, A>
impl<T, A> UnwindSafe for Socks5Socket<T, A>
Blanket Implementations§
source§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
source§fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
buf
. Read moresource§fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
source§fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
source§fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
source§fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
source§fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
source§fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
source§fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
source§fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
source§fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
source§fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
source§fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
source§fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
source§fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
source§fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
source§fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
source§fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
source§fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
source§fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
source§fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
source§fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
source§fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
source§fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
source§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
buf
. Read more