Skip to content

Commit

Permalink
Fix bug where relay selector evaluates only first location constraint…
Browse files Browse the repository at this point in the history
… when a custom list is selected
  • Loading branch information
Jon Petersson committed Feb 28, 2024
1 parent b74b165 commit 6287c3a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions ios/MullvadREST/Relay/RelaySelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,23 @@ public enum RelaySelector {
case .any:
return true
case let .only(relayConstraint):
for location in relayConstraint.locations {
// At least one location must match the relay under test.
return relayConstraint.locations.contains { location in
switch location {
case let .country(countryCode):
return relayWithLocation.serverLocation.countryCode == countryCode &&
relayWithLocation.relay.includeInCountry
relayWithLocation.serverLocation.countryCode == countryCode &&
relayWithLocation.relay.includeInCountry

case let .city(countryCode, cityCode):
return relayWithLocation.serverLocation.countryCode == countryCode &&
relayWithLocation.serverLocation.cityCode == cityCode
relayWithLocation.serverLocation.countryCode == countryCode &&
relayWithLocation.serverLocation.cityCode == cityCode

case let .hostname(countryCode, cityCode, hostname):
return relayWithLocation.serverLocation.countryCode == countryCode &&
relayWithLocation.serverLocation.cityCode == cityCode &&
relayWithLocation.relay.hostname == hostname
relayWithLocation.serverLocation.countryCode == countryCode &&
relayWithLocation.serverLocation.cityCode == cityCode &&
relayWithLocation.relay.hostname == hostname
}
}

return false
}
}.filter { relayWithLocation -> Bool in
relayWithLocation.relay.active
Expand Down

0 comments on commit 6287c3a

Please sign in to comment.