mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-21 14:29:10 +00:00
Replace shell-words with shlex.
This commit is contained in:
parent
5d5c8af55f
commit
a689b43ec4
2 changed files with 12 additions and 4 deletions
|
@ -53,7 +53,7 @@ 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"
|
||||||
shell-words = "1.1.0"
|
shlex = "1.3.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
args::{ArgDns, ArgProxy},
|
args::{ArgDns, ArgProxy},
|
||||||
ArgVerbosity, Args,
|
ArgVerbosity, Args,
|
||||||
};
|
};
|
||||||
use shell_words::split;
|
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);
|
||||||
|
|
||||||
|
@ -88,8 +88,16 @@ 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;
|
||||||
};
|
};
|
||||||
let args = <Args as ::clap::Parser>::parse_from(split(cli_args).expect("failed to split cli args"));
|
match split(cli_args) {
|
||||||
general_run_for_api(args, tun_mtu, packet_information)
|
Some(args) => {
|
||||||
|
let args = <Args as ::clap::Parser>::parse_from(args);
|
||||||
|
general_run_for_api(args, tun_mtu, packet_information)
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
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 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue