2024-10-18 17:40:04 +03:00
|
|
|
mod config;
|
|
|
|
mod error;
|
|
|
|
mod handler;
|
2024-10-18 20:42:08 +03:00
|
|
|
mod host;
|
2024-10-18 17:40:04 +03:00
|
|
|
mod serde_addr;
|
|
|
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
use error::AppResult;
|
|
|
|
use handler::handler;
|
|
|
|
|
|
|
|
use socks5_server as socks;
|
|
|
|
use tokio::net::TcpListener;
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> AppResult<()> {
|
|
|
|
let config = Arc::new(config::parse()?);
|
|
|
|
let auth = Arc::new(socks::auth::NoAuth);
|
|
|
|
|
|
|
|
let listener = TcpListener::bind((config.host.as_str(), config.port)).await?;
|
|
|
|
let server = socks::Server::new(listener, auth);
|
|
|
|
|
|
|
|
while let Ok((conn, _addr)) = server.accept().await {
|
|
|
|
let config = config.clone();
|
|
|
|
tokio::spawn(async move {
|
|
|
|
match handler(conn, config).await {
|
|
|
|
Ok(()) => {}
|
|
|
|
Err(e) => {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|