diff options
| author | Jon Petersson <jon.petersson@mullvad.net> | 2025-08-27 16:41:33 +0200 |
|---|---|---|
| committer | Jon Petersson <jon.petersson@mullvad.net> | 2025-08-28 09:59:39 +0200 |
| commit | 0e2e0973873fec4997d27fb3fdb262bfe252d102 (patch) | |
| tree | 14dc67185521c1363ec2f564be07a33fb3a6c2ba /ios/MullvadVPN/RelayCacheTracker | |
| parent | 21b3ede39501c037231e69c89c2d18cbde156f5f (diff) | |
| download | mullvadvpn-0e2e0973873fec4997d27fb3fdb262bfe252d102.tar.xz mullvadvpn-0e2e0973873fec4997d27fb3fdb262bfe252d102.zip | |
Fix relay features not present on cached relays
Diffstat (limited to 'ios/MullvadVPN/RelayCacheTracker')
| -rw-r--r-- | ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift b/ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift index f640a34721..8470db9aa3 100644 --- a/ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift +++ b/ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift @@ -64,7 +64,7 @@ final class RelayCacheTracker: RelayCacheTrackerProtocol, @unchecked Sendable { do { cachedRelays = try cache.read().cachedRelays - try hotfixRelaysThatDoNotHaveDaita() + try hotfixRelaysThatDoNotHaveFeatures() } catch { logger.error( error: error, @@ -75,32 +75,31 @@ final class RelayCacheTracker: RelayCacheTrackerProtocol, @unchecked Sendable { } } - /// This method updates the cached relay to include daita information + /// This method updates the cached relay to include "feature" information /// - /// This is a hotfix meant to upgrade clients shipped with 2024.5 or before that did not have - /// daita information in their representation of `ServerRelay`. - /// If a version <= 2024.5 is installed less than an hour before a new upgrade, - /// no servers will be shown in locations when filtering for daita relays. + /// This is a hotfix meant to upgrade clients shipped with 2025.6 or before that did not have + /// feature information in their representation of `ServerRelay`. + /// If a version <= 2025.6 is installed less than an hour before a new upgrade, + /// no servers will be shown in locations when filtering for relays requiring a certain feature. /// /// > Info: `relayCacheLock` does not need to be accessed here, this method should be ran from `init` only. - private func hotfixRelaysThatDoNotHaveDaita() throws { + private func hotfixRelaysThatDoNotHaveFeatures() throws { guard let cachedRelays else { return } - let daitaPropertyMissing = cachedRelays.relays.wireguard.relays.first { $0.hasDaita } == nil + let featurePropertyMissing = cachedRelays.relays.wireguard.relays.first { $0.features != nil } == nil // If the cached relays already have daita information, this fix is not necessary - guard daitaPropertyMissing else { return } + guard featurePropertyMissing else { return } let preBundledRelays = try cache.readPrebundledRelays().relays - let preBundledDaitaRelays = preBundledRelays.wireguard.relays.filter { $0.hasDaita } - var cachedRelaysWithFixedDaita = cachedRelays.relays.wireguard.relays + let preBundledFeatureRelays = preBundledRelays.wireguard.relays.filter { $0.features != nil } + var cachedRelaysWithFixedFeatures = cachedRelays.relays.wireguard.relays - // For each daita enabled relay in the prebundled relays - // Find the corresponding relay in the cache by matching relay hostnames - // Then update it to toggle daita - for index in 0 ..< cachedRelaysWithFixedDaita.endIndex { - let relay = cachedRelaysWithFixedDaita[index] - preBundledDaitaRelays.forEach { + // For each relay with features in the prebundled relays, find the corresponding relay + // in the cache by matching relay hostnames and update it. + for index in 0 ..< cachedRelaysWithFixedFeatures.endIndex { + let relay = cachedRelaysWithFixedFeatures[index] + preBundledFeatureRelays.forEach { if $0.hostname == relay.hostname { - cachedRelaysWithFixedDaita[index] = relay.override(daita: true) + cachedRelaysWithFixedFeatures[index] = relay.override(features: $0.features) } } } @@ -110,7 +109,7 @@ final class RelayCacheTracker: RelayCacheTrackerProtocol, @unchecked Sendable { cachedRelays.relays.wireguard.ipv4Gateway, ipv6Gateway: cachedRelays.relays.wireguard.ipv6Gateway, portRanges: cachedRelays.relays.wireguard.portRanges, - relays: cachedRelaysWithFixedDaita, + relays: cachedRelaysWithFixedFeatures, shadowsocksPortRanges: cachedRelays.relays.wireguard.shadowsocksPortRanges ) |
