summaryrefslogtreecommitdiffhomepage
path: root/mullvad-daemon/src/lib.rs
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-02-27 10:22:54 +0100
committerDavid Lönnhager <david.l@mullvad.net>2020-06-02 10:05:01 +0200
commit5bb52620f9b7bbbc0bd24bfe03e4cfcfb5a0b16a (patch)
tree2038f1c4a0d8c9e71622907c0944e92749fa381c /mullvad-daemon/src/lib.rs
parent39c1a12c5c7f234fe32f397d93d60eb49234cfa1 (diff)
downloadmullvadvpn-5bb52620f9b7bbbc0bd24bfe03e4cfcfb5a0b16a.tar.xz
mullvadvpn-5bb52620f9b7bbbc0bd24bfe03e4cfcfb5a0b16a.zip
Add IPC functions for managing split tunneling
Diffstat (limited to 'mullvad-daemon/src/lib.rs')
-rw-r--r--mullvad-daemon/src/lib.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs
index cd9ddd39a1..783954a3b2 100644
--- a/mullvad-daemon/src/lib.rs
+++ b/mullvad-daemon/src/lib.rs
@@ -57,6 +57,7 @@ use std::{
};
use talpid_core::{
mpsc::Sender,
+ split,
tunnel_state_machine::{self, TunnelCommand, TunnelParametersGenerator},
};
#[cfg(target_os = "android")]
@@ -212,6 +213,15 @@ pub enum DaemonCommand {
/// Remove settings and clear the cache
#[cfg(not(target_os = "android"))]
FactoryReset(oneshot::Sender<()>),
+ /// Request list of processes excluded from the tunnel
+ #[cfg(unix)]
+ GetSplitTunnelProcesses(oneshot::Sender<Vec<i32>>),
+ /// Exclude traffic of a process (PID) from the tunnel
+ #[cfg(unix)]
+ AddSplitTunnelProcess(oneshot::Sender<()>, i32),
+ /// Remove process (PID) from list of processes excluded from the tunnel
+ #[cfg(unix)]
+ RemoveSplitTunnelProcess(oneshot::Sender<()>, i32),
/// Makes the daemon exit the main loop and quit.
Shutdown,
/// Saves the target tunnel state and enters a blocking state. The state is restored
@@ -992,6 +1002,12 @@ where
GetCurrentVersion(tx) => self.on_get_current_version(tx),
#[cfg(not(target_os = "android"))]
FactoryReset(tx) => self.on_factory_reset(tx),
+ #[cfg(unix)]
+ GetSplitTunnelProcesses(tx) => self.on_get_split_tunnel_processes(tx),
+ #[cfg(unix)]
+ AddSplitTunnelProcess(tx, pid) => self.on_add_split_tunnel_process(tx, pid),
+ #[cfg(unix)]
+ RemoveSplitTunnelProcess(tx, pid) => self.on_remove_split_tunnel_process(tx, pid),
Shutdown => self.trigger_shutdown_event(),
PrepareRestart => self.on_prepare_restart(),
}
@@ -1355,6 +1371,30 @@ where
}));
}
+ #[cfg(unix)]
+ fn on_get_split_tunnel_processes(&mut self, tx: oneshot::Sender<Vec<i32>>) {
+ match split::list_pids() {
+ Ok(pids) => Self::oneshot_send(tx, pids, "get_split_tunnel_processes response"),
+ Err(e) => error!("{}", e.display_chain_with_msg("Unable to obtain PIDs")),
+ }
+ }
+
+ #[cfg(unix)]
+ fn on_add_split_tunnel_process(&mut self, tx: oneshot::Sender<()>, pid: i32) {
+ match split::add_pid(pid) {
+ Ok(()) => Self::oneshot_send(tx, (), "add_split_tunnel_process response"),
+ Err(e) => error!("{}", e.display_chain_with_msg("Unable to add PID")),
+ }
+ }
+
+ #[cfg(unix)]
+ fn on_remove_split_tunnel_process(&mut self, tx: oneshot::Sender<()>, pid: i32) {
+ match split::remove_pid(pid) {
+ Ok(()) => Self::oneshot_send(tx, (), "remove_split_tunnel_process response"),
+ Err(e) => error!("{}", e.display_chain_with_msg("Unable to remove PID")),
+ }
+ }
+
fn on_update_relay_settings(&mut self, tx: oneshot::Sender<()>, update: RelaySettingsUpdate) {
let save_result = self.settings.update_relay_settings(update);
match save_result {