summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2024-10-16 18:50:22 +0200
committerMarkus Pettersson <markus.pettersson@mullvad.net>2024-10-18 15:49:31 +0200
commit89c758e08a81882e59c20489b9398133fd4d79a4 (patch)
tree0be090baaf8621b1588b46f5932bec55b700b4f6
parent137f9d23d9213b85c0a5cac596f393a6aa652949 (diff)
downloadmullvadvpn-89c758e08a81882e59c20489b9398133fd4d79a4.tar.xz
mullvadvpn-89c758e08a81882e59c20489b9398133fd4d79a4.zip
Make smart routing take precedence over multihop
If both multihop and DAITA (with smart routing) is enabled, a DAITA-compatible entry relay will be selected. This implies that if the user has selected an entry relay which is not DAITA-enabled, the relay selector will override this choice and force a DAITA-enabled relay as entry. If smart routing is disabled in this case, the user's selected entry will always be selected, even if this means that the user will end up in a blocked state.
-rw-r--r--mullvad-relay-selector/src/relay_selector/mod.rs30
1 files changed, 22 insertions, 8 deletions
diff --git a/mullvad-relay-selector/src/relay_selector/mod.rs b/mullvad-relay-selector/src/relay_selector/mod.rs
index 4e78a73c8a..bcd39bd903 100644
--- a/mullvad-relay-selector/src/relay_selector/mod.rs
+++ b/mullvad-relay-selector/src/relay_selector/mod.rs
@@ -673,8 +673,8 @@ impl RelaySelector {
match Self::get_wireguard_singlehop_config(query, custom_lists, parsed_relays) {
Some(exit) => WireguardConfig::from(exit),
None => {
- // No exit candidate was found.. Check if smart routing stuff works!
- WireguardConfig::from(Self::select_daita_multihop_through_smart_routing(
+ // No exit candidate was found.. Time to try smart routing!
+ let multihop = Self::select_daita_multihop_through_smart_routing(
query,
custom_lists,
parsed_relays,
@@ -683,11 +683,25 @@ impl RelaySelector {
}
}
} else {
- WireguardConfig::from(Self::get_wireguard_multihop_config(
- query,
- custom_lists,
- parsed_relays,
- )?)
+ // A DAITA compatible entry should be used even when the exit is DAITA compatible.
+ // This only makes sense in context: The user is no longer able to explicitly choose an
+ // entry relay with smarting routing enabled, even if multihop is turned on
+ // TODO: Move this somewhere common?
+ let using_daita = || query.wireguard_constraints().daita == Constraint::Only(true);
+ // TODO: Move this somewhere common?
+ let smart_routing_enabled = || {
+ query
+ .wireguard_constraints()
+ .daita_use_multihop_if_necessary
+ .is_only_and(|on| on)
+ };
+ // Also implied: Multihop is enabled.
+ let multihop = if using_daita() && smart_routing_enabled() {
+ Self::get_wireguard_auto_multihop_config(query, custom_lists, parsed_relays)?
+ } else {
+ Self::get_wireguard_multihop_config(query, custom_lists, parsed_relays)?
+ };
+ WireguardConfig::from(multihop)
};
Ok(inner)
@@ -810,7 +824,7 @@ impl RelaySelector {
parsed_relays: &ParsedRelays,
) -> Result<Multihop, Error> {
// Here, we modify the original query just a bit.
- // The actual query for an exit relay is identical as for an exit relay, with the
+ // The actual query for an entry relay is identical as for an exit relay, with the
// exception that the location is different. It is simply the location as dictated by
// the query's multihop constraint.
let mut entry_relay_query = query.clone();