From eb8ab7d1062951ce2eea471a626db1e2131b7558 Mon Sep 17 00:00:00 2001 From: Karan Gauswami Date: Sun, 18 Jun 2023 11:57:46 +0530 Subject: [PATCH] use clap feature for allowed domains --- src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 68a196a..825cddd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,8 +42,8 @@ struct Cli { socks_address: SocketAddr, /// Comma-separated list of allowed domains - #[arg(long)] - allowed_domains: Option, + #[arg(long, value_delimiter = ',')] + allowed_domains: Option>, } #[tokio::main] @@ -71,9 +71,7 @@ async fn main() -> Result<()> { }; let client: Client> = hyper::Client::builder().build(connector); let client = &*Box::leak(Box::new(client)); - let allowed_domains = args - .allowed_domains - .map(|domains| domains.split(',').map(|d| d.trim().to_owned()).collect()); + let allowed_domains = args.allowed_domains; let allowed_domains = &*Box::leak(Box::new(allowed_domains)); let make_service = make_service_fn(move |_| async move { Ok::<_, Infallible>(service_fn(move |req| {