From a08dab4c3ae985bd3df1d5219827c57548cdd6ab Mon Sep 17 00:00:00 2001 From: GoogleGeek Date: Sun, 16 Jun 2024 10:51:56 +0800 Subject: [PATCH] fix --no-httpauth parser on true/false --- README.md | 2 +- src/main.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ee3183c..b01a403 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Options: -u, --username Socks5 username -P, --password Socks5 password --http-basic HTTP Basic Auth - --no-httpauth ignore HTTP Basic Auth, [default: true] + --no-httpauth <1/0> Ignore HTTP Basic Auth, [default: 1] -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 diff --git a/src/main.rs b/src/main.rs index 01108ee..3d85b8f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ mod auth; use crate::auth::Auth; -use clap::{Args, Parser}; +use clap::{Args, Parser, value_parser}; use color_eyre::eyre::Result; use tokio_socks::tcp::Socks5Stream; @@ -61,9 +61,9 @@ struct Cli { #[arg(long)] http_basic: Option, - /// Disable HTTP authentication [default: true] - #[arg(long, default_value_t = true)] - no_httpauth: bool, + /// Disable HTTP authentication [default: 1] + #[arg(long, value_parser = value_parser ! (u8).range(0..=1), default_value_t = 1)] + no_httpauth: u8, } #[tokio::main] @@ -85,7 +85,7 @@ async fn main() -> Result<()> { let allowed_domains = &*Box::leak(Box::new(allowed_domains)); let http_basic = args.http_basic.map(|hb| format!("Basic {}", general_purpose::STANDARD.encode(hb))); let http_basic = &*Box::leak(Box::new(http_basic)); - let no_httpauth = args.no_httpauth; + let no_httpauth = args.no_httpauth == 1; let listener = TcpListener::bind(addr).await?; info!("Listening on http://{}", addr);