From 4914ec8105f777bb6d595b8648003aa7b75b3552 Mon Sep 17 00:00:00 2001 From: Bug Magnet Date: Mon, 8 Apr 2024 17:17:37 +0200 Subject: [PATCH] Fix rebase issues --- .../Coordinators/ApplicationCoordinator.swift | 3 ++- .../MapConnectionStatusOperation.swift | 6 +++--- .../TunnelManager/StopTunnelOperation.swift | 3 ++- ios/MullvadVPN/TunnelManager/TunnelManager.swift | 2 +- ios/MullvadVPN/TunnelManager/TunnelState.swift | 9 +++++---- .../Tunnel/TunnelControlView.swift | 14 ++++++++------ .../Tunnel/TunnelViewController.swift | 2 +- .../Actor/PacketTunnelActor+KeyPolicy.swift | 4 ---- ios/PacketTunnelCore/Actor/State+Extensions.swift | 2 -- 9 files changed, 22 insertions(+), 23 deletions(-) diff --git a/ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift b/ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift index 673f0602049e..80352cdda2c8 100644 --- a/ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift @@ -980,7 +980,8 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo guard tunnelManager.deviceState.isLoggedIn else { return false } switch tunnelManager.tunnelStatus.state { - case .connected, .connecting, .reconnecting, .waitingForConnectivity(.noConnection), .error, .negotiatingKey: + case .connected, .connecting, .reconnecting, .waitingForConnectivity(.noConnection), .error, + .negotiatingPostQuantumKey: tunnelManager.reconnectTunnel(selectNewRelay: true) case .disconnecting, .disconnected: diff --git a/ios/MullvadVPN/TunnelManager/MapConnectionStatusOperation.swift b/ios/MullvadVPN/TunnelManager/MapConnectionStatusOperation.swift index a6a604569e0a..f92fd37e077b 100644 --- a/ios/MullvadVPN/TunnelManager/MapConnectionStatusOperation.swift +++ b/ios/MullvadVPN/TunnelManager/MapConnectionStatusOperation.swift @@ -57,9 +57,9 @@ class MapConnectionStatusOperation: AsyncOperation { return connectionState.isNetworkReachable ? .connecting(connectionState.selectedRelay) : .waitingForConnectivity(.noConnection) - case let .negotiatingPostQuantumKey(connectionState): - connectionState.isNetworkReachable - ? .negotiatingPostQuantumKey(connectionState.selectedRelay) + case let .negotiatingPostQuantumKey(connectionState, privateKey): + return connectionState.isNetworkReachable + ? .negotiatingPostQuantumKey(connectionState.selectedRelay, privateKey) : .waitingForConnectivity(.noConnection) case let .reconnecting(connectionState): return connectionState.isNetworkReachable diff --git a/ios/MullvadVPN/TunnelManager/StopTunnelOperation.swift b/ios/MullvadVPN/TunnelManager/StopTunnelOperation.swift index 0448de22fd49..1bd7a4f9c783 100644 --- a/ios/MullvadVPN/TunnelManager/StopTunnelOperation.swift +++ b/ios/MullvadVPN/TunnelManager/StopTunnelOperation.swift @@ -35,7 +35,8 @@ class StopTunnelOperation: ResultOperation { finish(result: .success(())) - case .connected, .connecting, .reconnecting, .waitingForConnectivity(.noConnection), .error, .negotiatingKey: + case .connected, .connecting, .reconnecting, .waitingForConnectivity(.noConnection), .error, + .negotiatingPostQuantumKey: doShutDownTunnel() case .disconnected, .disconnecting, .pendingReconnect, .waitingForConnectivity(.noNetwork): diff --git a/ios/MullvadVPN/TunnelManager/TunnelManager.swift b/ios/MullvadVPN/TunnelManager/TunnelManager.swift index 21e7bf546b84..eda2fa907e9e 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelManager.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelManager.swift @@ -675,7 +675,7 @@ final class TunnelManager: StorePaymentObserver { // while the tunnel process is trying to connect. startPollingTunnelStatus(interval: establishingTunnelStatusPollInterval) - case .negotiatingKey: + case .negotiatingPostQuantumKey: // No need to poll the tunnel while negotiating post quantum keys, assume the connection will work break diff --git a/ios/MullvadVPN/TunnelManager/TunnelState.swift b/ios/MullvadVPN/TunnelManager/TunnelState.swift index 7115c472d315..1d480fe3a53f 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelState.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelState.swift @@ -9,6 +9,7 @@ import Foundation import MullvadTypes import PacketTunnelCore +import WireGuardKitTypes /// A struct describing the tunnel status. struct TunnelStatus: Equatable, CustomStringConvertible { @@ -51,7 +52,7 @@ enum TunnelState: Equatable, CustomStringConvertible { case connecting(SelectedRelay?) /// Negotiating a key for post-quantum resistance - case negotiatingKey(SelectedRelay) + case negotiatingPostQuantumKey(SelectedRelay, PrivateKey) /// Connected the tunnel case connected(SelectedRelay) @@ -97,7 +98,7 @@ enum TunnelState: Equatable, CustomStringConvertible { "waiting for connectivity" case let .error(blockedStateReason): "error state: \(blockedStateReason)" - case let .negotiatingKey(tunnelRelay): + case let .negotiatingPostQuantumKey(tunnelRelay, _): "negotiating key with \(tunnelRelay.hostname)" } } @@ -109,14 +110,14 @@ enum TunnelState: Equatable, CustomStringConvertible { true case .pendingReconnect, .disconnecting, .disconnected, .waitingForConnectivity(.noNetwork), .error: false - case .negotiatingKey: + case .negotiatingPostQuantumKey: false } } var relay: SelectedRelay? { switch self { - case let .connected(relay), let .reconnecting(relay), let .negotiatingKey(relay): + case let .connected(relay), let .reconnecting(relay), let .negotiatingPostQuantumKey(relay, _): relay case let .connecting(relay): relay diff --git a/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift b/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift index 84be14ae43d3..75f26547476a 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift @@ -454,7 +454,7 @@ final class TunnelControlView: UIView { private extension TunnelState { var textColorForSecureLabel: UIColor { switch self { - case .connecting, .reconnecting, .waitingForConnectivity(.noConnection), .negotiatingKey: + case .connecting, .reconnecting, .waitingForConnectivity(.noConnection), .negotiatingPostQuantumKey: .white case .connected: @@ -484,7 +484,7 @@ private extension TunnelState { ) // TODO: Is this the correct message here ? - case .negotiatingKey: + case .negotiatingPostQuantumKey: NSLocalizedString( "TUNNEL_STATE_NEGOTIATING_KEY", tableName: "Main", @@ -567,7 +567,8 @@ private extension TunnelState { comment: "" ) - case .negotiatingKey: + // TODO: Is this correct ? + case .negotiatingPostQuantumKey: NSLocalizedString( "SWITCH_LOCATION_BUTTON_TITLE", tableName: "Main", @@ -587,7 +588,8 @@ private extension TunnelState { comment: "" ) - case .negotiatingKey: + // TODO: Is this correct ? + case .negotiatingPostQuantumKey: NSLocalizedString( "TUNNEL_STATE_CONNECTING_ACCESSIBILITY_LABEL", tableName: "Main", @@ -672,7 +674,7 @@ private extension TunnelState { .waitingForConnectivity(.noConnection): [.selectLocation, .cancel] - case .negotiatingKey: + case .negotiatingPostQuantumKey: [.selectLocation, .cancel] case .connected, .reconnecting, .error: @@ -688,7 +690,7 @@ private extension TunnelState { .waitingForConnectivity(.noConnection): [.cancel] - case .negotiatingKey: + case .negotiatingPostQuantumKey: [.cancel] case .connected, .reconnecting, .error: [.disconnect] diff --git a/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift b/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift index f257928386b6..ce7b72a9f357 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift @@ -152,7 +152,7 @@ class TunnelViewController: UIViewController, RootContainment { contentView.setAnimatingActivity(true) mapViewController.setCenter(tunnelRelay?.location.geoCoordinate, animated: animated) - case let .reconnecting(tunnelRelay), let .negotiatingKey(tunnelRelay): + case let .reconnecting(tunnelRelay), let .negotiatingPostQuantumKey(tunnelRelay, _): mapViewController.removeLocationMarker() contentView.setAnimatingActivity(true) mapViewController.setCenter(tunnelRelay.location.geoCoordinate, animated: animated) diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift index e0b49ada551b..9181a73edfd5 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift @@ -36,11 +36,7 @@ extension PacketTunnelActor { // Move currentKey into keyPolicy. stateData.keyPolicy = .usePrior(currentKey, startKeySwitchTask()) stateData.currentKey = nil - } - - _ = state.mutateConnectionState(connectionStateMutator) || - state.mutateBlockedState(blockedStateMutator) } /** diff --git a/ios/PacketTunnelCore/Actor/State+Extensions.swift b/ios/PacketTunnelCore/Actor/State+Extensions.swift index 93fe29f3b731..01913b4e24ce 100644 --- a/ios/PacketTunnelCore/Actor/State+Extensions.swift +++ b/ios/PacketTunnelCore/Actor/State+Extensions.swift @@ -95,7 +95,6 @@ extension State { let .disconnecting(connState): connState default: nil } - return modified } var blockedData: State.BlockingData? { @@ -149,7 +148,6 @@ extension State { default: break - } }