summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/process/openvpn.rs7
-rw-r--r--talpid_cli/src/cli.rs14
-rw-r--r--talpid_cli/src/main.rs2
3 files changed, 19 insertions, 4 deletions
diff --git a/src/process/openvpn.rs b/src/process/openvpn.rs
index 48da508f75..a6af4742c3 100644
--- a/src/process/openvpn.rs
+++ b/src/process/openvpn.rs
@@ -171,14 +171,16 @@ pub enum OpenVpnEvent {
/// A struct able to start and monitor OpenVPN processes.
pub struct OpenVpnMonitor {
command: OpenVpnCommand,
+ plugin_path: PathBuf,
monitor: ChildMonitor<OpenVpnCommand>,
}
impl OpenVpnMonitor {
/// Creates a new `OpenVpnMonitor` based on the given command
- pub fn new(command: OpenVpnCommand) -> Self {
+ pub fn new<P: AsRef<Path>>(command: OpenVpnCommand, plugin_path: P) -> Self {
OpenVpnMonitor {
command: command.clone(),
+ plugin_path: plugin_path.as_ref().to_path_buf(),
monitor: ChildMonitor::new(command),
}
}
@@ -200,8 +202,7 @@ impl OpenVpnMonitor {
let mut listener = shared_listener.lock().unwrap();
(listener.deref_mut())(OpenVpnEvent::PluginEvent(chained_msg));
}).chain_err(|| ErrorKind::PluginCommunicationError)?;
- self.command.plugin("./target/debug/libtalpid_openvpn_plugin.so",
- vec![server_id]);
+ self.command.plugin(&self.plugin_path, vec![server_id]);
Ok(())
}
diff --git a/talpid_cli/src/cli.rs b/talpid_cli/src/cli.rs
index d6d5899846..79a13d94c2 100644
--- a/talpid_cli/src/cli.rs
+++ b/talpid_cli/src/cli.rs
@@ -3,8 +3,17 @@ use std::path::PathBuf;
use talpid_core::net::RemoteAddr;
+#[cfg(all(unix, not(target_os="macos")))]
+const DEFAULT_PLUGIN_PATH: &'static str = "./target/debug/libtalpid_openvpn_plugin.so";
+#[cfg(target_os="macos")]
+const DEFAULT_PLUGIN_PATH: &'static str = "./target/debug/libtalpid_openvpn_plugin.dylib";
+#[cfg(windows)]
+const DEFAULT_PLUGIN_PATH: &'static str = "./target/debug/libtalpid_openvpn_plugin.dll";
+
+
pub struct Args {
pub binary: String,
+ pub plugin_path: PathBuf,
pub config: PathBuf,
pub remotes: Vec<RemoteAddr>,
pub verbosity: u64,
@@ -15,6 +24,7 @@ pub fn parse_args_or_exit() -> Args {
let remotes = values_t!(matches.values_of("remotes"), RemoteAddr).unwrap_or_else(|e| e.exit());
Args {
binary: matches.value_of("openvpn").unwrap().to_owned(),
+ plugin_path: PathBuf::from(matches.value_of("plugin").unwrap()),
config: PathBuf::from(matches.value_of("config").unwrap()),
remotes: remotes,
verbosity: matches.occurrences_of("verbose"),
@@ -48,6 +58,10 @@ fn create_app() -> App<'static, 'static> {
.takes_value(true)
.multiple(true)
.required(true))
+ .arg(Arg::with_name("plugin")
+ .long("plugin")
+ .help("Path to talpid plugin")
+ .default_value(DEFAULT_PLUGIN_PATH))
.arg(Arg::with_name("verbose")
.short("v")
.long("verbose")
diff --git a/talpid_cli/src/main.rs b/talpid_cli/src/main.rs
index ae8be2eed5..9bb7cfdc96 100644
--- a/talpid_cli/src/main.rs
+++ b/talpid_cli/src/main.rs
@@ -49,7 +49,7 @@ fn run() -> Result<()> {
init_logger()?;
let args = cli::parse_args_or_exit();
let command = create_openvpn_command(&args);
- let monitor = OpenVpnMonitor::new(command);
+ let monitor = OpenVpnMonitor::new(command, args.plugin_path);
main_loop(monitor)
}