diff --git a/README.md b/README.md index 1957813..8e416b2 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,15 @@ This will create proxy server on 8080 and use localhost:1080 as a Socks5 Proxy There are a few options for using `sthp`. ```text -USAGE: - sthp [OPTIONS] - -OPTIONS: - -h, --help Print help information - --listen-ip [default: 0.0.0.0] - -p, --port port where Http proxy should listen [default: 8080] - -P, --password Socks5 password - -s, --socks-address Socks5 proxy address [default: 127.0.0.1:1080] - -u, --username Socks5 username - -V, --version Print version information +Usage: sthp [OPTIONS] + +Options: + -p, --port port where Http proxy should listen [default: 8080] + --listen-ip [default: 0.0.0.0] + -u, --username Socks5 username + -P, --password Socks5 password + -s, --socks-address Socks5 proxy address [default: 127.0.0.1:1080] + --allowed-domains Comma-separated list of allowed domains + -h, --help Print help information + -V, --version Print version information ``` diff --git a/src/main.rs b/src/main.rs index 94e96b0..68a196a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,10 +55,9 @@ async fn main() -> Result<()> { let socks_address = args.socks_address; let port = args.port; - let auth = match args.auth { - Some(auth) => Some(Auth::new(auth.username, auth.password)), - None => None, - }; + let auth = args + .auth + .map(|auth| Auth::new(auth.username, auth.password)); let auth = &*Box::leak(Box::new(auth)); let addr = SocketAddr::from((args.listen_ip, port)); @@ -72,10 +71,9 @@ async fn main() -> Result<()> { }; let client: Client> = hyper::Client::builder().build(connector); let client = &*Box::leak(Box::new(client)); - let allowed_domains = match args.allowed_domains { - Some(domains) => Some(domains.split(',').map(|d| d.trim().to_owned()).collect()), - None => None, - }; + let allowed_domains = args + .allowed_domains + .map(|domains| domains.split(',').map(|d| d.trim().to_owned()).collect()); let allowed_domains = &*Box::leak(Box::new(allowed_domains)); let make_service = make_service_fn(move |_| async move { Ok::<_, Infallible>(service_fn(move |req| {