summaryrefslogtreecommitdiffhomepage
path: root/mullvad-daemon/src
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-02-28 11:28:42 +0100
committerDavid Lönnhager <david.l@mullvad.net>2020-06-02 10:05:01 +0200
commit2691bd8622876b2884d7c6be2100883ba225a657 (patch)
tree0fdb6edc9b4731ca71670b65413ad99515838386 /mullvad-daemon/src
parent9d783fcb730faddf8fd6d45957d6e7c78062444f (diff)
downloadmullvadvpn-2691bd8622876b2884d7c6be2100883ba225a657.tar.xz
mullvadvpn-2691bd8622876b2884d7c6be2100883ba225a657.zip
Add IPC call for split::clear_pids()
Diffstat (limited to 'mullvad-daemon/src')
-rw-r--r--mullvad-daemon/src/lib.rs13
-rw-r--r--mullvad-daemon/src/management_interface.rs20
2 files changed, 33 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,