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
impl Authenticated
Sourcepub async fn wait_request(self) -> Result<ClientConnection>
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.
Sourcepub async fn shutdown(&mut self) -> Result<()>
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.
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.