summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src/cmds
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2021-08-17 13:53:37 +0200
committerDavid Lönnhager <david.l@mullvad.net>2021-09-28 12:41:48 +0200
commit00973733707c669bc51c48c9eebc481c4e3f7b82 (patch)
treefe7e2d93124e63bf8aebc7956c238c81390840cb /mullvad-cli/src/cmds
parentce84bcf44cd923f5d178c8a39eaec6eee8165e5f (diff)
downloadmullvadvpn-00973733707c669bc51c48c9eebc481c4e3f7b82.tar.xz
mullvadvpn-00973733707c669bc51c48c9eebc481c4e3f7b82.zip
Enable wireguard-nt with temporary CLI switch
Diffstat (limited to 'mullvad-cli/src/cmds')
-rw-r--r--mullvad-cli/src/cmds/tunnel.rs55
1 files changed, 53 insertions, 2 deletions
diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs
index 08306b70eb..e01d81a9da 100644
--- a/mullvad-cli/src/cmds/tunnel.rs
+++ b/mullvad-cli/src/cmds/tunnel.rs
@@ -34,11 +34,19 @@ impl Command for Tunnel {
}
fn create_wireguard_subcommand() -> clap::App<'static, 'static> {
- clap::SubCommand::with_name("wireguard")
+ let subcmd = clap::SubCommand::with_name("wireguard")
.about("Manage options for Wireguard tunnels")
.setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(create_wireguard_mtu_subcommand())
- .subcommand(create_wireguard_keys_subcommand())
+ .subcommand(create_wireguard_keys_subcommand());
+ #[cfg(windows)]
+ {
+ subcmd.subcommand(create_wireguard_use_wg_nt_subcommand())
+ }
+ #[cfg(not(windows))]
+ {
+ subcmd
+ }
}
fn create_wireguard_mtu_subcommand() -> clap::App<'static, 'static> {
@@ -61,6 +69,22 @@ fn create_wireguard_keys_subcommand() -> clap::App<'static, 'static> {
.subcommand(create_wireguard_keys_rotation_interval_subcommand())
}
+#[cfg(windows)]
+fn create_wireguard_use_wg_nt_subcommand() -> clap::App<'static, 'static> {
+ clap::SubCommand::with_name("use-wireguard-nt")
+ .about("Enable or disable wireguard-nt")
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
+ .subcommand(clap::SubCommand::with_name("get"))
+ .subcommand(
+ clap::SubCommand::with_name("set").arg(
+ clap::Arg::with_name("policy")
+ .required(true)
+ .takes_value(true)
+ .possible_values(&["on", "off"]),
+ ),
+ )
+}
+
fn create_wireguard_keys_rotation_interval_subcommand() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("rotation-interval")
.about("Manage automatic key rotation (given in hours)")
@@ -147,6 +171,13 @@ impl Tunnel {
_ => unreachable!("unhandled command"),
},
+ #[cfg(windows)]
+ ("use-wireguard-nt", Some(matches)) => match matches.subcommand() {
+ ("get", _) => Self::process_wireguard_use_wg_nt_get().await,
+ ("set", Some(matches)) => Self::process_wireguard_use_wg_nt_set(matches).await,
+ _ => unreachable!("unhandled command"),
+ },
+
_ => unreachable!("unhandled command"),
}
}
@@ -180,6 +211,26 @@ impl Tunnel {
Ok(())
}
+ #[cfg(windows)]
+ async fn process_wireguard_use_wg_nt_get() -> Result<()> {
+ let tunnel_options = Self::get_tunnel_options().await?;
+ if tunnel_options.wireguard.unwrap().use_wireguard_nt {
+ println!("enabled");
+ } else {
+ println!("disabled");
+ }
+ Ok(())
+ }
+
+ #[cfg(windows)]
+ async fn process_wireguard_use_wg_nt_set(matches: &clap::ArgMatches<'_>) -> Result<()> {
+ let new_state = matches.value_of("policy").unwrap() == "on";
+ let mut rpc = new_rpc_client().await?;
+ rpc.set_use_wireguard_nt(new_state).await?;
+ println!("Updated wireguard-nt setting");
+ Ok(())
+ }
+
async fn process_wireguard_key_check() -> Result<()> {
let mut rpc = new_rpc_client().await?;
let key = rpc.get_wireguard_key(()).await;