diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-03-05 18:53:44 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-03-09 10:44:48 -0300 |
| commit | deefd4c50fe7e9eeab0c024bc2bfba9ae0c485b8 (patch) | |
| tree | 98257f88e6d0a94e004faa8d14eb0277f65cda73 /mullvad-daemon/src/main.rs | |
| parent | 19c201146b2f22db13123f47d7bb042991051583 (diff) | |
| download | mullvadvpn-deefd4c50fe7e9eeab0c024bc2bfba9ae0c485b8.tar.xz mullvadvpn-deefd4c50fe7e9eeab0c024bc2bfba9ae0c485b8.zip | |
Only run one instance of daemon
Before the RPC server is started, check if there is already another
instance of the daemon running. If there is, and it appears to be
responding correctly, don't start the daemon again.
Diffstat (limited to 'mullvad-daemon/src/main.rs')
| -rw-r--r-- | mullvad-daemon/src/main.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index 50fc5d1991..f07138b8ff 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -84,6 +84,9 @@ use std::fs; error_chain!{ errors { + DaemonIsAlreadyRunning { + description("Another instance of the daemon is already running") + } /// The client is in the wrong state for the requested operation. Optimally the code should /// be written in such a way so such states can't exist. InvalidState { @@ -284,6 +287,11 @@ impl Daemon { event_tx: IntoSender<TunnelCommand, DaemonEvent>, require_auth: bool, ) -> Result<ManagementInterfaceServer> { + ensure!( + !rpc_info::is_another_instance_running(), + ErrorKind::DaemonIsAlreadyRunning + ); + let shared_secret = if require_auth { Some(uuid::Uuid::new_v4().to_string()) } else { |
