summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2023-12-06 15:57:04 +0100
committerDavid Lönnhager <david.l@mullvad.net>2023-12-12 17:09:00 +0100
commit9a4424d9599d323e0a2c154e1fca8ee0eb8e932d (patch)
treeb0be149f9eff193f1fb711d377f2664630e2714a
parent72ee5f1546d84200e2f1918c74540eb5df7ba612 (diff)
downloadmullvadvpn-9a4424d9599d323e0a2c154e1fca8ee0eb8e932d.tar.xz
mullvadvpn-9a4424d9599d323e0a2c154e1fca8ee0eb8e932d.zip
Select WireGuard as automatic tunnel protocol three times instead of two
-rw-r--r--mullvad-relay-selector/src/lib.rs38
1 files changed, 14 insertions, 24 deletions
diff --git a/mullvad-relay-selector/src/lib.rs b/mullvad-relay-selector/src/lib.rs
index 77bad9e8ab..e66e574146 100644
--- a/mullvad-relay-selector/src/lib.rs
+++ b/mullvad-relay-selector/src/lib.rs
@@ -1135,17 +1135,10 @@ impl RelaySelector {
pub const fn preferred_tunnel_constraints(
retry_attempt: u32,
) -> (Constraint<u16>, TransportProtocol, TunnelType) {
- // Try out WireGuard in the first two connection attempts, first with any port,
- // afterwards on port 53. Afterwards, connect through OpenVPN alternating between UDP
- // on any port twice and TCP on port 443 once.
+ // Use WireGuard on the first three attempts, then OpenVPN
match retry_attempt {
- 0 => (
- Constraint::Any,
- TransportProtocol::Udp,
- TunnelType::Wireguard,
- ),
- 1 => (
- Constraint::Only(53),
+ 0..=2 => (
+ Self::preferred_wireguard_port(retry_attempt),
TransportProtocol::Udp,
TunnelType::Wireguard,
),
@@ -1875,23 +1868,20 @@ mod test {
protocol: TransportProtocol::Udp,
port: Constraint::Any,
});
- #[cfg(all(unix, not(target_os = "android")))]
- {
- let preferred = relay_selector.preferred_constraints(
- &relay_constraints,
- BridgeState::On,
- 0,
- &CustomListsSettings::default(),
- );
- assert_eq!(
- preferred.tunnel_protocol,
- Constraint::Only(TunnelType::Wireguard)
- );
- }
let preferred = relay_selector.preferred_constraints(
&relay_constraints,
BridgeState::On,
- 2,
+ 0,
+ &CustomListsSettings::default(),
+ );
+ assert_eq!(
+ preferred.tunnel_protocol,
+ Constraint::Only(TunnelType::Wireguard)
+ );
+ let preferred = relay_selector.preferred_constraints(
+ &relay_constraints,
+ BridgeState::On,
+ 3,
&CustomListsSettings::default(),
);
assert_eq!(