diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-09-27 09:27:38 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-10-09 14:40:14 +0200 |
| commit | dec790e8c876c913120c194f560ef94732d9ba62 (patch) | |
| tree | a4075f517ba7ef2dbff856dd6ec08c9b6458a299 | |
| parent | 532bd6d38c9cbb95b6d628dd4470f89f06025d94 (diff) | |
| download | mullvadvpn-dec790e8c876c913120c194f560ef94732d9ba62.tar.xz mullvadvpn-dec790e8c876c913120c194f560ef94732d9ba62.zip | |
Allow the user to specify if a new access method should be disabled when added
Adds the `-d | --disabled` flag to `mullvad api-access add
<access-method>` command. If the `-d | --disable` is set, the access
method is *not* enabled from the start.
Note that it may still be tested using the `mullvad api-access test`
command, even if it is principally marked as `disabled`.
| -rw-r--r-- | mullvad-cli/src/cmds/api_access.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/mullvad-cli/src/cmds/api_access.rs b/mullvad-cli/src/cmds/api_access.rs index 655f10a5de..c760e8e223 100644 --- a/mullvad-cli/src/cmds/api_access.rs +++ b/mullvad-cli/src/cmds/api_access.rs @@ -210,6 +210,10 @@ pub enum AddCustomCommands { /// Cipher to use #[arg(value_parser = SHADOWSOCKS_CIPHERS, default_value = "aes-256-gcm")] cipher: String, + /// Disable the use of this custom access method. It has to be manually + /// enabled at a later stage to be used when accessing the Mullvad API. + #[arg(default_value_t = false, short, long)] + disabled: bool, }, } @@ -223,6 +227,10 @@ pub enum AddSocks5Commands { remote_ip: IpAddr, /// The port of the remote proxy server remote_port: u16, + /// Disable the use of this custom access method. It has to be manually + /// enabled at a later stage to be used when accessing the Mullvad API. + #[arg(default_value_t = false, short, long)] + disabled: bool, }, /// Configure a local SOCKS5 proxy Local { @@ -234,6 +242,10 @@ pub enum AddSocks5Commands { remote_ip: IpAddr, /// The port of the remote peer remote_port: u16, + /// Disable the use of this custom access method. It has to be manually + /// enabled at a later stage to be used when accessing the Mullvad API. + #[arg(default_value_t = false, short, long)] + disabled: bool, }, } @@ -248,9 +260,15 @@ impl AddCustomCommands { } .clone() } - /// TODO: Actually add an `enabled` flag to the variants of `AddCustomCommands` + fn enabled(&self) -> bool { - true + match self { + AddCustomCommands::Shadowsocks { disabled, .. } => !disabled, + AddCustomCommands::Socks5(socks) => match socks { + AddSocks5Commands::Remote { disabled, .. } => !disabled, + AddSocks5Commands::Local { disabled, .. } => !disabled, + }, + } } } @@ -330,6 +348,7 @@ mod conversions { remote_ip, remote_port, name: _, + disabled: _, } => { println!("Adding Local SOCKS5-proxy: localhost:{local_port} => {remote_ip}:{remote_port}"); let socks_proxy = daemon_types::Socks5::Local( @@ -346,6 +365,7 @@ mod conversions { remote_ip, remote_port, name: _, + disabled: _, } => { println!("Adding SOCKS5-proxy: {remote_ip}:{remote_port}"); let socks_proxy = daemon_types::Socks5::Remote( @@ -364,6 +384,7 @@ mod conversions { password, cipher, name: _, + disabled: _, } => { println!( "Adding Shadowsocks-proxy: {password} @ {remote_ip}:{remote_port} using {cipher}" |
