diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-02-05 10:13:01 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-02-05 11:05:52 +0100 |
| commit | 1bb9d569a36efc2084f673bd06f47e3cacdf6182 (patch) | |
| tree | 885d5e6c3ba099c76db638264deb31b0258dfeb1 | |
| parent | 4a6d1af34e675f92baa53fa10559190906923a33 (diff) | |
| download | mullvadvpn-1bb9d569a36efc2084f673bd06f47e3cacdf6182.tar.xz mullvadvpn-1bb9d569a36efc2084f673bd06f47e3cacdf6182.zip | |
Only reconnect if using relevant tunnel protocol
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 37 |
1 files changed, 31 insertions, 6 deletions
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) |
