From 3b907146d136b3c37006a7d8d403c20523c7e0a6 Mon Sep 17 00:00:00 2001 From: sabraman Date: Sun, 22 Mar 2026 23:05:41 +0300 Subject: [PATCH] reject unknown init options before setup --- src/cli.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index 6dc0e2a..14fd981 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -7,11 +7,17 @@ use std::process::Command; /// Options for the init command pub struct InitOptions { + /// Listen port for the generated proxy configuration. pub port: u16, + /// TLS masking domain written into the generated configuration. pub domain: String, + /// Optional user-provided MTProxy secret in hex form. pub secret: Option, + /// Username inserted into the generated access configuration. pub username: String, + /// Destination directory for the generated config file. pub config_dir: PathBuf, + /// Skips starting the systemd service after installation. pub no_start: bool, } @@ -41,6 +47,7 @@ pub fn parse_init_args(args: &[String]) -> Option { while i < args.len() { match args[i].as_str() { + "--init" => {} "--port" => { i += 1; if i < args.len() { @@ -74,6 +81,10 @@ pub fn parse_init_args(args: &[String]) -> Option { "--no-start" => { opts.no_start = true; } + other if other.starts_with('-') => { + eprintln!("[error] Unknown option for --init: {}", other); + std::process::exit(1); + } _ => {} } i += 1;