diff options
| author | Emīls Piņķis <emils@mullvad.net> | 2020-04-07 19:50:40 +0100 |
|---|---|---|
| committer | Emīls Piņķis <emils@mullvad.net> | 2020-04-08 07:54:52 +0100 |
| commit | d657130ac4299948c480ac97024b4026d96686c7 (patch) | |
| tree | adaa4dda8a3520fbcca4daa3e7f4ccd0cbfae925 | |
| parent | 2d0172e574440f912710b6cb5f0d1973c5043de6 (diff) | |
| download | mullvadvpn-d657130ac4299948c480ac97024b4026d96686c7.tar.xz mullvadvpn-d657130ac4299948c480ac97024b4026d96686c7.zip | |
Select OpenVPN relays when no WG key exists
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 5 | ||||
| -rw-r--r-- | mullvad-daemon/src/relays.rs | 19 |
2 files changed, 20 insertions, 4 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index bca668bc28..79cb4d192d 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -769,6 +769,11 @@ where &constraints, self.settings.get_bridge_state(), retry_attempt, + self.account_history + .get(&account_token) + .unwrap_or(None) + .and_then(|entry| entry.wireguard) + .is_some(), ) .map_err(|_| ParameterGenerationError::NoMatchingRelay) .and_then(|(relay, endpoint)| { diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs index 4c9111d468..25a3b8eb40 100644 --- a/mullvad-daemon/src/relays.rs +++ b/mullvad-daemon/src/relays.rs @@ -210,9 +210,14 @@ impl RelaySelector { relay_constraints: &RelayConstraints, bridge_state: &BridgeState, retry_attempt: u32, + wg_key_exists: bool, ) -> Result<(Relay, MullvadEndpoint), Error> { - let preferred_constraints = - self.preferred_constraints(relay_constraints, bridge_state, retry_attempt); + let preferred_constraints = self.preferred_constraints( + relay_constraints, + bridge_state, + retry_attempt, + wg_key_exists, + ); if let Some((relay, endpoint)) = self.get_tunnel_endpoint_internal(&preferred_constraints) { debug!( "Relay matched on highest preference for retry attempt {}", @@ -237,10 +242,15 @@ impl RelaySelector { original_constraints: &RelayConstraints, bridge_state: &BridgeState, retry_attempt: u32, + wg_key_exists: bool, ) -> RelayConstraints { let (preferred_port, preferred_protocol, preferred_tunnel) = if *bridge_state != BridgeState::On { - self.preferred_tunnel_constraints(retry_attempt, &original_constraints.location) + self.preferred_tunnel_constraints( + retry_attempt, + &original_constraints.location, + wg_key_exists, + ) } else { ( Constraint::Any, @@ -370,6 +380,7 @@ impl RelaySelector { &self, retry_attempt: u32, location_constraint: &Constraint<LocationConstraint>, + wg_key_exists: bool, ) -> (Constraint<u16>, TransportProtocol, TunnelProtocol) { #[cfg(not(target_os = "windows"))] { @@ -381,7 +392,7 @@ impl RelaySelector { }); // If location does not support WireGuard, defer to preferred OpenVPN tunnel // constraints - if !location_supports_wireguard { + if !location_supports_wireguard || !wg_key_exists { let (preferred_port, preferred_protocol) = Self::preferred_openvpn_constraints(retry_attempt); return (preferred_port, preferred_protocol, TunnelProtocol::OpenVpn); |
