diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2023-12-14 08:42:23 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2024-04-16 14:43:19 +0200 |
| commit | 424a519d6eb10be91971054733c8738715eb0906 (patch) | |
| tree | bf35a67e8b8ee4be517af984ba5b550d4ba70f5d | |
| parent | 52a2bed28a4360d9c0f98fed2898e713dc85371c (diff) | |
| download | mullvadvpn-424a519d6eb10be91971054733c8738715eb0906.tar.xz mullvadvpn-424a519d6eb10be91971054733c8738715eb0906.zip | |
Only filter locations for first wg hop
3 files changed, 40 insertions, 6 deletions
diff --git a/gui/src/renderer/components/select-location/RelayListContext.tsx b/gui/src/renderer/components/select-location/RelayListContext.tsx index 2341932f2d..13e2dc28e8 100644 --- a/gui/src/renderer/components/select-location/RelayListContext.tsx +++ b/gui/src/renderer/components/select-location/RelayListContext.tsx @@ -74,7 +74,13 @@ export function RelayListContextProvider(props: RelayListContextProviderProps) { }, [fullRelayList, locationType, relaySettings?.tunnelProtocol]); const relayListForDaita = useMemo(() => { - return filterLocationsByDaita(relayListForEndpointType, daita); + return filterLocationsByDaita( + relayListForEndpointType, + daita, + locationType, + relaySettings?.tunnelProtocol ?? 'any', + relaySettings?.wireguard.useMultihop ?? false, + ); }, [daita, relayListForEndpointType]); // Filters the relays to only keep the relays matching the currently selected filters, e.g. diff --git a/gui/src/renderer/components/select-location/SelectLocation.tsx b/gui/src/renderer/components/select-location/SelectLocation.tsx index e7bd4865cd..3f3535225e 100644 --- a/gui/src/renderer/components/select-location/SelectLocation.tsx +++ b/gui/src/renderer/components/select-location/SelectLocation.tsx @@ -5,7 +5,7 @@ import { colors } from '../../../config.json'; import { Ownership } from '../../../shared/daemon-rpc-types'; import { messages } from '../../../shared/gettext'; import { useRelaySettingsUpdater } from '../../lib/constraint-updater'; -import { filterSpecialLocations } from '../../lib/filter-locations'; +import { daitaFilterActive, filterSpecialLocations } from '../../lib/filter-locations'; import { useHistory } from '../../lib/history'; import { formatHtml } from '../../lib/html-formatter'; import { RoutePath } from '../../lib/routes'; @@ -72,6 +72,12 @@ export default function SelectLocation() { const providers = relaySettings?.providers ?? []; const filteredProviders = useFilteredProviders(providers, ownership); const daita = useSelector((state) => state.settings.wireguard.daita?.enabled ?? false); + const showDaitaFilter = daitaFilterActive( + daita, + locationType, + relaySettings?.tunnelProtocol ?? 'any', + relaySettings?.wireguard.useMultihop ?? false, + ); const [searchValue, setSearchValue] = useState(''); @@ -123,7 +129,7 @@ export default function SelectLocation() { const showOwnershipFilter = ownership !== Ownership.any; const showProvidersFilter = providers.length > 0; - const showFilters = showOwnershipFilter || showProvidersFilter || daita; + const showFilters = showOwnershipFilter || showProvidersFilter || showDaitaFilter; return ( <BackAction action={onClose}> <Layout> @@ -222,7 +228,7 @@ export default function SelectLocation() { </StyledFilter> )} - {daita && ( + {showDaitaFilter && ( <StyledFilter> {sprintf( messages.pgettext('select-location-view', 'Setting: %(settingName)s'), diff --git a/gui/src/renderer/lib/filter-locations.ts b/gui/src/renderer/lib/filter-locations.ts index 802748680a..78126f1fb4 100644 --- a/gui/src/renderer/lib/filter-locations.ts +++ b/gui/src/renderer/lib/filter-locations.ts @@ -1,6 +1,13 @@ -import { Ownership, RelayEndpointType, RelayLocation } from '../../shared/daemon-rpc-types'; +import { + LiftedConstraint, + Ownership, + RelayEndpointType, + RelayLocation, + TunnelProtocol, +} from '../../shared/daemon-rpc-types'; import { relayLocations } from '../../shared/gettext'; import { + LocationType, RelayLocationCityWithVisibility, RelayLocationCountryWithVisibility, RelayLocationRelayWithVisibility, @@ -30,12 +37,27 @@ export function filterLocationsByEndPointType( export function filterLocationsByDaita( locations: IRelayLocationCountryRedux[], daita: boolean, + locationType: LocationType, + tunnelProtocol: LiftedConstraint<TunnelProtocol>, + multihop: boolean, ): IRelayLocationCountryRedux[] { - return daita + return daitaFilterActive(daita, locationType, tunnelProtocol, multihop) ? filterLocationsImpl(locations, (relay: IRelayLocationRelayRedux) => relay.daita) : locations; } +export function daitaFilterActive( + daita: boolean, + locationType: LocationType, + tunnelProtocol: LiftedConstraint<TunnelProtocol>, + multihop: boolean, +) { + const isEntry = multihop + ? locationType === LocationType.entry + : locationType === LocationType.exit; + return daita && isEntry && tunnelProtocol !== 'openvpn'; +} + export function filterLocations( locations: IRelayLocationCountryRedux[], ownership?: Ownership, |
