diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-11-14 05:26:05 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-11-14 06:10:44 +0100 |
| commit | 3068edb2ecb9d7440dbcd7523434400294b1e8de (patch) | |
| tree | 4f2fecf7e8e99428b47cbd5b4be1c11f732f2c6a /mullvad-daemon/src | |
| parent | 434b5343f74fa35364f482e24248de4cf7e85d16 (diff) | |
| download | mullvadvpn-3068edb2ecb9d7440dbcd7523434400294b1e8de.tar.xz mullvadvpn-3068edb2ecb9d7440dbcd7523434400294b1e8de.zip | |
Move finding resource dir to top
Diffstat (limited to 'mullvad-daemon/src')
| -rw-r--r-- | mullvad-daemon/src/main.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index 5b17a67be4..a5ea07cabd 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -55,6 +55,7 @@ use mullvad_types::relay_endpoint::RelayEndpoint; use mullvad_types::states::{DaemonState, SecurityState, TargetState}; use rand::Rng; +use std::env; use std::io; use std::net::Ipv4Addr; use std::path::PathBuf; @@ -185,6 +186,7 @@ struct Daemon { // Just for testing. A cyclic iterator iterating over the hardcoded relays, // picking a new one for each retry. relay_iter: std::iter::Cycle<std::iter::Cloned<std::slice::Iter<'static, Endpoint>>>, + resource_dir: PathBuf, } impl Daemon { @@ -193,6 +195,7 @@ impl Daemon { let management_interface_broadcaster = Self::start_management_interface(tx.clone())?; let state = TunnelState::NotRunning; let target_state = TargetState::Unsecured; + let resource_dir = get_resource_dir(); Ok(Daemon { state, tunnel_close_handle: None, @@ -212,6 +215,7 @@ impl Daemon { tunnel_metadata: None, tunnel_log: tunnel_log, relay_iter: RELAYS.iter().cloned().cycle(), + resource_dir, }) } @@ -580,6 +584,7 @@ impl Daemon { tunnel_endpoint, account_token, self.tunnel_log.as_ref().map(PathBuf::as_path), + &self.resource_dir, on_tunnel_event, ).chain_err(|| ErrorKind::TunnelError("Unable to start tunnel monitor")) } @@ -734,3 +739,19 @@ fn randomize_port(protocol: TransportProtocol) -> u16 { .choose(&pool) .expect("no ports to randomize from") } + +fn get_resource_dir() -> PathBuf { + match env::current_exe() { + Ok(mut path) => { + path.pop(); + path + } + Err(e) => { + error!( + "Failed finding the directory of the executable. Using working directory: {}", + e + ); + PathBuf::from(".") + } + } +} |
