diff options
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 13 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 20 | ||||
| -rw-r--r-- | mullvad-ipc-client/src/lib.rs | 4 |
3 files changed, 37 insertions, 0 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 783954a3b2..bcb045f7c3 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -222,6 +222,9 @@ pub enum DaemonCommand { /// Remove process (PID) from list of processes excluded from the tunnel #[cfg(unix)] RemoveSplitTunnelProcess(oneshot::Sender<()>, i32), + /// Clear list of processes excluded from the tunnel + #[cfg(unix)] + ClearSplitTunnelProcesses(oneshot::Sender<()>), /// Makes the daemon exit the main loop and quit. Shutdown, /// Saves the target tunnel state and enters a blocking state. The state is restored @@ -1008,6 +1011,8 @@ where AddSplitTunnelProcess(tx, pid) => self.on_add_split_tunnel_process(tx, pid), #[cfg(unix)] RemoveSplitTunnelProcess(tx, pid) => self.on_remove_split_tunnel_process(tx, pid), + #[cfg(unix)] + ClearSplitTunnelProcesses(tx) => self.on_clear_split_tunnel_processes(tx), Shutdown => self.trigger_shutdown_event(), PrepareRestart => self.on_prepare_restart(), } @@ -1395,6 +1400,14 @@ where } } + #[cfg(unix)] + fn on_clear_split_tunnel_processes(&mut self, tx: oneshot::Sender<()>) { + match split::clear_pids() { + Ok(()) => Self::oneshot_send(tx, (), "clear_split_tunnel_processes response"), + Err(e) => error!("{}", e.display_chain_with_msg("Unable to clear PIDs")), + } + } + fn on_update_relay_settings(&mut self, tx: oneshot::Sender<()>, update: RelaySettingsUpdate) { let save_result = self.settings.update_relay_settings(update); match save_result { diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index 2839fc3d57..52d793d12f 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -190,6 +190,10 @@ build_rpc_trait! { #[rpc(meta, name = "remove_split_tunnel_process")] fn remove_split_tunnel_process(&self, Self::Metadata, i32) -> BoxFuture<(), Error>; + /// Clear list of processes to exclude from the tunnel + #[rpc(meta, name = "clear_split_tunnel_processes")] + fn clear_split_tunnel_processes(&self, Self::Metadata) -> BoxFuture<(), Error>; + #[pubsub(name = "daemon_event")] { /// Subscribes to events from the daemon. #[rpc(name = "daemon_event_subscribe")] @@ -799,6 +803,22 @@ impl ManagementInterfaceApi for ManagementInterface { } } + fn clear_split_tunnel_processes(&self, _: Self::Metadata) -> BoxFuture<(), Error> { + #[cfg(unix)] + { + log::debug!("clear_split_tunnel_processes"); + let (tx, rx) = sync::oneshot::channel(); + let future = self + .send_command_to_daemon(DaemonCommand::ClearSplitTunnelProcesses(tx)) + .and_then(|_| rx.map_err(|_| Error::internal_error())); + Box::new(future) + } + #[cfg(not(unix))] + { + Box::new(future::ok(())) + } + } + fn daemon_event_subscribe( &self, diff --git a/mullvad-ipc-client/src/lib.rs b/mullvad-ipc-client/src/lib.rs index 47a26c9b75..93817c7328 100644 --- a/mullvad-ipc-client/src/lib.rs +++ b/mullvad-ipc-client/src/lib.rs @@ -247,6 +247,10 @@ impl DaemonRpcClient { self.call("remove_split_tunnel_process", &[pid]) } + pub fn clear_split_tunnel_processes(&mut self) -> Result<()> { + self.call("clear_split_tunnel_processes", &NO_ARGS) + } + pub fn call<A, O>(&mut self, method: &'static str, args: &A) -> Result<O> where |
