diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-06-10 09:36:48 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-06-19 15:47:07 +0200 |
| commit | a33f5961780f4d3831fc4a1ddf72b433e3fb4740 (patch) | |
| tree | 9374debefa623b4d3fbe0e75af354c7925dd7bbe /talpid-core | |
| parent | 267087b3255e2748693d52728dadfdd69c6cb761 (diff) | |
| download | mullvadvpn-a33f5961780f4d3831fc4a1ddf72b433e3fb4740.tar.xz mullvadvpn-a33f5961780f4d3831fc4a1ddf72b433e3fb4740.zip | |
Add RPC for checking if split tunneling is available on Linux
Diffstat (limited to 'talpid-core')
| -rw-r--r-- | talpid-core/src/split_tunnel/linux.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/talpid-core/src/split_tunnel/linux.rs b/talpid-core/src/split_tunnel/linux.rs index dfbf8fc479..1efb1dc60b 100644 --- a/talpid-core/src/split_tunnel/linux.rs +++ b/talpid-core/src/split_tunnel/linux.rs @@ -3,7 +3,10 @@ use std::{ io::{self, BufRead, BufReader, Write}, path::{Path, PathBuf}, }; -use talpid_types::cgroup::{find_net_cls_mount, SPLIT_TUNNEL_CGROUP_NAME}; +use talpid_types::{ + cgroup::{find_net_cls_mount, SPLIT_TUNNEL_CGROUP_NAME}, + ErrorExt, +}; const DEFAULT_NET_CLS_DIR: &str = "/sys/fs/cgroup/net_cls"; const NET_CLS_DIR_OVERRIDE_ENV_VAR: &str = "TALPID_NET_CLS_MOUNT_DIR"; @@ -70,7 +73,10 @@ impl Default for PidManager { let inner = match Self::new_inner() { Ok(net_cls_path) => Inner::Ok { net_cls_path }, Err(err) => { - log::error!("{}", err.display_chain_with_msg("Failed to enable split tunneling")); + log::error!( + "{}", + err.display_chain_with_msg("Failed to enable split tunneling") + ); Inner::Failed { err } } }; @@ -197,6 +203,11 @@ impl PidManager { Ok(()) } + /// Return whether it is enabled + pub fn is_enabled(&self) -> bool { + matches!(self.inner, Inner::Ok { .. }) + } + fn open_parent_cgroup_handle(net_cls_path: &Path) -> io::Result<fs::File> { fs::OpenOptions::new() .write(true) |
