IncomingConnection

Struct IncomingConnection 

Source
pub struct IncomingConnection<A, S> { /* private fields */ }
Expand description

An incoming SOCKS5 connection.

This may not be a valid SOCKS5 connection. You should call IncomingConnection::authenticate() and IncomingConnection::wait() to perform a SOCKS5 connection negotiation.

Implementations§

Source§

impl<A> IncomingConnection<A, NeedAuthenticate>

Source

pub async fn authenticate( self, ) -> Result<(IncomingConnection<A, NeedCommand>, A), (Error, TcpStream)>

Perform a SOCKS5 authentication handshake using the given Auth adapter.

If the handshake succeeds, an IncomingConnection<A, state::NeedCommand> alongs with the output of the Auth adapter A is returned. Otherwise, the error and the underlying TcpStream is returned.

Note that this method will not implicitly close the connection even if the handshake failed.

Source§

impl<A> IncomingConnection<A, NeedCommand>

Source

pub async fn wait(self) -> Result<Command, (Error, TcpStream)>

Waits the SOCKS5 client to send a request.

This method will return a Command if the client sends a valid command.

When encountering an error, the stream will be returned alongside the error.

Note that this method will not implicitly close the connection even if the client sends an invalid command.

Source§

impl<A, S> IncomingConnection<A, S>

Source

pub async fn close(&mut self) -> Result<(), IoError>

Causes the other peer to receive a read of length 0, indicating that no more data will be sent. This only closes the stream in one direction.

Source

pub fn local_addr(&self) -> Result<SocketAddr, IoError>

Returns the local address that this stream is bound to.

Source

pub fn peer_addr(&self) -> Result<SocketAddr, IoError>

Returns the remote address that this stream is connected to.

Source

pub fn get_ref(&self) -> &TcpStream

Returns a shared reference to the underlying stream.

Note that this may break the encapsulation of the SOCKS5 connection and you should not use this method unless you know what you are doing.

Source

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

Returns a mutable reference to the underlying stream.

Note that this may break the encapsulation of the SOCKS5 connection and you should not use this method unless you know what you are doing.

Source

pub fn into_inner(self) -> TcpStream

Consumes the IncomingConnection and returns the underlying TcpStream.

Trait Implementations§

Source§

impl<A, S> Debug for IncomingConnection<A, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A, S> !Freeze for IncomingConnection<A, S>

§

impl<A, S> !RefUnwindSafe for IncomingConnection<A, S>

§

impl<A, S> Send for IncomingConnection<A, S>
where S: Send,

§

impl<A, S> Sync for IncomingConnection<A, S>
where S: Sync,

§

impl<A, S> Unpin for IncomingConnection<A, S>
where S: Unpin,

§

impl<A, S> !UnwindSafe for IncomingConnection<A, S>

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

Source§

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

Source§

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.