summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2023-12-06 16:52:16 +0100
committerDavid Lönnhager <david.l@mullvad.net>2023-12-12 17:09:00 +0100
commit72ee5f1546d84200e2f1918c74540eb5df7ba612 (patch)
tree51f0c47b537babb79d064f20a7f617b422b520ff
parent1ece9472405f8413d5ce5240e7444a1a495f973e (diff)
downloadmullvadvpn-72ee5f1546d84200e2f1918c74540eb5df7ba612.tar.xz
mullvadvpn-72ee5f1546d84200e2f1918c74540eb5df7ba612.zip
Always alternate between random ports and port 53 when using WireGuard
-rw-r--r--docs/relay-selector.md4
-rw-r--r--mullvad-relay-selector/src/lib.rs11
2 files changed, 7 insertions, 8 deletions
diff --git a/docs/relay-selector.md b/docs/relay-selector.md
index a4c4b8a249..7dca137657 100644
--- a/docs/relay-selector.md
+++ b/docs/relay-selector.md
@@ -63,8 +63,8 @@ constraints, following default ones will take effect:
_udp2tcp_ all of the time.
If obfuscation is turned _off_, WireGuard connections will first alternate between using
- a random port and port 53, with 2 attempts each, e.g. first attempt using port 22151, second
- 26107, third attempt and fourth attempt using port 53, and then back to random ports.
+ a random port and port 53, e.g. first attempt using port 22151, second 53, third
+ 26107, fourth attempt using port 53, and so on.
If the user has specified a specific port for either _udp2tcp_ or WireGuard, it will override the
port selection, but it will not change the connection type described above (WireGuard or WireGuard
diff --git a/mullvad-relay-selector/src/lib.rs b/mullvad-relay-selector/src/lib.rs
index c10d999afb..77bad9e8ab 100644
--- a/mullvad-relay-selector/src/lib.rs
+++ b/mullvad-relay-selector/src/lib.rs
@@ -1158,12 +1158,11 @@ impl RelaySelector {
}
const fn preferred_wireguard_port(retry_attempt: u32) -> Constraint<u16> {
- // This ensures that if after the first 2 failed attempts the daemon does not
- // connect, then afterwards 2 of each 4 successive attempts will try to connect
- // on port 53.
- match retry_attempt % 4 {
- 0 | 1 => Constraint::Any,
- _ => Constraint::Only(53),
+ // Alternate between using a random port and port 53
+ if retry_attempt % 2 == 0 {
+ Constraint::Any
+ } else {
+ Constraint::Only(53)
}
}