diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2024-01-18 15:58:40 +0100 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2024-01-18 15:58:40 +0100 |
| commit | 8f8e8c4699237ce6f254c0d6b7f02657dc4224ca (patch) | |
| tree | 1468c4bf64f54b1b41350931b6f6812a379689ec /mullvad-cli/src | |
| parent | df2c42059be814d11d2ce1cf649c09aa73f96268 (diff) | |
| parent | 0a43e6fbb807f6aebc351cf99b6ad308247ff565 (diff) | |
| download | mullvadvpn-8f8e8c4699237ce6f254c0d6b7f02657dc4224ca.tar.xz mullvadvpn-8f8e8c4699237ce6f254c0d6b7f02657dc4224ca.zip | |
Merge branch 'cli_satus_lockdown'
Diffstat (limited to 'mullvad-cli/src')
| -rw-r--r-- | mullvad-cli/src/cmds/status.rs | 30 | ||||
| -rw-r--r-- | mullvad-cli/src/format.rs | 16 |
2 files changed, 34 insertions, 12 deletions
diff --git a/mullvad-cli/src/cmds/status.rs b/mullvad-cli/src/cmds/status.rs index 15b0d10dfe..8880c4c69c 100644 --- a/mullvad-cli/src/cmds/status.rs +++ b/mullvad-cli/src/cmds/status.rs @@ -34,13 +34,25 @@ impl Status { println!("New tunnel state: {new_state:#?}"); } else { // When we enter the connected or disconnected state, am.i.mullvad.net will - // be polled to get IP information. When it arrives, we will get another - // tunnel state of the same enum type, but with the IP filled in. This - // match statement checks for duplicate tunnel states and skips the second - // print to avoid spamming the user. + // be polled to get exit location. When it arrives, we will get another + // tunnel state of the same enum type, but with the location filled in. This + // match statement checks if the new state is an updated version of the old + // one and if so skips the print to avoid spamming the user. Note that for + // graphical frontends updating the drawn state with an identical one is + // invisible, so this is only an issue for the CLI. match (&previous_tunnel_state, &new_state) { - (Some(TunnelState::Disconnected(_)), TunnelState::Disconnected(_)) - | ( + ( + Some(TunnelState::Disconnected { + location: _, + locked_down: was_locked_down, + }), + TunnelState::Disconnected { + location: _, + locked_down, + }, + // Do print an updated state if the lockdown setting was changed + ) if was_locked_down == locked_down => continue, + ( Some(TunnelState::Connected { .. }), TunnelState::Connected { .. }, ) => continue, @@ -91,7 +103,7 @@ pub async fn handle(cmd: Option<Status>, args: StatusArgs) -> Result<()> { let state = rpc.get_tunnel_state().await?; let device = rpc.get_device().await?; - print_account_loggedout(&state, &device); + print_account_logged_out(&state, &device); if args.debug { println!("Tunnel state: {state:#?}"); @@ -106,7 +118,7 @@ pub async fn handle(cmd: Option<Status>, args: StatusArgs) -> Result<()> { Ok(()) } -fn print_account_loggedout(state: &TunnelState, device: &DeviceState) { +fn print_account_logged_out(state: &TunnelState, device: &DeviceState) { match state { TunnelState::Connecting { .. } | TunnelState::Connected { .. } | TunnelState::Error(_) => { match device { @@ -117,6 +129,6 @@ fn print_account_loggedout(state: &TunnelState, device: &DeviceState) { DeviceState::LoggedIn(_) => (), } } - TunnelState::Disconnected(_) | TunnelState::Disconnecting(_) => (), + TunnelState::Disconnected { .. } | TunnelState::Disconnecting(_) => (), } } diff --git a/mullvad-cli/src/format.rs b/mullvad-cli/src/format.rs index 512b632dc8..e605efbe3b 100644 --- a/mullvad-cli/src/format.rs +++ b/mullvad-cli/src/format.rs @@ -37,8 +37,15 @@ pub fn print_state(state: &TunnelState, verbose: bool) { format_relay_connection(endpoint, location.as_ref(), verbose) ); } - Disconnected(_) => { - println!("Disconnected"); + Disconnected { + location: _, + locked_down, + } => { + if *locked_down { + println!("Disconnected (Internet access is blocked due to lockdown mode)"); + } else { + println!("Disconnected"); + } } Disconnecting(_) => println!("Disconnecting..."), } @@ -46,7 +53,10 @@ pub fn print_state(state: &TunnelState, verbose: bool) { pub fn print_location(state: &TunnelState) { let location = match state { - TunnelState::Disconnected(location) => location, + TunnelState::Disconnected { + location, + locked_down: _, + } => location, TunnelState::Connected { location, .. } => location, _ => return, }; |
