diff options
| author | Emīls Piņķis <emils@mullvad.net> | 2022-09-30 14:20:58 +0200 |
|---|---|---|
| committer | Emīls Piņķis <emils@mullvad.net> | 2022-09-30 14:20:58 +0200 |
| commit | 0be74230db7f4f805edee572de8b8cb5ea5f2424 (patch) | |
| tree | 052bf269f8b591bc36301403df02476cc37dae2f | |
| parent | 015b76fbbea8d5b7599711a20f6dccb845f2c4d5 (diff) | |
| parent | d1f14ce1e4b3b33bca1b512b91121f263f3aa958 (diff) | |
| download | mullvadvpn-0be74230db7f4f805edee572de8b8cb5ea5f2424.tar.xz mullvadvpn-0be74230db7f4f805edee572de8b8cb5ea5f2424.zip | |
Merge branch 'stop-requesting-ipv6-location'
| -rw-r--r-- | mullvad-daemon/src/geoip.rs | 21 | ||||
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 5 |
2 files changed, 18 insertions, 8 deletions
diff --git a/mullvad-daemon/src/geoip.rs b/mullvad-daemon/src/geoip.rs index def16e3ef7..af3d82ae93 100644 --- a/mullvad-daemon/src/geoip.rs +++ b/mullvad-daemon/src/geoip.rs @@ -11,6 +11,7 @@ const URI_V6: &str = "https://ipv6.am.i.mullvad.net/json"; pub async fn send_location_request( request_sender: RequestServiceHandle, + use_ipv6: bool, ) -> Result<GeoIpLocation, Error> { let v4_sender = request_sender.clone(); let v4_future = async move { @@ -19,27 +20,35 @@ pub async fn send_location_request( }; let v6_sender = request_sender.clone(); let v6_future = async move { - let location = send_location_request_internal(URI_V6, v6_sender).await?; - Ok::<GeoIpLocation, Error>(GeoIpLocation::from(location)) + if use_ipv6 { + Some( + send_location_request_internal(URI_V6, v6_sender) + .await + .map(GeoIpLocation::from), + ) + } else { + None + } }; let (v4_result, v6_result) = join!(v4_future, v6_future); match (v4_result, v6_result) { - (Ok(mut v4), Ok(v6)) => { + (Ok(mut v4), Some(Ok(v6))) => { v4.ipv6 = v6.ipv6; v4.mullvad_exit_ip = v4.mullvad_exit_ip && v6.mullvad_exit_ip; Ok(v4) } - (Ok(v4), Err(e)) => { + (Ok(v4), None) => Ok(v4), + (Ok(v4), Some(Err(e))) => { log_network_error(e, "IPv6"); Ok(v4) } - (Err(e), Ok(v6)) => { + (Err(e), Some(Ok(v6))) => { log_network_error(e, "IPv4"); Ok(v6) } - (Err(e_v4), Err(_)) => Err(e_v4), + (Err(e_v4), _) => Err(e_v4), } } diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 487c5b1f49..959e3222da 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -1246,8 +1246,9 @@ where async fn get_geo_location(&mut self) -> impl Future<Output = Result<GeoIpLocation, ()>> { let rest_service = self.api_runtime.rest_handle().await; - async { - geoip::send_location_request(rest_service) + let use_ipv6 = self.settings.tunnel_options.generic.enable_ipv6; + async move { + geoip::send_location_request(rest_service, use_ipv6) .await .map_err(|e| { log::warn!("Unable to fetch GeoIP location: {}", e.display_chain()); |
