diff options
| -rw-r--r-- | mullvad-cli/src/cmds/split_tunnel/windows.rs | 8 | ||||
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 21 | ||||
| -rw-r--r-- | mullvad-daemon/src/settings.rs | 7 | ||||
| -rw-r--r-- | mullvad-management-interface/proto/management_interface.proto | 8 | ||||
| -rw-r--r-- | mullvad-management-interface/src/types.rs | 21 | ||||
| -rw-r--r-- | mullvad-types/src/settings/mod.rs | 20 |
6 files changed, 50 insertions, 35 deletions
diff --git a/mullvad-cli/src/cmds/split_tunnel/windows.rs b/mullvad-cli/src/cmds/split_tunnel/windows.rs index 5f6fa8878e..3d1dd5ee1d 100644 --- a/mullvad-cli/src/cmds/split_tunnel/windows.rs +++ b/mullvad-cli/src/cmds/split_tunnel/windows.rs @@ -102,7 +102,13 @@ impl SplitTunnel { async fn get(&self) -> Result<()> { let mut rpc = new_rpc_client().await?; - let enabled = rpc.get_settings(()).await?.into_inner().split_tunnel; + let enabled = rpc + .get_settings(()) + .await? + .into_inner() + .split_tunnel + .unwrap() + .enable_exclusions; println!( "Split tunnel status: {}", if enabled { "on" } else { "off" } diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 013b3453db..c901d45767 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -657,9 +657,10 @@ where TransportProtocol::Tcp, ); #[cfg(windows)] - let exclude_apps = if settings.split_tunnel { + let exclude_apps = if settings.split_tunnel.enable_exclusions { settings - .split_tunnel_apps + .split_tunnel + .apps .iter() .map(|s| OsString::from(s)) .collect() @@ -1763,7 +1764,7 @@ where fn on_get_split_tunnel_apps(&mut self, tx: oneshot::Sender<HashSet<PathBuf>>) { Self::oneshot_send( tx, - self.settings.to_settings().split_tunnel_apps, + self.settings.to_settings().split_tunnel.apps, "get_split_tunnel_apps response", ); } @@ -1777,12 +1778,12 @@ where settings: Settings, new_list: HashSet<PathBuf>, ) { - if new_list == settings.split_tunnel_apps { + if new_list == settings.split_tunnel.apps { Self::oneshot_send(tx, Ok(()), response_msg); return; } - if settings.split_tunnel { + if settings.split_tunnel.enable_exclusions { let (result_tx, result_rx) = oneshot::channel(); self.send_tunnel_command(TunnelCommand::SetExcludedApps( result_tx, @@ -1830,7 +1831,7 @@ where async fn on_add_split_tunnel_app(&mut self, tx: ResponseTx<(), Error>, path: PathBuf) { let settings = self.settings.to_settings(); - let mut new_list = settings.split_tunnel_apps.clone(); + let mut new_list = settings.split_tunnel.apps.clone(); new_list.insert(path); self.set_split_tunnel_paths(tx, "add_split_tunnel_app response", settings, new_list) @@ -1841,7 +1842,7 @@ where async fn on_remove_split_tunnel_app(&mut self, tx: ResponseTx<(), Error>, path: PathBuf) { let settings = self.settings.to_settings(); - let mut new_list = settings.split_tunnel_apps.clone(); + let mut new_list = settings.split_tunnel.apps.clone(); new_list.remove(&path); self.set_split_tunnel_paths(tx, "remove_split_tunnel_app response", settings, new_list) @@ -1860,13 +1861,13 @@ where async fn on_set_split_tunnel_state(&mut self, tx: ResponseTx<(), Error>, enabled: bool) { let settings = self.settings.to_settings(); - if enabled != settings.split_tunnel { + if enabled != settings.split_tunnel.enable_exclusions { let new_list = if enabled { - settings.split_tunnel_apps.clone() + settings.split_tunnel.apps.clone() } else { HashSet::new() }; - if !settings.split_tunnel_apps.is_empty() { + if !settings.split_tunnel.apps.is_empty() { let (result_tx, result_rx) = oneshot::channel(); self.send_tunnel_command(TunnelCommand::SetExcludedApps( result_tx, diff --git a/mullvad-daemon/src/settings.rs b/mullvad-daemon/src/settings.rs index 1499ddab53..8940a1a0a8 100644 --- a/mullvad-daemon/src/settings.rs +++ b/mullvad-daemon/src/settings.rs @@ -316,16 +316,17 @@ impl SettingsPersister { #[cfg(windows)] pub async fn set_split_tunnel_apps(&mut self, paths: HashSet<PathBuf>) -> Result<bool, Error> { - let should_save = paths != self.settings.split_tunnel_apps; + let should_save = paths != self.settings.split_tunnel.apps; if should_save { - self.settings.split_tunnel_apps = paths; + self.settings.split_tunnel.apps = paths; } self.update(should_save).await } #[cfg(windows)] pub async fn set_split_tunnel_state(&mut self, enabled: bool) -> Result<bool, Error> { - let should_save = Self::update_field(&mut self.settings.split_tunnel, enabled); + let should_save = + Self::update_field(&mut self.settings.split_tunnel.enable_exclusions, enabled); self.update(should_save).await } diff --git a/mullvad-management-interface/proto/management_interface.proto b/mullvad-management-interface/proto/management_interface.proto index 39bfa20669..617a5ab827 100644 --- a/mullvad-management-interface/proto/management_interface.proto +++ b/mullvad-management-interface/proto/management_interface.proto @@ -270,8 +270,12 @@ message Settings { bool auto_connect = 7; TunnelOptions tunnel_options = 8; bool show_beta_releases = 9; - bool split_tunnel = 10; - repeated string split_tunnel_apps = 11; + SplitTunnelSettings split_tunnel = 10; +} + +message SplitTunnelSettings { + bool enable_exclusions = 1; + repeated string apps = 2; } message RelaySettings { diff --git a/mullvad-management-interface/src/types.rs b/mullvad-management-interface/src/types.rs index abd0b3a17c..11547887a4 100644 --- a/mullvad-management-interface/src/types.rs +++ b/mullvad-management-interface/src/types.rs @@ -364,9 +364,9 @@ impl From<mullvad_types::relay_constraints::LocationConstraint> for RelayLocatio impl From<&mullvad_types::settings::Settings> for Settings { fn from(settings: &mullvad_types::settings::Settings) -> Self { #[cfg(windows)] - let split_tunnel_apps = { + let split_tunnel = { let mut converted_list = vec![]; - for path in settings.split_tunnel_apps.clone().iter() { + for path in settings.split_tunnel.apps.clone().iter() { match path.as_path().as_os_str().to_str() { Some(path) => converted_list.push(path.to_string()), None => { @@ -374,8 +374,14 @@ impl From<&mullvad_types::settings::Settings> for Settings { } } } - converted_list + + Some(SplitTunnelSettings { + enable_exclusions: settings.split_tunnel.enable_exclusions, + apps: converted_list, + }) }; + #[cfg(not(windows))] + let split_tunnel = None; Self { account_token: settings.get_account_token().unwrap_or_default(), @@ -387,14 +393,7 @@ impl From<&mullvad_types::settings::Settings> for Settings { auto_connect: settings.auto_connect, tunnel_options: Some(TunnelOptions::from(&settings.tunnel_options)), show_beta_releases: settings.show_beta_releases, - #[cfg(windows)] - split_tunnel: settings.split_tunnel, - #[cfg(windows)] - split_tunnel_apps, - #[cfg(not(windows))] - split_tunnel: false, - #[cfg(not(windows))] - split_tunnel_apps: Vec::new(), + split_tunnel, } } } diff --git a/mullvad-types/src/settings/mod.rs b/mullvad-types/src/settings/mod.rs index bfcffe878a..a15cb8fa61 100644 --- a/mullvad-types/src/settings/mod.rs +++ b/mullvad-types/src/settings/mod.rs @@ -60,17 +60,23 @@ pub struct Settings { pub tunnel_options: TunnelOptions, /// Whether to notify users of beta updates. pub show_beta_releases: bool, - /// Whether to enable split tunneling for [`Settings::split_tunnel_apps`]. + /// Split tunneling settings #[cfg(windows)] - pub split_tunnel: bool, - /// List of applications to exclude from the tunnel. - #[cfg(windows)] - pub split_tunnel_apps: HashSet<PathBuf>, + pub split_tunnel: SplitTunnelSettings, /// Specifies settings schema version #[cfg_attr(target_os = "android", jnix(skip))] settings_version: migrations::SettingsVersion, } +#[cfg(windows)] +#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)] +pub struct SplitTunnelSettings { + /// Toggles split tunneling on or off + pub enable_exclusions: bool, + /// List of applications to exclude from the tunnel. + pub apps: HashSet<PathBuf>, +} + impl Default for Settings { fn default() -> Self { Settings { @@ -88,9 +94,7 @@ impl Default for Settings { tunnel_options: TunnelOptions::default(), show_beta_releases: false, #[cfg(windows)] - split_tunnel: false, - #[cfg(windows)] - split_tunnel_apps: HashSet::new(), + split_tunnel: SplitTunnelSettings::default(), settings_version: migrations::CURRENT_SETTINGS_VERSION, } } |
