Validate bind address in CLI

Added validation for bind address in main function.
This commit is contained in:
Saikari 2026-03-25 10:57:57 +03:00 committed by GitHub
parent 1f4133e13c
commit 5a881798fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -1,4 +1,5 @@
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use std::net::IpAddr;
use clap::Parser; use clap::Parser;
use tg_unblock::{bypass, network, ws_proxy}; use tg_unblock::{bypass, network, ws_proxy};
@ -22,6 +23,12 @@ struct Args {
fn main() { fn main() {
let args = Args::parse(); let args = Args::parse();
// Validate bind address early
if args.bind.parse::<IpAddr>().is_err() {
eprintln!("[!] Неверный адрес привязки: {}", args.bind);
std::process::exit(1);
}
let is_admin = bypass::check_admin(); let is_admin = bypass::check_admin();
let mut dns_was_set = false; let mut dns_was_set = false;
let mut adapter_name: Option<String> = None; let mut adapter_name: Option<String> = None;