Files
shadowsocks-rust/src/plugin/ss_plugin.rs
T
Y. T. Chung eb580be25a Style and wording improvement
1. Remove Emails
2. Better log for timed out
3. Properly log plugin listening address in server mode
4. Use latest rustfmt and new style configuration
2017-07-24 09:05:41 +08:00

31 lines
812 B
Rust

use std::net::SocketAddr;
use subprocess::{Exec, NullFile, Popen};
use subprocess::Result as PopenResult;
use config::ServerAddr;
use super::{PluginConfig, PluginMode};
pub fn start_plugin(
plugin: &PluginConfig,
remote: &ServerAddr,
local: &SocketAddr,
_mode: PluginMode,
) -> PopenResult<Popen> {
trace!("Start plugin \"{:?}\" remote: {}, local: {}", plugin, remote, local);
let mut exec = Exec::cmd(&plugin.plugin)
.env("SS_REMOTE_HOST", remote.host())
.env("SS_REMOTE_PORT", remote.port().to_string())
.env("SS_LOCAL_HOST", local.ip().to_string())
.env("SS_LOCAL_PORT", local.port().to_string())
.stdin(NullFile);
if let Some(ref opt) = plugin.plugin_opt {
exec = exec.env("SS_PLUGIN_OPTIONS", opt);
}
exec.popen()
}