From 831fb52d4ab45fe89e2d3b87d577d8cdd798cd96 Mon Sep 17 00:00:00 2001 From: Steffen Ernst Date: Fri, 14 Feb 2025 13:30:51 +0100 Subject: [PATCH] Fix access method rotation after dns proxy failure --- ios/MullvadREST/Transport/TransportProvider.swift | 13 ++++++++++++- ios/MullvadRustRuntime/EncryptedDNSProxy.swift | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ios/MullvadREST/Transport/TransportProvider.swift b/ios/MullvadREST/Transport/TransportProvider.swift index ac08064eb40c..9573d5fdbda5 100644 --- a/ios/MullvadREST/Transport/TransportProvider.swift +++ b/ios/MullvadREST/Transport/TransportProvider.swift @@ -8,6 +8,7 @@ import Foundation import Logging +import MullvadRustRuntime import MullvadTypes public final class TransportProvider: RESTTransportProvider, Sendable { @@ -38,7 +39,8 @@ public final class TransportProvider: RESTTransportProvider, Sendable { let currentStrategy = transportStrategy return TransportWrapper(wrapped: actualTransport) { [weak self] error in - if let error = error as? URLError, error.shouldResetNetworkTransport { + if (error as? URLError)?.shouldResetNetworkTransport ?? false || + (error as? EncryptedDnsProxyError)?.shouldResetNetworkTransport ?? false { self?.resetTransportMatching(currentStrategy) } } @@ -104,6 +106,15 @@ public final class TransportProvider: RESTTransportProvider, Sendable { } } +private extension EncryptedDnsProxyError { + var shouldResetNetworkTransport: Bool { + switch self { + case .start: + return true + } + } +} + private extension URLError { /// Whether the transport selection should be reset. /// diff --git a/ios/MullvadRustRuntime/EncryptedDNSProxy.swift b/ios/MullvadRustRuntime/EncryptedDNSProxy.swift index 935ac27fa06e..b5929b5ba419 100644 --- a/ios/MullvadRustRuntime/EncryptedDNSProxy.swift +++ b/ios/MullvadRustRuntime/EncryptedDNSProxy.swift @@ -9,7 +9,7 @@ import Foundation import MullvadRustRuntimeProxy -enum EncryptedDnsProxyError: Error { +public enum EncryptedDnsProxyError: Error { case start(err: Int32) }