pub struct Server<O> { /* private fields */ }
Expand description
The socks5 server itself.
The server can be constructed on a given socket address, or be created on an existing TcpListener.
The authentication method can be configured with the
AuthExecutor
trait.
Implementations§
Source§impl<O: 'static> Server<O>
impl<O: 'static> Server<O>
Sourcepub fn new(listener: TcpListener, auth: AuthAdaptor<O>) -> Self
pub fn new(listener: TcpListener, auth: AuthAdaptor<O>) -> Self
Create a new socks5 server with the given TCP listener and authentication method.
Sourcepub async fn bind(addr: SocketAddr, auth: AuthAdaptor<O>) -> Result<Self>
pub async fn bind(addr: SocketAddr, auth: AuthAdaptor<O>) -> Result<Self>
Create a new socks5 server on the given socket address and authentication method.
Sourcepub async fn accept(&self) -> Result<(IncomingConnection<O>, SocketAddr)>
pub async fn accept(&self) -> Result<(IncomingConnection<O>, SocketAddr)>
Accept an IncomingConnection
.
The connection may not be a valid socks5 connection. You need to call
IncomingConnection::authenticate
to hand-shake it into a proper socks5 connection.
Sourcepub fn poll_accept(
&self,
cx: &mut Context<'_>,
) -> Poll<Result<(IncomingConnection<O>, SocketAddr)>>
pub fn poll_accept( &self, cx: &mut Context<'_>, ) -> Poll<Result<(IncomingConnection<O>, SocketAddr)>>
Polls to accept an IncomingConnection<O>
.
The connection is only a freshly created TCP connection and may not be a valid SOCKS5 connection.
You should call
IncomingConnection::authenticate
to perform a SOCKS5 authentication handshake.
If there is no connection to accept, Poll::Pending is returned and the current task will be notified by a waker. Note that on multiple calls to poll_accept, only the Waker from the Context passed to the most recent call is scheduled to receive a wakeup.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Get the the local socket address binded to this server