summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gui/src/main/daemon-rpc.ts1
-rw-r--r--gui/src/shared/daemon-rpc-types.ts1
-rw-r--r--mullvad-daemon/src/lib.rs38
-rw-r--r--mullvad-daemon/src/relays.rs12
-rw-r--r--mullvad-types/src/location.rs3
5 files changed, 41 insertions, 14 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index 86ef3dff0a..f50428ea8a 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -41,6 +41,7 @@ const locationSchema = maybe(
longitude: number,
mullvad_exit_ip: boolean,
hostname: maybe(string),
+ bridge_hostname: maybe(string),
}),
);
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts
index 3225995e75..a3f81e29be 100644
--- a/gui/src/shared/daemon-rpc-types.ts
+++ b/gui/src/shared/daemon-rpc-types.ts
@@ -12,6 +12,7 @@ export interface ILocation {
longitude: number;
mullvadExitIp: boolean;
hostname?: string;
+ bridgeHostname?: string;
}
export type BlockReason =
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs
index 88cd834969..42c87d0024 100644
--- a/mullvad-daemon/src/lib.rs
+++ b/mullvad-daemon/src/lib.rs
@@ -214,6 +214,7 @@ pub struct Daemon<L: EventListener = ManagementInterfaceEventBroadcaster> {
tokio_remote: tokio_core::reactor::Remote,
relay_selector: relays::RelaySelector,
last_generated_relay: Option<Relay>,
+ last_generated_bridge_relay: Option<Relay>,
version: String,
}
@@ -379,6 +380,7 @@ where
tokio_remote,
relay_selector,
last_generated_relay: None,
+ last_generated_bridge_relay: None,
version,
})
}
@@ -500,6 +502,7 @@ where
) -> Result<TunnelParameters> {
let tunnel_options = self.settings.get_tunnel_options().clone();
let location = relay.location.as_ref().expect("Relay has no location set");
+ self.last_generated_bridge_relay = None;
match endpoint {
MullvadEndpoint::OpenVpn(endpoint) => {
let proxy_settings = match self.settings.get_bridge_settings() {
@@ -509,16 +512,28 @@ where
transport_protocol: Constraint::Only(endpoint.protocol),
};
match self.settings.get_bridge_state() {
- BridgeState::On => Some(
- self.relay_selector
+ BridgeState::On => {
+ let (bridge_settings, bridge_relay) = self
+ .relay_selector
.get_proxy_settings(&bridge_constraints, location)
- .ok_or(Error::NoBridgeAvailable)?,
- ),
- BridgeState::Auto => self.relay_selector.get_auto_proxy_settings(
- &bridge_constraints,
- location,
- retry_attempt,
- ),
+ .ok_or(Error::NoBridgeAvailable)?;
+ self.last_generated_bridge_relay = Some(bridge_relay);
+ Some(bridge_settings)
+ }
+ BridgeState::Auto => {
+ if let Some((bridge_settings, bridge_relay)) =
+ self.relay_selector.get_auto_proxy_settings(
+ &bridge_constraints,
+ location,
+ retry_attempt,
+ )
+ {
+ self.last_generated_bridge_relay = Some(bridge_relay);
+ Some(bridge_settings)
+ } else {
+ None
+ }
+ }
BridgeState::Off => None,
}
}
@@ -704,6 +719,10 @@ where
fn build_location_from_relay(&self) -> Option<GeoIpLocation> {
let relay = self.last_generated_relay.as_ref()?;
+ let bridge_hostname = self
+ .last_generated_bridge_relay
+ .as_ref()
+ .map(|bridge| bridge.hostname.clone());
let location = relay.location.as_ref().cloned().unwrap();
let hostname = relay.hostname.clone();
@@ -716,6 +735,7 @@ where
longitude: location.longitude,
mullvad_exit_ip: true,
hostname: Some(hostname),
+ bridge_hostname,
})
}
diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs
index 81874e4367..e9c02c6214 100644
--- a/mullvad-daemon/src/relays.rs
+++ b/mullvad-daemon/src/relays.rs
@@ -280,7 +280,7 @@ impl RelaySelector {
bridge_constraints: &InternalBridgeConstraints,
location: &Location,
retry_attempt: u32,
- ) -> Option<ProxySettings> {
+ ) -> Option<(ProxySettings, Relay)> {
if !self.should_use_bridge(retry_attempt) {
return None;
}
@@ -307,7 +307,7 @@ impl RelaySelector {
&mut self,
constraints: &InternalBridgeConstraints,
location: &Location,
- ) -> Option<ProxySettings> {
+ ) -> Option<(ProxySettings, Relay)> {
let mut matching_relays: Vec<Relay> = self
.lock_parsed_relays()
.relays()
@@ -322,9 +322,11 @@ impl RelaySelector {
matching_relays.sort_by_cached_key(|relay| {
(relay.location.as_ref().unwrap().distance_from(&location) * 1000.0) as i64
});
- return matching_relays
- .get(0)
- .and_then(|relay| self.pick_random_bridge(&relay));
+ return matching_relays.get(0).and_then(|relay| {
+ (self
+ .pick_random_bridge(&relay)
+ .map(|bridge| (bridge, relay.clone())))
+ });
}
diff --git a/mullvad-types/src/location.rs b/mullvad-types/src/location.rs
index 514ce35809..629f15d37a 100644
--- a/mullvad-types/src/location.rs
+++ b/mullvad-types/src/location.rs
@@ -73,6 +73,7 @@ pub struct GeoIpLocation {
pub longitude: f64,
pub mullvad_exit_ip: bool,
pub hostname: Option<String>,
+ pub bridge_hostname: Option<String>,
}
impl From<AmIMullvad> for GeoIpLocation {
@@ -81,6 +82,7 @@ impl From<AmIMullvad> for GeoIpLocation {
IpAddr::V4(v4) => (Some(v4), None),
IpAddr::V6(v6) => (None, Some(v6)),
};
+
GeoIpLocation {
ipv4,
ipv6,
@@ -90,6 +92,7 @@ impl From<AmIMullvad> for GeoIpLocation {
longitude: location.longitude,
mullvad_exit_ip: location.mullvad_exit_ip,
hostname: None,
+ bridge_hostname: None,
}
}
}