Skip to content

Commit

Permalink
Remove daita filter notice when using use_anywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
hulthe committed Aug 20, 2024
1 parent 6a84cae commit 7ea6b55
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export function RelayListContextProvider(props: RelayListContextProviderProps) {

const fullRelayList = useSelector((state) => state.settings.relayLocations);
const relaySettings = useNormalRelaySettings();
const multihop = relaySettings?.wireguard.useMultihop ?? false;

// Filters the relays to only keep the ones of the desired endpoint type, e.g. "wireguard",
// "openvpn" or "bridge"
Expand All @@ -79,7 +78,8 @@ export function RelayListContextProvider(props: RelayListContextProviderProps) {
const relayListForDaita = useMemo(() => {
return filterLocationsByDaita(
relayListForEndpointType,
daita && (!useAnywhere || multihop),
daita,
useAnywhere,
locationType,
relaySettings?.tunnelProtocol ?? 'any',
relaySettings?.wireguard.useMultihop ?? false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ export default function SelectLocation() {
const providers = relaySettings?.providers ?? [];
const filteredProviders = useFilteredProviders(providers, ownership);
const daita = useSelector((state) => state.settings.wireguard.daita?.enabled ?? false);
const useAnywhere = useSelector((state) => state.settings.wireguard.daita?.useAnywhere ?? false);
const showDaitaFilter = daitaFilterActive(
daita,
useAnywhere,
locationType,
relaySettings?.tunnelProtocol ?? 'any',
relaySettings?.wireguard.useMultihop ?? false,
Expand Down
6 changes: 4 additions & 2 deletions gui/src/renderer/lib/filter-locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,27 @@ export function filterLocationsByEndPointType(
export function filterLocationsByDaita(
locations: IRelayLocationCountryRedux[],
daita: boolean,
useAnywhere: boolean,
locationType: LocationType,
tunnelProtocol: LiftedConstraint<TunnelProtocol>,
multihop: boolean,
): IRelayLocationCountryRedux[] {
return daitaFilterActive(daita, locationType, tunnelProtocol, multihop)
return daitaFilterActive(daita, useAnywhere, locationType, tunnelProtocol, multihop)
? filterLocationsImpl(locations, (relay: IRelayLocationRelayRedux) => relay.daita)
: locations;
}

export function daitaFilterActive(
daita: boolean,
useAnywhere: boolean,
locationType: LocationType,
tunnelProtocol: LiftedConstraint<TunnelProtocol>,
multihop: boolean,
) {
const isEntry = multihop
? locationType === LocationType.entry
: locationType === LocationType.exit;
return daita && isEntry && tunnelProtocol !== 'openvpn';
return daita && (!useAnywhere || multihop) && isEntry && tunnelProtocol !== 'openvpn';
}

export function filterLocations(
Expand Down

0 comments on commit 7ea6b55

Please sign in to comment.