pub struct SocksServer { /* private fields */ }
Expand description
A SOCKS5 Server
Implementations§
Source§impl SocksServer
impl SocksServer
Sourcepub async fn new(
socket_addr: SocketAddr,
allow_no_auth: bool,
auth: Box<dyn Fn(String, String) -> bool + Send>,
) -> SocksServer
pub async fn new( socket_addr: SocketAddr, allow_no_auth: bool, auth: Box<dyn Fn(String, String) -> bool + Send>, ) -> SocksServer
Creates and returns a new SocksServer
Sourcepub async fn serve(&mut self)
pub async fn serve(&mut self)
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§
impl !Freeze for SocksServer
impl !RefUnwindSafe for SocksServer
impl Send for SocksServer
impl Sync for SocksServer
impl Unpin for SocksServer
impl !UnwindSafe for SocksServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more