summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEmīls Piņķis <emils@mullvad.net>2020-04-08 08:15:57 +0100
committerEmīls Piņķis <emils@mullvad.net>2020-04-08 08:15:57 +0100
commit88d02b3770c6b0541fb5aa843dc7f1837ec44c27 (patch)
treeadaa4dda8a3520fbcca4daa3e7f4ccd0cbfae925
parent2d0172e574440f912710b6cb5f0d1973c5043de6 (diff)
parentd657130ac4299948c480ac97024b4026d96686c7 (diff)
downloadmullvadvpn-88d02b3770c6b0541fb5aa843dc7f1837ec44c27.tar.xz
mullvadvpn-88d02b3770c6b0541fb5aa843dc7f1837ec44c27.zip
Merge branch 'fix-relay-selection-without-wg-key'
-rw-r--r--mullvad-daemon/src/lib.rs5
-rw-r--r--mullvad-daemon/src/relays.rs19
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);