summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2022-11-02 15:45:30 +0100
committerAndrej Mihajlov <and@mullvad.net>2022-11-02 15:45:30 +0100
commit23c4a466ea12903317390b451e608b81962e583b (patch)
tree144ef531e81899d9cb48791f33c59bb14cdff377
parent24f0f6628b8c5a25e8541cd82ba16581706745d2 (diff)
parent2db9b60dd431991455b6c769f54d7694a27f6ccb (diff)
downloadmullvadvpn-23c4a466ea12903317390b451e608b81962e583b.tar.xz
mullvadvpn-23c4a466ea12903317390b451e608b81962e583b.zip
Merge branch 'tunnel-sim-no-shared'
-rw-r--r--ios/MullvadVPN/AppDelegate.swift7
-rw-r--r--ios/MullvadVPN/SimulatorTunnelProviderHost.swift7
2 files changed, 11 insertions, 3 deletions
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift
index 75f41f0fb2..e52c680b05 100644
--- a/ios/MullvadVPN/AppDelegate.swift
+++ b/ios/MullvadVPN/AppDelegate.swift
@@ -21,7 +21,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
private var logger: Logger!
#if targetEnvironment(simulator)
- private let simulatorTunnelProvider = SimulatorTunnelProviderHost()
+ private var simulatorTunnelProviderHost: SimulatorTunnelProviderHost?
#endif
private let operationQueue: AsyncOperationQueue = {
@@ -47,7 +47,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
#if targetEnvironment(simulator)
// Configure mock tunnel provider on simulator
- SimulatorTunnelProvider.shared.delegate = simulatorTunnelProvider
+ simulatorTunnelProviderHost = SimulatorTunnelProviderHost(
+ relayCacheTracker: .shared
+ )
+ SimulatorTunnelProvider.shared.delegate = simulatorTunnelProviderHost
#endif
registerBackgroundTasks()
diff --git a/ios/MullvadVPN/SimulatorTunnelProviderHost.swift b/ios/MullvadVPN/SimulatorTunnelProviderHost.swift
index 688a6af3bc..6068036cfe 100644
--- a/ios/MullvadVPN/SimulatorTunnelProviderHost.swift
+++ b/ios/MullvadVPN/SimulatorTunnelProviderHost.swift
@@ -21,10 +21,15 @@ class SimulatorTunnelProviderHost: SimulatorTunnelProviderDelegate {
private var selectorResult: RelaySelectorResult?
private let urlSession = REST.makeURLSession()
private var proxiedRequests = [UUID: URLSessionDataTask]()
+ private let relayCacheTracker: RelayCacheTracker
private let providerLogger = Logger(label: "SimulatorTunnelProviderHost")
private let dispatchQueue = DispatchQueue(label: "SimulatorTunnelProviderHostQueue")
+ init(relayCacheTracker: RelayCacheTracker) {
+ self.relayCacheTracker = relayCacheTracker
+ }
+
override func startTunnel(
options: [String: NSObject]?,
completionHandler: @escaping (Error?) -> Void
@@ -158,7 +163,7 @@ class SimulatorTunnelProviderHost: SimulatorTunnelProviderDelegate {
}
private func pickRelay() throws -> RelaySelectorResult {
- let cachedRelays = try RelayCacheTracker.shared.getCachedRelays()
+ let cachedRelays = try relayCacheTracker.getCachedRelays()
let tunnelSettings = try SettingsManager.readSettings()
return try RelaySelector.evaluate(