diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-06-27 21:49:53 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-06-28 19:18:45 +0000 |
| commit | 09bbf7dc4f89c8faa0c536b7046813afa15d4d82 (patch) | |
| tree | 8a6067b0a4b9f11630cae83d9b2d813798b23412 | |
| parent | a4c73a9f1a84dd7e3b666cffde680a55e2a3bb80 (diff) | |
| download | mullvadvpn-09bbf7dc4f89c8faa0c536b7046813afa15d4d82.tar.xz mullvadvpn-09bbf7dc4f89c8faa0c536b7046813afa15d4d82.zip | |
Refactor API method to use stored relay location
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 6071306b66..0e66149915 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -791,26 +791,26 @@ where fn on_get_current_location(&self, tx: oneshot::Sender<Option<GeoIpLocation>>) { use self::TunnelState::*; let get_location: Box<dyn Future<Item = Option<GeoIpLocation>, Error = ()> + Send> = - match self.tunnel_state { + match &self.tunnel_state { Disconnected => Box::new(self.get_geo_location().map(Some)), - Connecting { .. } | Disconnecting(..) => match self.build_location_from_relay() { + Connecting { location, .. } => Box::new(future::result(Ok(Some(location.clone())))), + Disconnecting(..) => match self.build_location_from_relay() { Some(relay_location) => Box::new(future::result(Ok(Some(relay_location)))), // Custom relay is set, no location is known None => Box::new(future::result(Ok(None))), }, - Connected { .. } => match self.build_location_from_relay() { - Some(location_from_relay) => Box::new( + Connected { location, .. } => { + let relay_location = location.clone(); + Box::new( self.get_geo_location() .map(|fetched_location| GeoIpLocation { ipv4: fetched_location.ipv4, ipv6: fetched_location.ipv6, - ..location_from_relay + ..relay_location }) .map(Some), - ), - // Custom relay is set, no location is known intrinsicly - None => Box::new(self.get_geo_location().map(Some)), - }, + ) + } Blocked(..) => { // We are not online at all at this stage so no location data is available. Box::new(future::result(Ok(None))) |
