diff options
| author | David Lönnhager <david.l@mullvad.net> | 2021-04-23 09:43:16 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2021-05-17 11:08:50 +0200 |
| commit | 09fa4dcce3cbf128a893344c0a22eb6cfb6b941e (patch) | |
| tree | 37f7a702bdb5cc980ad95dda8ae4cf36166ac09a | |
| parent | 727015d63363922ec79ec4a3dcb79a34656d9468 (diff) | |
| download | mullvadvpn-09fa4dcce3cbf128a893344c0a22eb6cfb6b941e.tar.xz mullvadvpn-09fa4dcce3cbf128a893344c0a22eb6cfb6b941e.zip | |
Obtain WG exit endpoint from relay selector
| -rw-r--r-- | mullvad-daemon/src/relays.rs | 34 | ||||
| -rw-r--r-- | mullvad-types/src/relay_constraints.rs | 2 |
2 files changed, 35 insertions, 1 deletions
diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs index 5b60369ad6..82a60fff55 100644 --- a/mullvad-daemon/src/relays.rs +++ b/mullvad-daemon/src/relays.rs @@ -323,6 +323,40 @@ impl RelaySelector { relay_constraints } + pub fn get_tunnel_exit_endpoint( + &mut self, + relay_constraints: &RelayConstraints, + ) -> Option<(Relay, MullvadEndpoint)> { + if relay_constraints.tunnel_protocol != Constraint::Only(TunnelType::Wireguard) + && relay_constraints.tunnel_protocol != Constraint::Any + { + return None; + } + if relay_constraints + .wireguard_constraints + .exit_location + .is_none() + { + return None; + } + + let exit_constraints = RelayConstraints { + location: relay_constraints + .wireguard_constraints + .exit_location + .clone() + .unwrap(), + tunnel_protocol: Constraint::Only(TunnelType::Wireguard), + providers: relay_constraints.providers.clone(), + wireguard_constraints: WireguardConstraints { + exit_location: None, + ..WireguardConstraints::default() + }, + ..RelayConstraints::default() + }; + self.get_tunnel_endpoint_internal(&exit_constraints) + } + pub fn get_auto_proxy_settings( &mut self, bridge_constraints: &InternalBridgeConstraints, diff --git a/mullvad-types/src/relay_constraints.rs b/mullvad-types/src/relay_constraints.rs index ab57c62529..6ad47c8af8 100644 --- a/mullvad-types/src/relay_constraints.rs +++ b/mullvad-types/src/relay_constraints.rs @@ -439,7 +439,7 @@ impl Match<OpenVpnEndpointData> for OpenVpnConstraints { pub struct WireguardConstraints { pub port: Constraint<u16>, pub ip_version: Constraint<IpVersion>, - pub exit_location: Option<LocationConstraint>, + pub exit_location: Option<Constraint<LocationConstraint>>, } impl fmt::Display for WireguardConstraints { |
