pub struct IncomingConnection<O> { /* private fields */ }
Expand description

A freshly established TCP connection.

This may not be a valid SOCKS5 connection. You should call authenticate() to perform a SOCKS5 authentication handshake.

It can also be converted back into a raw tokio TcpStream with From trait.

Implementations§

source§

impl<O> IncomingConnection<O>

source

pub async fn authenticate( self ) -> Result<(Authenticated, O), (Error, TcpStream)>

Perform a SOCKS5 authentication handshake using the given Auth adapter.

If the handshake succeeds, an Authenticated alongs with the output of the Auth adapter is returned. Otherwise, the error and the original TcpStream is returned.

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

source

pub async fn shutdown(&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 linger(&self) -> Result<Option<Duration>, IoError>

Reads the linger duration for this socket by getting the SO_LINGER option.

For more information about this option, see set_linger.

source

pub fn set_linger(&self, dur: Option<Duration>) -> Result<(), IoError>

Sets the linger duration of this socket by setting the SO_LINGER option.

This option controls the action taken when a stream has unsent messages and the stream is closed. If SO_LINGER is set, the system shall block the process until it can transmit the data or until the time expires.

If SO_LINGER is not specified, and the stream is closed, the system handles the call in a way that allows the process to continue as quickly as possible.

source

pub fn nodelay(&self) -> Result<bool, IoError>

Gets the value of the TCP_NODELAY option on this socket.

For more information about this option, see set_nodelay.

source

pub fn set_nodelay(&self, nodelay: bool) -> Result<(), IoError>

Sets the value of the TCP_NODELAY option on this socket.

If set, this option disables the Nagle algorithm. This means that segments are always sent as soon as possible, even if there is only a small amount of data. When not set, data is buffered until there is a sufficient amount to send out, thereby avoiding the frequent sending of small packets.

source

pub fn ttl(&self) -> Result<u32, IoError>

Gets the value of the IP_TTL option for this socket.

For more information about this option, see set_ttl.

source

pub fn set_ttl(&self, ttl: u32) -> Result<(), IoError>

Sets the value for the IP_TTL option on this socket.

This value sets the time-to-live field that is used in every packet sent from this socket.

Trait Implementations§

source§

impl<O> From<IncomingConnection<O>> for TcpStream

source§

fn from(conn: IncomingConnection<O>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.