summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-08-18 14:02:54 +0200
committerDavid Lönnhager <david.l@mullvad.net>2020-08-24 18:42:41 +0200
commit3657b1ac1cfbda17a804b8ee6614312f1d883203 (patch)
treecba4d973ec0d6abb438dfe7eb139369111f21871 /mullvad-cli
parent29e7a521b37965356fbc722b4766eda20b4fd101 (diff)
downloadmullvadvpn-3657b1ac1cfbda17a804b8ee6614312f1d883203.tar.xz
mullvadvpn-3657b1ac1cfbda17a804b8ee6614312f1d883203.zip
CLI: Show a warning if the location constraints point to a relay that cannot be found
Diffstat (limited to 'mullvad-cli')
-rw-r--r--mullvad-cli/src/cmds/relay.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs
index e21faa8e4e..2e69a40312 100644
--- a/mullvad-cli/src/cmds/relay.rs
+++ b/mullvad-cli/src/cmds/relay.rs
@@ -371,6 +371,47 @@ impl Relay {
async fn set_location(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
let location_constraint = location::get_constraint(matches);
+ let mut found = false;
+
+ if !location_constraint.country.is_empty() {
+ let countries = Self::get_filtered_relays().await?;
+ for country in &countries {
+ if country.code != location_constraint.country {
+ continue;
+ }
+
+ if location_constraint.city.is_empty() {
+ found = true;
+ break;
+ }
+
+ for city in &country.cities {
+ if city.code != location_constraint.city {
+ continue;
+ }
+
+ if location_constraint.hostname.is_empty() {
+ found = true;
+ break;
+ }
+
+ for relay in &city.relays {
+ if relay.hostname != location_constraint.hostname {
+ continue;
+ }
+ found = true;
+ break;
+ }
+
+ break;
+ }
+ break;
+ }
+
+ if !found {
+ eprintln!("Warning: No matching relay was found.");
+ }
+ }
self.update_constraints(RelaySettingsUpdate {
r#type: Some(relay_settings_update::Type::Normal(