默认使用广播代替组播、精简依赖
This commit is contained in:
@@ -50,7 +50,8 @@ fn common() -> Command {
|
||||
Arg::new("tap")
|
||||
.long("tap")
|
||||
.help(switch_tap_help())
|
||||
.action(ArgAction::SetTrue),
|
||||
.action(ArgAction::SetTrue)
|
||||
.value_parser(BoolishValueParser::new()),
|
||||
).arg(
|
||||
Arg::new("in_ip")
|
||||
.long("in-ip")
|
||||
@@ -67,6 +68,12 @@ fn common() -> Command {
|
||||
.long("password")
|
||||
.help(switch_password_help())
|
||||
.action(ArgAction::Set)
|
||||
).arg(
|
||||
Arg::new("simulate_multicast")
|
||||
.long("simulate-multicast")
|
||||
.help(switch_simulate_multicast_help())
|
||||
.action(ArgAction::SetTrue)
|
||||
.value_parser(BoolishValueParser::new()),
|
||||
).arg(
|
||||
Arg::new("config")
|
||||
.long("config")
|
||||
|
||||
@@ -39,6 +39,7 @@ pub struct StartConfig {
|
||||
pub off_command_server: bool,
|
||||
pub log: bool,
|
||||
pub password: Option<String>,
|
||||
pub simulate_multicast:bool,
|
||||
}
|
||||
|
||||
fn ips_parse(ips: &Vec<String>) -> Result<Vec<(u32, u32, Ipv4Addr)>, String> {
|
||||
@@ -189,6 +190,7 @@ pub fn default_config(start_args: StartArgs) -> Result<StartConfig, String> {
|
||||
off_command_server: start_args.off_command_server,
|
||||
log: start_args.log,
|
||||
password: start_args.password,
|
||||
simulate_multicast:start_args.simulate_multicast,
|
||||
};
|
||||
println!("========参数配置========");
|
||||
Ok(base_config)
|
||||
@@ -296,7 +298,8 @@ pub fn read_config_file(config_path: PathBuf) -> Result<StartConfig, String> {
|
||||
#[cfg(any(unix))]
|
||||
off_command_server: args_config.off_command_server,
|
||||
log,
|
||||
password:args_config.password
|
||||
password:args_config.password,
|
||||
simulate_multicast:args_config.simulate_multicast
|
||||
};
|
||||
println!("========参数配置========");
|
||||
Ok(base_config)
|
||||
@@ -335,6 +338,8 @@ pub struct ArgsConfig {
|
||||
#[serde(default = "default_false")]
|
||||
pub log: bool,
|
||||
pub password: Option<String>,
|
||||
#[serde(default = "default_false")]
|
||||
pub simulate_multicast:bool,
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -360,6 +365,7 @@ impl ArgsConfig {
|
||||
#[cfg(any(unix))]
|
||||
off_command_server: start_config.off_command_server,
|
||||
password: start_config.password,
|
||||
simulate_multicast:start_config.simulate_multicast,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,9 @@ pub fn switch_out_ip_help() -> String {
|
||||
pub fn switch_password_help() -> String {
|
||||
rust_i18n::t!("switch_password_help")
|
||||
}
|
||||
pub fn switch_simulate_multicast_help() -> String {
|
||||
rust_i18n::t!("switch_simulate_multicast_help")
|
||||
}
|
||||
|
||||
pub fn switch_config_help() -> String {
|
||||
rust_i18n::t!("switch_config_help")
|
||||
|
||||
@@ -110,6 +110,9 @@ pub struct StartArgs {
|
||||
/// 客户端数据加密
|
||||
#[arg(long)]
|
||||
password:Option<String>,
|
||||
/// 模拟组播,默认情况下组播数据会被当作广播发送,兼容性更强,但是会造成流量浪费,开启后会模拟真实组播的数据发送
|
||||
#[arg(long)]
|
||||
simulate_multicast:bool,
|
||||
/// 读取配置文件 --config config_file_path
|
||||
/// Read configuration file
|
||||
#[arg(long)]
|
||||
|
||||
@@ -46,6 +46,7 @@ pub async fn main0(base_args: BaseArgs) {
|
||||
start_config.in_ips.clone(),
|
||||
start_config.out_ips.clone(),
|
||||
start_config.password.clone(),
|
||||
start_config.simulate_multicast,
|
||||
);
|
||||
let lock = match config::lock_file() {
|
||||
Ok(lock) => {
|
||||
|
||||
@@ -119,6 +119,7 @@ pub fn main0(base_args: BaseArgs) {
|
||||
start_config.in_ips,
|
||||
start_config.out_ips,
|
||||
start_config.password,
|
||||
start_config.simulate_multicast,
|
||||
);
|
||||
let lock = match config::lock_file() {
|
||||
Ok(lock) => {
|
||||
|
||||
@@ -171,6 +171,7 @@ async fn start_switch(arguments: Vec<OsString>) -> switch::Result<()> {
|
||||
start_config.in_ips,
|
||||
start_config.out_ips,
|
||||
start_config.password,
|
||||
start_config.simulate_multicast,
|
||||
);
|
||||
log::info!("switch-service服务启动");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user