[][src]Struct socks5_async::SocksServer

pub struct SocksServer { /* fields omitted */ }

A SOCKS5 Server

Implementations

impl SocksServer[src]

pub async fn new(
    socket_addr: SocketAddr,
    allow_no_auth: bool,
    auth: Box<dyn Fn(String, String) -> bool + Send>
) -> SocksServer
[src]

Creates and returns a new SocksServer

pub async fn serve<'_>(&'_ mut self)[src]

Starts the server. It should be called after initializing server

Example

use socks5_async::SocksServer;
use std::{
    boxed::Box,
    error::Error,
    net::SocketAddr,
};

let users = vec![
    (String::from("user1"), String::from("123456"))
];

// Server address
let address: SocketAddr = "127.0.0.1:1080".parse().unwrap();
let mut socks5 = SocksServer::new(address, true,
    Box::new(move |username, password| {
        // Authenticate user
        return users.contains(&(username, password));
    }),
).await;
socks5.serve().await;

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.