mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 10:09:17 +08:00
Allow passing in an optional plugin_arg
This commit is contained in:
@@ -205,6 +205,7 @@ fn main() {
|
||||
let plugin = PluginConfig {
|
||||
plugin: p.to_owned(),
|
||||
plugin_opt: matches.value_of("PLUGIN_OPT").map(ToOwned::to_owned),
|
||||
plugin_arg: None,
|
||||
};
|
||||
|
||||
sc.set_plugin(plugin);
|
||||
|
||||
@@ -111,6 +111,7 @@ fn main() {
|
||||
let plugin = PluginConfig {
|
||||
plugin: p.to_owned(),
|
||||
plugin_opt: matches.value_of("PLUGIN_OPT").map(ToOwned::to_owned),
|
||||
plugin_arg: None,
|
||||
};
|
||||
|
||||
sc.set_plugin(plugin);
|
||||
|
||||
@@ -98,6 +98,8 @@ struct SSConfig {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
plugin_opts: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
plugin_arg: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
timeout: Option<u64>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
udp_timeout: Option<u64>,
|
||||
@@ -422,6 +424,7 @@ impl ServerConfig {
|
||||
plugin = Some(PluginConfig {
|
||||
plugin: p.to_owned(),
|
||||
plugin_opt: vsp.next().map(ToOwned::to_owned),
|
||||
plugin_arg: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1210,6 +1213,7 @@ impl Config {
|
||||
Some(plugin) => Some(PluginConfig {
|
||||
plugin,
|
||||
plugin_opt: config.plugin_opts,
|
||||
plugin_arg: config.plugin_arg,
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -1257,6 +1261,7 @@ impl Config {
|
||||
Some(p) => Some(PluginConfig {
|
||||
plugin: p,
|
||||
plugin_opt: svr.plugin_opts,
|
||||
plugin_arg: None,
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -1491,6 +1496,7 @@ impl fmt::Display for Config {
|
||||
jconf.password = Some(svr.password().to_string());
|
||||
jconf.plugin = svr.plugin().map(|p| p.plugin.to_string());
|
||||
jconf.plugin_opts = svr.plugin().and_then(|p| p.plugin_opt.clone());
|
||||
jconf.plugin_arg = svr.plugin().and_then(|p| p.plugin_arg.clone());
|
||||
jconf.timeout = svr.timeout().map(|t| t.as_secs());
|
||||
}
|
||||
_ => {
|
||||
|
||||
@@ -35,6 +35,7 @@ mod ss_plugin;
|
||||
pub struct PluginConfig {
|
||||
pub plugin: String,
|
||||
pub plugin_opt: Option<String>,
|
||||
pub plugin_arg: Option<String>,
|
||||
}
|
||||
|
||||
/// Mode of Plugin
|
||||
|
||||
@@ -25,5 +25,9 @@ pub fn plugin_cmd(plugin: &PluginConfig, remote: &ServerAddr, local: &SocketAddr
|
||||
cmd.env("SS_PLUGIN_OPTIONS", opt);
|
||||
}
|
||||
|
||||
if let Some(ref arg) = plugin.plugin_arg {
|
||||
cmd.arg(arg);
|
||||
}
|
||||
|
||||
cmd
|
||||
}
|
||||
|
||||
@@ -445,6 +445,7 @@ impl ManagerService {
|
||||
Some(pp) => Some(PluginConfig {
|
||||
plugin: pp,
|
||||
plugin_opt: p.plugin_opt,
|
||||
plugin_arg: None,
|
||||
}),
|
||||
None => None,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user