summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src/cmds
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2018-11-05 13:54:54 +0100
committerLinus Färnstrand <linus@mullvad.net>2018-11-05 13:54:54 +0100
commit3ab939af52a66b84a195b0758ae81f62e2fa7250 (patch)
treee252298458f95fb8309babb8d44eb198350cae06 /mullvad-cli/src/cmds
parent52cdd81d77d4922945ec4598f6799671d92b0823 (diff)
downloadmullvadvpn-3ab939af52a66b84a195b0758ae81f62e2fa7250.tar.xz
mullvadvpn-3ab939af52a66b84a195b0758ae81f62e2fa7250.zip
Add CLI command for making daemon update relay list
Diffstat (limited to 'mullvad-cli/src/cmds')
-rw-r--r--mullvad-cli/src/cmds/relay.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs
index f6838427ec..9f12f8af33 100644
--- a/mullvad-cli/src/cmds/relay.rs
+++ b/mullvad-cli/src/cmds/relay.rs
@@ -100,15 +100,21 @@ impl Command for Relay {
.subcommand(
clap::SubCommand::with_name("list").about("List available countries and cities"),
)
+ .subcommand(
+ clap::SubCommand::with_name("update")
+ .about("Update the list of available countries and cities"),
+ )
}
fn run(&self, matches: &clap::ArgMatches) -> Result<()> {
if let Some(set_matches) = matches.subcommand_matches("set") {
self.set(set_matches)
- } else if let Some(_) = matches.subcommand_matches("get") {
+ } else if matches.subcommand_matches("get").is_some() {
self.get()
- } else if let Some(list_matches) = matches.subcommand_matches("list") {
- self.list(list_matches)
+ } else if matches.subcommand_matches("list").is_some() {
+ self.list()
+ } else if matches.subcommand_matches("update").is_some() {
+ self.update()
} else {
unreachable!("No relay command given");
}
@@ -210,7 +216,7 @@ impl Relay {
Ok(())
}
- fn list(&self, _matches: &clap::ArgMatches) -> Result<()> {
+ fn list(&self) -> Result<()> {
let mut rpc = new_rpc_client()?;
let mut locations = rpc.get_relay_locations()?;
locations.countries.sort_by(|c1, c2| c1.name.cmp(&c2.name));
@@ -227,6 +233,12 @@ impl Relay {
}
Ok(())
}
+
+ fn update(&self) -> Result<()> {
+ new_rpc_client()?.update_relay_locations()?;
+ println!("Updating relay list in the background...");
+ Ok(())
+ }
}