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<bool>> + 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 socks5_impl::protocol::AuthMethod;
use socks5_impl::server::AuthExecutor;
use tokio::net::TcpStream;
pub struct MyAuth;
#[async_trait::async_trait]
impl AuthExecutor for MyAuth {
fn auth_method(&self) -> AuthMethod {
AuthMethod::from(0x80)
}
async fn execute(&self, stream: &mut TcpStream) -> std::io::Result<bool> {
// do something
Ok(true)
}
}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<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".