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>
impl<A> IncomingConnection<A, NeedAuthenticate>
Sourcepub async fn authenticate(
self,
) -> Result<(IncomingConnection<A, NeedCommand>, A), (Error, TcpStream)>
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>
impl<A> IncomingConnection<A, NeedCommand>
Sourcepub async fn wait(self) -> Result<Command, (Error, TcpStream)>
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>
impl<A, S> IncomingConnection<A, S>
Sourcepub async fn close(&mut self) -> Result<(), IoError>
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.
Sourcepub fn local_addr(&self) -> Result<SocketAddr, IoError>
pub fn local_addr(&self) -> Result<SocketAddr, IoError>
Returns the local address that this stream is bound to.
Sourcepub fn peer_addr(&self) -> Result<SocketAddr, IoError>
pub fn peer_addr(&self) -> Result<SocketAddr, IoError>
Returns the remote address that this stream is connected to.
Sourcepub fn get_ref(&self) -> &TcpStream
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.
Sourcepub fn get_mut(&mut self) -> &mut TcpStream
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.
Sourcepub fn into_inner(self) -> TcpStream
pub fn into_inner(self) -> TcpStream
Consumes the IncomingConnection and returns the underlying TcpStream.