diff options
| author | David Lönnhager <david.l@mullvad.net> | 2022-10-12 12:42:48 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2022-10-17 10:47:37 +0200 |
| commit | c442fdf619e373fedd0fab66529ba05dcabc8135 (patch) | |
| tree | fe59551c869ad5a29e4c187d2686e5bb3000c125 | |
| parent | 28ee56a7f428a4f2988d969a75ee990594056c25 (diff) | |
| download | mullvadvpn-c442fdf619e373fedd0fab66529ba05dcabc8135.tar.xz mullvadvpn-c442fdf619e373fedd0fab66529ba05dcabc8135.zip | |
Refactor CLI to use GeoIpLocation from mullvad-types
| -rw-r--r-- | mullvad-cli/src/cmds/status.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/mullvad-cli/src/cmds/status.rs b/mullvad-cli/src/cmds/status.rs index 7d1ad09327..80eb91db68 100644 --- a/mullvad-cli/src/cmds/status.rs +++ b/mullvad-cli/src/cmds/status.rs @@ -2,7 +2,7 @@ use crate::{format, new_rpc_client, Command, Error, Result}; use mullvad_management_interface::{ types::daemon_event::Event as EventType, ManagementServiceClient, }; -use mullvad_types::states::TunnelState; +use mullvad_types::{location::GeoIpLocation, states::TunnelState}; pub struct Status; @@ -112,9 +112,8 @@ impl Command for Status { } async fn print_location(rpc: &mut ManagementServiceClient) -> Result<()> { - let location = rpc.get_current_location(()).await; - let location = match location { - Ok(response) => response.into_inner(), + let location = match rpc.get_current_location(()).await { + Ok(response) => GeoIpLocation::try_from(response.into_inner()).expect("invalid geoip data"), Err(status) => { if status.code() == mullvad_management_interface::Code::NotFound { println!("Location data unavailable"); @@ -124,11 +123,11 @@ async fn print_location(rpc: &mut ManagementServiceClient) -> Result<()> { } } }; - if !location.ipv4.is_empty() { - println!("IPv4: {}", location.ipv4); + if let Some(ipv4) = location.ipv4 { + println!("IPv4: {}", ipv4); } - if !location.ipv6.is_empty() { - println!("IPv6: {}", location.ipv6); + if let Some(ipv6) = location.ipv6 { + println!("IPv6: {}", ipv6); } println!( |
