socks5_impl::server::connection

Struct IncomingConnection

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

An incoming connection. This may not be a valid socks5 connection. You need to call authenticate() to perform the socks5 handshake. It will be converted to a proper socks5 connection after the handshake succeeds.

Implementations§

Source§

impl<O: 'static> IncomingConnection<O>

Source

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

Returns the local address that this stream is bound to.

Source

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

Returns the remote address that this stream is connected to.

Source

pub async fn shutdown(&mut self) -> Result<()>

Shutdown the TCP stream.

Source

pub fn linger(&self) -> Result<Option<Duration>>

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<()>

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>

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<()>

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>

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<()>

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.

Source

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

Perform a SOCKS5 authentication handshake using the given AuthExecutor adapter.

If the handshake succeeds, an Authenticated alongs with the output of the AuthExecutor 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.

Trait Implementations§

Source§

impl<O> Debug for IncomingConnection<O>

Source§

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

Formats the value using the given formatter. Read more
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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Gets the type name of self
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> Downcast for T
where T: AsAny + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
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.