37 lines
789 B
Rust
37 lines
789 B
Rust
|
mod config;
|
||
|
mod error;
|
||
|
mod handler;
|
||
|
// mod host;
|
||
|
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(())
|
||
|
}
|