Trait socks5_impl::server::auth::AuthExecutor
source · pub trait AuthExecutor {
// Required methods
fn auth_method(&self) -> AuthMethod;
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 socks5_impl::protocol::AuthMethod;
use socks5_impl::server::AuthExecutor;
use tokio::net::TcpStream;
pub struct MyAuth;
#[async_trait]
impl AuthExecutor for MyAuth {
fn auth_method(&self) -> AuthMethod {
AuthMethod::from(0x80)
}
async fn execute(&self, stream: &mut TcpStream) -> std::io::Result<()> {
// do something
Ok(())
}
}