Struct tokio_socks::tcp::socks4::Socks4Listener

source ·
pub struct Socks4Listener<S> { /* private fields */ }
Expand description

A SOCKS4 BIND client.

Once you get an instance of Socks4Listener, you should send the bind_addr to the remote process via the primary connection. Then, call the accept function and wait for the other end connecting to the rendezvous address.

Implementations§

source§

impl Socks4Listener<TcpStream>

source

pub async fn bind<'t, P, T>( proxy: P, target: T, ) -> Result<Socks4Listener<TcpStream>>
where P: ToProxyAddrs, T: IntoTargetAddr<'t>,

Initiates a BIND request to the specified proxy.

The proxy will filter incoming connections based on the value of target.

§Error

It propagates the error that occurs in the conversion from T to TargetAddr.

source

pub async fn bind_with_userid<'a, 't, P, T>( proxy: P, target: T, user_id: &'a str, ) -> Result<Socks4Listener<TcpStream>>
where P: ToProxyAddrs, T: IntoTargetAddr<'t>,

Initiates a BIND request to the specified proxy using given username and password.

The proxy will filter incoming connections based on the value of target.

§Error

It propagates the error that occurs in the conversion from T to TargetAddr.

source§

impl<S> Socks4Listener<S>
where S: AsyncSocket + Unpin,

source

pub async fn bind_with_socket<'t, T>( socket: S, target: T, ) -> Result<Socks4Listener<S>>
where T: IntoTargetAddr<'t>,

Initiates a BIND request to the specified proxy using the given socket to it.

The proxy will filter incoming connections based on the value of target.

§Error

It propagates the error that occurs in the conversion from T to TargetAddr.

source

pub async fn bind_with_user_and_socket<'a, 't, T>( socket: S, target: T, user_id: &'a str, ) -> Result<Socks4Listener<S>>
where T: IntoTargetAddr<'t>,

Initiates a BIND request to the specified proxy using given username, password and socket to the proxy.

The proxy will filter incoming connections based on the value of target.

§Error

It propagates the error that occurs in the conversion from T to TargetAddr.

source

pub fn bind_addr(&self) -> TargetAddr<'_>

Returns the address of the proxy-side TCP listener.

This should be forwarded to the remote process, which should open a connection to it.

source

pub async fn accept(self) -> Result<Socks4Stream<S>>

Consumes this listener, returning a Future which resolves to the Socks4Stream connected to the target server through the proxy.

The value of bind_addr should be forwarded to the remote process before this method is called.

Auto Trait Implementations§

§

impl<S> Freeze for Socks4Listener<S>
where S: Freeze,

§

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

§

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

§

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

§

impl<S> Unpin for Socks4Listener<S>
where S: Unpin,

§

impl<S> UnwindSafe for Socks4Listener<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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.