diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-02-05 13:02:48 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-02-05 13:02:48 +0100 |
| commit | 958111e268457608fc28fc588734d53a5a52df90 (patch) | |
| tree | d50f2f12dba4e7fc4a15f29569217f88e4e318c4 | |
| parent | 4a6d1af34e675f92baa53fa10559190906923a33 (diff) | |
| parent | ce3beb820000d7d2c45c495be8a69f19cad870d7 (diff) | |
| download | mullvadvpn-958111e268457608fc28fc588734d53a5a52df90.tar.xz mullvadvpn-958111e268457608fc28fc588734d53a5a52df90.zip | |
Merge branch 'reconnect-update'
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 37 |
2 files changed, 32 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 715ae4d378..ae38b8c66f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Line wrap the file at 100 chars. Th - Remove WireGuard keys from accounts when they are removed from the local account history. - Upgrade from Electron 6 to Electron 7. - Disable WireGuard protocol option if there's no WireGuard key. +- Only reconnect when settings change if a relevant tunnel protocol is used. #### Android - Wait for traffic to be routed through the tunnel device before advertising blocked state. diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index fe59f86d93..d116c635f0 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -67,7 +67,7 @@ use talpid_core::{ #[cfg(target_os = "android")] use talpid_types::android::AndroidContext; use talpid_types::{ - net::{openvpn, TransportProtocol, TunnelParameters}, + net::{openvpn, TransportProtocol, TunnelParameters, TunnelType}, tunnel::{ErrorStateCause, ParameterGenerationError, TunnelStateTransition}, ErrorExt, }; @@ -1278,8 +1278,12 @@ where Self::oneshot_send(tx, (), "set_openvpn_mssfix response"); if settings_changed { self.event_listener.notify_settings(self.settings.clone()); - info!("Initiating tunnel restart because the OpenVPN mssfix setting changed"); - self.reconnect_tunnel(); + if let Some(TunnelType::OpenVpn) = self.get_connected_tunnel_type() { + info!( + "Initiating tunnel restart because the OpenVPN mssfix setting changed" + ); + self.reconnect_tunnel(); + } } } Err(e) => error!("{}", e.display_chain_with_msg("Unable to save settings")), @@ -1358,8 +1362,12 @@ where Self::oneshot_send(tx, (), "set_wireguard_mtu response"); if settings_changed { self.event_listener.notify_settings(self.settings.clone()); - info!("Initiating tunnel restart because the WireGuard MTU setting changed"); - self.reconnect_tunnel(); + if let Some(TunnelType::Wireguard) = self.get_connected_tunnel_type() { + info!( + "Initiating tunnel restart because the WireGuard MTU setting changed" + ); + self.reconnect_tunnel(); + } } } Err(e) => error!("{}", e.display_chain_with_msg("Unable to save settings")), @@ -1454,7 +1462,9 @@ where self.account_history.insert(account_entry).map_err(|e| { format!("Failed to add new wireguard key to account data: {}", e) })?; - self.reconnect_tunnel(); + if let Some(TunnelType::Wireguard) = self.get_connected_tunnel_type() { + self.reconnect_tunnel(); + } let keygen_event = KeygenEvent::NewKey(public_key); self.event_listener.notify_key_event(keygen_event.clone()); @@ -1577,6 +1587,21 @@ where } } + fn get_connected_tunnel_type(&self) -> Option<TunnelType> { + use talpid_types::net::TunnelEndpoint; + use TunnelState::Connected; + + if let Connected { + endpoint: TunnelEndpoint { tunnel_type, .. }, + .. + } = self.tunnel_state + { + Some(tunnel_type) + } else { + None + } + } + fn send_tunnel_command(&mut self, command: TunnelCommand) { self.tunnel_command_tx .unbounded_send(command) |
