diff options
| author | Emīls <emils@mullvad.net> | 2019-11-27 11:49:40 +0000 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2019-11-27 12:52:32 +0000 |
| commit | ee5d27e52dab4de8821935bb7a1b1712677d95f5 (patch) | |
| tree | 098057d208644f0fd5c0e918a6d0cd5bf0276c43 /mullvad-cli/src | |
| parent | 9e326e4b058d2937391e086d7c87d4efc930365b (diff) | |
| download | mullvadvpn-ee5d27e52dab4de8821935bb7a1b1712677d95f5.tar.xz mullvadvpn-ee5d27e52dab4de8821935bb7a1b1712677d95f5.zip | |
Add tunnel-protocol subcomand to CLI
Diffstat (limited to 'mullvad-cli/src')
| -rw-r--r-- | mullvad-cli/src/cmds/relay.rs | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs index eaafcc0cb9..51c96f076d 100644 --- a/mullvad-cli/src/cmds/relay.rs +++ b/mullvad-cli/src/cmds/relay.rs @@ -116,7 +116,7 @@ impl Command for Relay { ) .subcommand( clap::SubCommand::with_name("tunnel") - .about("Set tunnel constraints") + .about("Set inidividual tunnel constraints") .arg( clap::Arg::with_name("vpn protocol") .required(true) @@ -132,7 +132,16 @@ impl Command for Relay { .possible_values(&["any", "udp", "tcp"]), ), - ), + ) + .subcommand(clap::SubCommand::with_name("tunnel-protocol") + .about("Set tunnel protocol") + .arg( + clap::Arg::with_name("tunnel protocol") + .required(true) + .index(1) + .possible_values(&["any", "wireguard", "openvpn", ]), + ) + ), ) .subcommand(clap::SubCommand::with_name("get")) .subcommand( @@ -174,6 +183,8 @@ impl Relay { self.set_location(location_matches) } else if let Some(tunnel_matches) = matches.subcommand_matches("tunnel") { self.set_tunnel(tunnel_matches) + } else if let Some(tunnel_matches) = matches.subcommand_matches("tunnel-protocol") { + self.set_tunnel_protocol(tunnel_matches) } else { unreachable!("No set relay command given"); } @@ -288,7 +299,7 @@ impl Relay { } self.update_constraints(RelaySettingsUpdate::Normal(RelayConstraintsUpdate { location: None, - tunnel_protocol: Some(Constraint::Only(TunnelProtocol::Wireguard)), + tunnel_protocol: None, wireguard_constraints: Some(WireguardConstraints { port }), ..Default::default() })) @@ -296,7 +307,7 @@ impl Relay { "openvpn" => { self.update_constraints(RelaySettingsUpdate::Normal(RelayConstraintsUpdate { location: None, - tunnel_protocol: Some(Constraint::Any), + tunnel_protocol: None, openvpn_constraints: Some(OpenVpnConstraints { port, protocol }), ..Default::default() })) @@ -305,6 +316,19 @@ impl Relay { } } + fn set_tunnel_protocol(&self, matches: &clap::ArgMatches<'_>) -> Result<()> { + let tunnel_protocol = match matches.value_of("tunnel protocol").unwrap() { + "wireguard" => Constraint::Only(TunnelProtocol::Wireguard), + "openvpn" => Constraint::Only(TunnelProtocol::OpenVpn), + "any" => Constraint::Any, + _ => unreachable!(), + }; + self.update_constraints(RelaySettingsUpdate::Normal(RelayConstraintsUpdate { + tunnel_protocol: Some(tunnel_protocol), + ..Default::default() + })) + } + fn get(&self) -> Result<()> { let mut rpc = new_rpc_client()?; let constraints = rpc.get_settings()?.get_relay_settings(); |
