minor changes

This commit is contained in:
ssrlive 2025-01-07 20:56:25 +08:00
parent a689b43ec4
commit 91a0c75d62
2 changed files with 8 additions and 12 deletions

View file

@ -42,6 +42,7 @@ ipstack = { version = "0.1" }
log = { version = "0.4", features = ["std"] } log = { version = "0.4", features = ["std"] }
mimalloc = { version = "0.1", default-features = false, optional = true } mimalloc = { version = "0.1", default-features = false, optional = true }
percent-encoding = "2" percent-encoding = "2"
shlex = "1.3.0"
socks5-impl = { version = "0.6", default-features = false, features = [ socks5-impl = { version = "0.6", default-features = false, features = [
"tokio", "tokio",
] } ] }
@ -53,7 +54,6 @@ tun = { version = "0.7", features = ["async"] }
udp-stream = { version = "0.0.12", default-features = false } udp-stream = { version = "0.0.12", default-features = false }
unicase = "2" unicase = "2"
url = "2" url = "2"
shlex = "1.3.0"
[build-dependencies] [build-dependencies]
serde_json = "1" serde_json = "1"

View file

@ -2,8 +2,8 @@ use crate::{
args::{ArgDns, ArgProxy}, args::{ArgDns, ArgProxy},
ArgVerbosity, Args, ArgVerbosity, Args,
}; };
use shlex::split;
use std::os::raw::{c_char, c_int, c_ushort}; use std::os::raw::{c_char, c_int, c_ushort};
static TUN_QUIT: std::sync::Mutex<Option<tokio_util::sync::CancellationToken>> = std::sync::Mutex::new(None); static TUN_QUIT: std::sync::Mutex<Option<tokio_util::sync::CancellationToken>> = std::sync::Mutex::new(None);
/// # Safety /// # Safety
@ -88,16 +88,12 @@ pub unsafe extern "C" fn tun2proxy_run_with_cli_args(cli_args: *const c_char, tu
let Ok(cli_args) = std::ffi::CStr::from_ptr(cli_args).to_str() else { let Ok(cli_args) = std::ffi::CStr::from_ptr(cli_args).to_str() else {
return -5; return -5;
}; };
match split(cli_args) { let Some(args) = shlex::split(cli_args) else {
Some(args) => { log::error!("Failed to split CLI arguments");
let args = <Args as ::clap::Parser>::parse_from(args); return -6;
general_run_for_api(args, tun_mtu, packet_information) };
} let args = <Args as ::clap::Parser>::parse_from(args);
None => { general_run_for_api(args, tun_mtu, packet_information)
log::error!("Failed to split CLI arguments");
-6
}
}
} }
pub fn general_run_for_api(args: Args, tun_mtu: u16, packet_information: bool) -> c_int { pub fn general_run_for_api(args: Args, tun_mtu: u16, packet_information: bool) -> c_int {