From 18e9eefdcce0b7d20ca19b338e36d85079b6764b Mon Sep 17 00:00:00 2001 From: gus <42593099+lightcloud00@users.noreply.github.com> Date: Wed, 26 Aug 2026 11:55:46 -0400 Subject: [PATCH] fix(ios): preserve protected route priority --- ios/Sources/CompanionCore/Failover.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ios/Sources/CompanionCore/Failover.swift b/ios/Sources/CompanionCore/Failover.swift index a974d0b81..11d1cb531 100644 --- a/ios/Sources/CompanionCore/Failover.swift +++ b/ios/Sources/CompanionCore/Failover.swift @@ -313,11 +313,11 @@ extension Connection { /// either walks that complete typed set or, for an older desktop, derives /// direct routes from the legacy fields — never a lossy mixture of both. /// - /// A protected route that already carried the bearer leads regardless of - /// a lower advertised priority. Otherwise a hand-typed LAN origin - /// (`priority: 0`) would win the sort after restart and the rotation - /// would hand the token to cleartext again. Typing a local address - /// resets `activeEndpoint`, so the priority order remains the escape hatch. + /// When the active route already protected the bearer, all protected + /// routes lead while retaining their advertised priority. Otherwise a + /// hand-typed LAN origin (`priority: 0`) could win after restart and the + /// rotation would hand the token to cleartext again. Typing a local + /// address resets `activeEndpoint`, so priority remains the escape hatch. public var orderedEndpoints: [CompanionEndpoint] { var candidates = endpoints ?? [] if !candidates.isEmpty { @@ -329,8 +329,9 @@ extension Connection { ? $0.offset < $1.offset : $0.element.priority < $1.element.priority }.map(\.element) - if let activeEndpoint, activeEndpoint.protectsCredentials { - candidates = [activeEndpoint] + candidates.filter { $0.url != activeEndpoint.url } + if activeEndpoint?.protectsCredentials == true { + candidates = candidates.filter(\.protectsCredentials) + + candidates.filter { !$0.protectsCredentials } } } else { candidates = orderedHosts.enumerated().compactMap { offset, candidate in