diff options
| author | mojganii <mojgan.jelodar@codic.se> | 2024-08-14 14:03:23 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2024-08-15 09:38:02 +0200 |
| commit | bdfd39740fdbf9c5462967c23a03e29aeece41d2 (patch) | |
| tree | 27ea3bacb29034e424ee7d865e1b3a67c252b3b7 /ios/MullvadVPN | |
| parent | 1283882cf051a68fe28b26ebbce93ae1bf0895b6 (diff) | |
| download | mullvadvpn-bdfd39740fdbf9c5462967c23a03e29aeece41d2.tar.xz mullvadvpn-bdfd39740fdbf9c5462967c23a03e29aeece41d2.zip | |
Add DAITA into TunnelSettings
Diffstat (limited to 'ios/MullvadVPN')
4 files changed, 8 insertions, 48 deletions
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift index 124ec57517..68b55ee9c9 100644 --- a/ios/MullvadVPN/AppDelegate.swift +++ b/ios/MullvadVPN/AppDelegate.swift @@ -79,9 +79,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD ipOverrideRepository: ipOverrideRepository ) - let constraintsUpdater = RelayConstraintsUpdater() - let multihopListener = MultihopStateListener() - let multihopUpdater = MultihopUpdater(listener: multihopListener) + let tunnelSettingsListener = TunnelSettingsListener() + let tunnelSettingsUpdater = SettingsUpdater(listener: tunnelSettingsListener) relayCacheTracker = RelayCacheTracker( relayCache: ipOverrideWrapper, @@ -95,16 +94,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD let relaySelector = RelaySelectorWrapper( relayCache: ipOverrideWrapper, - multihopUpdater: multihopUpdater + tunnelSettingsUpdater: tunnelSettingsUpdater ) tunnelManager = createTunnelManager(application: application, relaySelector: relaySelector) - settingsObserver = TunnelBlockObserver(didLoadConfiguration: { tunnelManager in - multihopListener.onNewMultihop?(tunnelManager.settings.tunnelMultihopState) - constraintsUpdater.onNewConstraints?(tunnelManager.settings.relayConstraints) - }, didUpdateTunnelSettings: { _, settings in - multihopListener.onNewMultihop?(settings.tunnelMultihopState) - constraintsUpdater.onNewConstraints?(settings.relayConstraints) + settingsObserver = TunnelBlockObserver(didUpdateTunnelSettings: { _, settings in + tunnelSettingsListener.onNewSettings?(settings) }) tunnelManager.addObserver(settingsObserver) @@ -124,8 +119,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD shadowsocksLoader = ShadowsocksLoader( cache: shadowsocksCache, relaySelector: shadowsocksRelaySelector, - constraintsUpdater: constraintsUpdater, - multihopUpdater: multihopUpdater + settingsUpdater: tunnelSettingsUpdater ) configuredTransportProvider = ProxyConfigurationTransportProvider( diff --git a/ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProviderHost.swift b/ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProviderHost.swift index 2bd8898e84..04ea6c1375 100644 --- a/ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProviderHost.swift +++ b/ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProviderHost.swift @@ -160,12 +160,7 @@ final class SimulatorTunnelProviderHost: SimulatorTunnelProviderDelegate { } private func pickRelays() throws -> SelectedRelays { - let tunnelSettings = try SettingsManager.readSettings() - - return try relaySelector.selectRelays( - with: tunnelSettings.relayConstraints, - connectionAttemptCount: 0 - ) + return try relaySelector.selectRelays(connectionAttemptCount: 0) } private func setInternalStateConnected(with selectedRelays: SelectedRelays?) { diff --git a/ios/MullvadVPN/TunnelManager/Tunnel+Settings.swift b/ios/MullvadVPN/TunnelManager/Tunnel+Settings.swift deleted file mode 100644 index 80c91b7618..0000000000 --- a/ios/MullvadVPN/TunnelManager/Tunnel+Settings.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// Tunnel+Settings.swift -// MullvadVPN -// -// Created by Mojgan on 2024-06-19. -// Copyright © 2024 Mullvad VPN AB. All rights reserved. -// - -import MullvadLogging -import MullvadSettings - -protocol TunnelSettingsStrategyProtocol { - func shouldReconnectToNewRelay(oldSettings: LatestTunnelSettings, newSettings: LatestTunnelSettings) -> Bool -} - -struct TunnelSettingsStrategy: TunnelSettingsStrategyProtocol { - func shouldReconnectToNewRelay(oldSettings: LatestTunnelSettings, newSettings: LatestTunnelSettings) -> Bool { - switch (oldSettings, newSettings) { - case let (old, new) where old.relayConstraints != new.relayConstraints, - let (old, new) where old.tunnelMultihopState != new.tunnelMultihopState: - true - default: - false - } - } -} diff --git a/ios/MullvadVPN/TunnelManager/TunnelManager.swift b/ios/MullvadVPN/TunnelManager/TunnelManager.swift index fb03fa2f18..2d663a048f 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelManager.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelManager.swift @@ -785,10 +785,7 @@ final class TunnelManager: StorePaymentObserver { fileprivate func selectRelays() throws -> SelectedRelays { let retryAttempts = tunnelStatus.observedState.connectionState?.connectionAttemptCount ?? 0 - return try relaySelector.selectRelays( - with: settings.relayConstraints, - connectionAttemptCount: retryAttempts - ) + return try relaySelector.selectRelays(connectionAttemptCount: retryAttempts) } fileprivate func prepareForVPNConfigurationDeletion() { |
