diff options
| author | David Lönnhager <david.l@mullvad.net> | 2019-12-17 10:06:27 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2019-12-17 12:30:16 +0100 |
| commit | 964d5211746a3e2841e6a86c22d1c5bd757707bb (patch) | |
| tree | 70f42303da155de47edbf1689cf2b8958eeea671 /mullvad-cli/src | |
| parent | be990b4373d75dde1352d0812e2c418855c82e40 (diff) | |
| download | mullvadvpn-964d5211746a3e2841e6a86c22d1c5bd757707bb.tar.xz mullvadvpn-964d5211746a3e2841e6a86c22d1c5bd757707bb.zip | |
Improve key rotation CLI
Diffstat (limited to 'mullvad-cli/src')
| -rw-r--r-- | mullvad-cli/src/cmds/tunnel.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs index c1e1e174e1..2d0da4bf32 100644 --- a/mullvad-cli/src/cmds/tunnel.rs +++ b/mullvad-cli/src/cmds/tunnel.rs @@ -56,15 +56,15 @@ fn create_wireguard_keys_subcommand() -> clap::App<'static, 'static> { .setting(clap::AppSettings::SubcommandRequiredElseHelp) .subcommand(clap::SubCommand::with_name("check")) .subcommand(clap::SubCommand::with_name("generate")) - .subcommand(create_wireguard_keys_automatic_rotation_subcommand()) + .subcommand(create_wireguard_keys_rotation_interval_subcommand()) } -fn create_wireguard_keys_automatic_rotation_subcommand() -> clap::App<'static, 'static> { - clap::SubCommand::with_name("automatic-rotation") +fn create_wireguard_keys_rotation_interval_subcommand() -> clap::App<'static, 'static> { + clap::SubCommand::with_name("rotation-interval") .about("Manage automatic key rotation (specified in hours; 0 = disabled)") .setting(clap::AppSettings::SubcommandRequiredElseHelp) .subcommand(clap::SubCommand::with_name("get")) - .subcommand(clap::SubCommand::with_name("unset")) + .subcommand(clap::SubCommand::with_name("reset").about("Use the default rotation interval")) .subcommand( clap::SubCommand::with_name("set").arg(clap::Arg::with_name("interval").required(true)), ) @@ -132,12 +132,12 @@ impl Tunnel { ("key", Some(matches)) => match matches.subcommand() { ("check", _) => Self::process_wireguard_key_check(), ("generate", _) => Self::process_wireguard_key_generate(), - ("automatic-rotation", Some(matches)) => match matches.subcommand() { - ("get", _) => Self::process_wireguard_automatic_rotation_get(), + ("rotation-interval", Some(matches)) => match matches.subcommand() { + ("get", _) => Self::process_wireguard_rotation_interval_get(), ("set", Some(matches)) => { - Self::process_wireguard_automatic_rotation_set(matches) + Self::process_wireguard_rotation_interval_set(matches) } - ("unset", _) => Self::process_wireguard_automatic_rotation_unset(), + ("reset", _) => Self::process_wireguard_rotation_interval_reset(), _ => unreachable!("unhandled command"), }, _ => unreachable!("unhandled command"), @@ -205,32 +205,32 @@ impl Tunnel { Ok(()) } - fn process_wireguard_automatic_rotation_get() -> Result<()> { + fn process_wireguard_rotation_interval_get() -> Result<()> { let tunnel_options = Self::get_tunnel_options()?; println!( - "Automatic rotation interval (hours): {}", + "Rotation interval: {} hour(s)", tunnel_options .wireguard .automatic_rotation .map(|interval| interval.to_string()) - .unwrap_or_else(|| "unset".to_owned()) + .unwrap_or_else(|| "default".to_owned()) ); Ok(()) } - fn process_wireguard_automatic_rotation_set(matches: &clap::ArgMatches<'_>) -> Result<()> { + fn process_wireguard_rotation_interval_set(matches: &clap::ArgMatches<'_>) -> Result<()> { let rotate_interval = value_t!(matches.value_of("interval"), u32).unwrap_or_else(|e| e.exit()); let mut rpc = new_rpc_client()?; - rpc.set_wireguard_automatic_rotation(Some(rotate_interval))?; - println!("Wireguard automatic key rotation has been updated"); + rpc.set_wireguard_rotation_interval(Some(rotate_interval))?; + println!("Set key rotation interval: {} hour(s)", rotate_interval); Ok(()) } - fn process_wireguard_automatic_rotation_unset() -> Result<()> { + fn process_wireguard_rotation_interval_reset() -> Result<()> { let mut rpc = new_rpc_client()?; - rpc.set_wireguard_automatic_rotation(None)?; - println!("Wireguard automatic key rotation has been unset"); + rpc.set_wireguard_rotation_interval(None)?; + println!("Set key rotation interval: default"); Ok(()) } |
