From de7835e1fbaf491fa310bdf5b59092e6f713b5fc Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Fri, 15 Mar 2024 11:46:48 +0100 Subject: [PATCH] Fix Android build Fix Android build after removing `WireguardMatcher::new_matcher` --- .../src/relay_selector/matcher.rs | 29 ++++++++++++++----- .../src/relay_selector/mod.rs | 7 +++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/mullvad-relay-selector/src/relay_selector/matcher.rs b/mullvad-relay-selector/src/relay_selector/matcher.rs index 71edb0fac122..232c6df56e3e 100644 --- a/mullvad-relay-selector/src/relay_selector/matcher.rs +++ b/mullvad-relay-selector/src/relay_selector/matcher.rs @@ -36,20 +36,33 @@ impl<'a> RelayMatcher> { wireguard_data: &'a WireguardEndpointData, custom_lists: &CustomListsSettings, ) -> RelayMatcher> { - Self { + let endpoint_matcher = AnyTunnelMatcher { + wireguard: WireguardMatcher::new(query.wireguard_constraints.clone(), wireguard_data), + openvpn: OpenVpnMatcher::new( + query.openvpn_constraints.clone(), + openvpn_data, + bridge_state, + ), + tunnel_type: query.tunnel_protocol, + }; + Self::using(query, custom_lists, endpoint_matcher) + } +} + +impl RelayMatcher { + pub fn using( + query: RelayQuery, + custom_lists: &CustomListsSettings, + endpoint_matcher: T, + ) -> RelayMatcher { + RelayMatcher { locations: ResolvedLocationConstraint::from_constraint(query.location, custom_lists), providers: query.providers, ownership: query.ownership, - endpoint_matcher: AnyTunnelMatcher { - wireguard: WireguardMatcher::new(query.wireguard_constraints, wireguard_data), - openvpn: OpenVpnMatcher::new(query.openvpn_constraints, openvpn_data, bridge_state), - tunnel_type: query.tunnel_protocol, - }, + endpoint_matcher, } } -} -impl RelayMatcher { /// Filter a list of relays and their endpoints based on constraints. /// Only relays with (and including) matching endpoints are returned. pub fn filter_matching_relay_list<'a, R: Iterator + Clone>( diff --git a/mullvad-relay-selector/src/relay_selector/mod.rs b/mullvad-relay-selector/src/relay_selector/mod.rs index ffa2ecf68f1e..598e82f37dd5 100644 --- a/mullvad-relay-selector/src/relay_selector/mod.rs +++ b/mullvad-relay-selector/src/relay_selector/mod.rs @@ -909,12 +909,13 @@ impl RelaySelector { config: &NormalSelectorConfig<'_>, parsed_relays: &ParsedRelays, ) -> Vec { + use self::matcher::WireguardMatcher; let relays = parsed_relays.relays(); - let matcher = WireguardMatcher::new_matcher( - query.clone(), + let endpoint_matcher = WireguardMatcher::new( + query.wireguard_constraints.clone(), &parsed_relays.parsed_list().wireguard, - config.custom_lists, ); + let matcher = RelayMatcher::using(query.clone(), config.custom_lists, endpoint_matcher); matcher.filter_matching_relay_list(relays) } }