diff options
| author | Jonathan <jonathan@mullvad.net> | 2023-12-21 13:36:52 +0100 |
|---|---|---|
| committer | Jonathan <jonathan@mullvad.net> | 2023-12-21 13:36:52 +0100 |
| commit | 9d71eccc2f3507928b833f969c952347c7a76d4c (patch) | |
| tree | c92a6f524fa9f659a0edb2bb702e466d051ddba2 /mullvad-cli/src/format.rs | |
| parent | ce7f4f73f82295275631ef05dbe12ba17843ec2d (diff) | |
| parent | 8ed53a012b6c510a0dfd92925b8b0e742fd79da3 (diff) | |
| download | mullvadvpn-9d71eccc2f3507928b833f969c952347c7a76d4c.tar.xz mullvadvpn-9d71eccc2f3507928b833f969c952347c7a76d4c.zip | |
Merge branch 'out-ip-delay'
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..512b632dc8 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 to be 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>, |
