diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-06-20 09:37:04 +0200 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-06-21 13:15:34 +0200 |
| commit | c6afb3defb5051223cae59488b7194dbace70b36 (patch) | |
| tree | 25f343f6e6bd556b67e7953452f9343ebd025a9e | |
| parent | 83e38eba4036b65cd28be7e74768d19896d834ec (diff) | |
| download | mullvadvpn-c6afb3defb5051223cae59488b7194dbace70b36.tar.xz mullvadvpn-c6afb3defb5051223cae59488b7194dbace70b36.zip | |
Add smarter entry location constraint selection to multihop
Add the same location constraint logic as `relay set location` to the
entry location constraint for multihop. This implies that the relay
selection for both work in the same way.
| -rw-r--r-- | mullvad-cli/src/cmds/relay.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs index 9c5560d35e..528c0addfb 100644 --- a/mullvad-cli/src/cmds/relay.rs +++ b/mullvad-cli/src/cmds/relay.rs @@ -129,6 +129,25 @@ pub enum SetTunnelCommands { pub enum EntryLocation { /// Entry endpoint to use. This can be 'any' or any location that is valid with 'set location', /// such as 'se got'. + #[command( + override_usage = "mullvad relay set tunnel wireguard entry-location <COUNTRY> [CITY] [HOSTNAME] | <HOSTNAME> + + Select entry location using a country: + +\tmullvad relay set tunnel wireguard entry-location se + + Select entry location using a country and city: + +\tmullvad relay set tunnel wireguard entry-location se got + + Select entry location using a country, city and hostname: + +\tmullvad relay set tunnel wireguard entry-location se got se-got-wg-004 + + Select entry location using only its hostname: + +\tmullvad relay set tunnel wireguard entry-location se-got-wg-004" + )] EntryLocation(LocationArgs), } @@ -524,7 +543,14 @@ impl Relay { wireguard_constraints.use_multihop = *use_multihop; } if let Some(EntryLocation::EntryLocation(entry)) = entry_location { - wireguard_constraints.entry_location = Constraint::from(entry); + let countries = Self::get_filtered_relays().await?; + // The country field is assumed to be hostname due to CLI argument parsing + wireguard_constraints.entry_location = + if let Some(relay) = find_relay_by_hostname(&countries, &entry.country) { + Constraint::Only(relay) + } else { + Constraint::from(entry) + }; } Self::update_constraints(RelaySettingsUpdate::Normal(RelayConstraintsUpdate { |
