socks5_impl::server::connection

Struct Authenticated

Source
pub struct Authenticated(/* private fields */);
Expand description

A TCP stream that has been authenticated.

To get the command from the SOCKS5 client, use wait_request.

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

Implementations§

Source§

impl Authenticated

Source

pub async fn wait_request(self) -> Result<ClientConnection>

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 request.

Source

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

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>

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

Trait Implementations§

Source§

impl From<Authenticated> for TcpStream

Source§

fn from(conn: Authenticated) -> 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.