Trait socks5_impl::server::auth::Auth
source · pub trait Auth {
// Required methods
fn as_handshake_method(&self) -> HandshakeMethod;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
stream: &'life1 mut TcpStream
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
This trait is for defining the socks5 authentication method.
Pre-defined authentication methods can be found in the auth
module.
You can create your own authentication method by implementing this trait. Since GAT is not stabled yet, async_trait needs to be used.
Example
use async_trait::async_trait;
use std::io::Result;
use socks5_impl::protocol::HandshakeMethod;
use socks5_impl::server::Auth;
use tokio::net::TcpStream;
pub struct MyAuth;
#[async_trait]
impl Auth for MyAuth {
fn as_handshake_method(&self) -> HandshakeMethod {
HandshakeMethod(0x80)
}
async fn execute(&self, stream: &mut TcpStream) -> Result<()> {
// do something
Ok(())
}
}