diff options
| -rw-r--r-- | talpid-core/src/tunnel/mod.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs index 3835e26632..407c774d35 100644 --- a/talpid-core/src/tunnel/mod.rs +++ b/talpid-core/src/tunnel/mod.rs @@ -2,6 +2,7 @@ use mktemp; use net; use openvpn_plugin::types::OpenVpnPluginEvent; use process::openvpn::OpenVpnCommand; +use std::ffi::{OsStr, OsString}; use std::fs; use std::io::{self, Write}; use std::path::{Path, PathBuf}; @@ -84,7 +85,9 @@ impl TunnelMonitor { } fn create_openvpn_cmd(remote: net::Endpoint, user_pass_file: &Path) -> OpenVpnCommand { - let mut cmd = OpenVpnCommand::new("openvpn"); + let openvpn_binary = Self::find_path_to_openvpn_binary(); + + let mut cmd = OpenVpnCommand::new(openvpn_binary); if let Some(config) = get_config_path() { cmd.config(config); } @@ -92,6 +95,25 @@ impl TunnelMonitor { cmd } + fn find_path_to_openvpn_binary() -> OsString { + match ::std::env::current_exe() { + Ok(mut path) => { + path.pop(); + + path.push("openvpn-binaries"); + + let openvpn_binary = path.join("openvpn"); + if openvpn_binary.exists() { + return openvpn_binary.into_os_string(); + } + } + Err(e) => warn!("Failed finding the directory of the executable, {}", e), + } + + debug!("Did not find a bundled version of OpenVPN, will rely on the PATH instead"); + OsStr::new("openvpn").to_os_string() + } + fn create_user_pass_file(account_token: &str) -> io::Result<mktemp::Temp> { let path = mktemp::Temp::new_file()?; debug!( |
