diff options
| author | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2023-11-17 15:15:41 +0100 |
|---|---|---|
| committer | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2023-11-23 15:14:21 +0100 |
| commit | de51170bec7f193384598b4731607ba5888fa77b (patch) | |
| tree | eaaadba80ace13a638df7346084a6963136b93d5 /mullvad-cli/src | |
| parent | 6b551a33ad86bffc61ce4b08a85e32b3fe0b73c1 (diff) | |
| download | mullvadvpn-de51170bec7f193384598b4731607ba5888fa77b.tar.xz mullvadvpn-de51170bec7f193384598b4731607ba5888fa77b.zip | |
Add subcommand level `entry` to `wireguard`
The command
`relay set tunnel wireguard entry-location` is replaced with
`relay set tunnel wireguard entry location` and
`relay set tunnel wireguard custom-list` is replaced with
`relay set tunnel wireguard entry custom-list`.
This is intended to communicate that the `custom-list` also affects
the entry relay and are mutually exclusive.
Diffstat (limited to 'mullvad-cli/src')
| -rw-r--r-- | mullvad-cli/src/cmds/relay.rs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs index b9b0c2ef37..3c14456518 100644 --- a/mullvad-cli/src/cmds/relay.rs +++ b/mullvad-cli/src/cmds/relay.rs @@ -134,14 +134,21 @@ pub enum SetTunnelCommands { use_multihop: Option<BooleanOption>, #[clap(subcommand)] - entry_location: Option<EntryLocation>, + entry: Option<EntryCommands>, }, } #[derive(Subcommand, Debug, Clone)] -pub enum EntryLocation { - /// Entry endpoint to use. This can be 'any' or any location that is valid with 'set location', - /// such as 'se got'. +pub enum EntryCommands { + /// Set wireguard entry relay constraints + #[clap(subcommand)] + Entry(EntryArgs), +} + +#[derive(Subcommand, Debug, Clone)] +pub enum EntryArgs { + /// Location of entry relay. This can be 'any' or any location that is valid with 'set + /// location', such as 'se got'. #[command( override_usage = "mullvad relay set tunnel wireguard entry-location <COUNTRY> [CITY] [HOSTNAME] | <HOSTNAME> @@ -161,7 +168,7 @@ pub enum EntryLocation { \tmullvad relay set tunnel wireguard entry-location se-got-wg-004" )] - EntryLocation(LocationArgs), + Location(LocationArgs), /// Name of custom list to use to pick entry endpoint. CustomList { custom_list_name: String }, } @@ -432,10 +439,10 @@ impl Relay { port, ip_version, use_multihop, - entry_location, + entry, } => { - Self::set_wireguard_constraints(port, ip_version, use_multihop, entry_location) - .await + let entry = entry.map(|EntryCommands::Entry(entry)| entry); + Self::set_wireguard_constraints(port, ip_version, use_multihop, entry).await } } } @@ -646,7 +653,7 @@ impl Relay { port: Option<Constraint<u16>>, ip_version: Option<Constraint<IpVersion>>, use_multihop: Option<BooleanOption>, - entry_location: Option<EntryLocation>, + entry_location: Option<EntryArgs>, ) -> Result<()> { let mut rpc = MullvadProxyClient::new().await?; let wireguard = rpc.get_relay_locations().await?.wireguard; @@ -675,7 +682,7 @@ impl Relay { wireguard_constraints.use_multihop = *use_multihop; } match entry_location { - Some(EntryLocation::EntryLocation(location_args)) => { + Some(EntryArgs::Location(location_args)) => { let relay_filter = |relay: &mullvad_types::relay_list::Relay| { relay.active && matches!(relay.endpoint_data, RelayEndpointData::Wireguard(_)) }; @@ -685,7 +692,7 @@ impl Relay { wireguard_constraints.entry_location = location_constraint.map(LocationConstraint::from); } - Some(EntryLocation::CustomList { custom_list_name }) => { + Some(EntryArgs::CustomList { custom_list_name }) => { let list_id = super::custom_list::find_list_by_name(&mut rpc, &custom_list_name) .await? .id; |
