diff options
Diffstat (limited to 'mullvad-cli/src/format.rs')
| -rw-r--r-- | mullvad-cli/src/format.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/mullvad-cli/src/format.rs b/mullvad-cli/src/format.rs index 2938842cef..0e920b6218 100644 --- a/mullvad-cli/src/format.rs +++ b/mullvad-cli/src/format.rs @@ -37,11 +37,34 @@ pub fn print_state(state: &TunnelState, verbose: bool) { format_relay_connection(endpoint, location.as_ref(), verbose) ); } - Disconnected => println!("Disconnected"), + Disconnected(_) => { + println!("Disconnected"); + } Disconnecting(_) => println!("Disconnecting..."), } } +pub fn print_location(state: &TunnelState) { + let location = match state { + TunnelState::Disconnected(location) => location, + TunnelState::Connected { location, .. } => location, + _ => return, + }; + if let Some(location) = location { + print!("Your connection appears from: {}", location.country); + if let Some(city) = &location.city { + print!(", {}", city); + } + if let Some(ipv4) = location.ipv4 { + print!(". IPv4: {ipv4}"); + } + if let Some(ipv6) = location.ipv6 { + print!(", IPv6: {ipv6}"); + } + println!(); + } +} + fn format_relay_connection( endpoint: &TunnelEndpoint, location: Option<&GeoIpLocation>, |
