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>
impl<O: 'static> IncomingConnection<O>
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the local address that this stream is bound to.
Sourcepub fn peer_addr(&self) -> Result<SocketAddr>
pub fn peer_addr(&self) -> Result<SocketAddr>
Returns the remote address that this stream is connected to.
Sourcepub fn linger(&self) -> Result<Option<Duration>>
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
.
Sourcepub fn set_linger(&self, dur: Option<Duration>) -> Result<()>
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.
Sourcepub fn nodelay(&self) -> Result<bool>
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
.
Sourcepub fn set_nodelay(&self, nodelay: bool) -> Result<()>
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.
Sourcepub fn ttl(&self) -> Result<u32>
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
.
Sourcepub fn set_ttl(&self, ttl: u32) -> Result<()>
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.
Sourcepub async fn authenticate(self) -> Result<(Authenticated, O)>
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.