From 68ad70894f05692651e2bf49bb89e893104d9db6 Mon Sep 17 00:00:00 2001 From: Andrew Bulhak Date: Thu, 21 Mar 2024 10:45:53 +0100 Subject: [PATCH] Remove trailing spaces --- .../Actor/PacketTunnelActor+KeyPolicy.swift | 4 ++-- .../Actor/State+Extensions.swift | 4 ++-- ios/PacketTunnelCore/Actor/State.swift | 19 +++++++++---------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift index a49afd82a552..3084b21676f7 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift @@ -25,7 +25,7 @@ extension PacketTunnelActor { func cacheActiveKey(lastKeyRotation: Date?) { // There should be a way to rationalise these two identical functions into one. state.mutateAssociatedData { stateData in - guard + guard stateData.keyPolicy == .useCurrent, let currentKey = stateData.currentKey else { return } @@ -33,7 +33,7 @@ extension PacketTunnelActor { // Therefore perform the key switch as normal with one exception that it shouldn't reconnect the tunnel // automatically. stateData.lastKeyRotation = lastKeyRotation - + // Move currentKey into keyPolicy. stateData.keyPolicy = .usePrior(currentKey, startKeySwitchTask()) stateData.currentKey = nil diff --git a/ios/PacketTunnelCore/Actor/State+Extensions.swift b/ios/PacketTunnelCore/Actor/State+Extensions.swift index 014c34bb2c4f..024495c116da 100644 --- a/ios/PacketTunnelCore/Actor/State+Extensions.swift +++ b/ios/PacketTunnelCore/Actor/State+Extensions.swift @@ -129,12 +129,12 @@ extension State { var associatedData: StateAssociatedData = connState modifier(&associatedData) self = self.replacingConnectionData(with: associatedData as! ConnectionData) - + case let .error(blockedState): var associatedData: StateAssociatedData = blockedState modifier(&associatedData) self = .error(associatedData as! BlockingData) - + default: break } diff --git a/ios/PacketTunnelCore/Actor/State.swift b/ios/PacketTunnelCore/Actor/State.swift index 93484eb5c4e8..ff7c09307413 100644 --- a/ios/PacketTunnelCore/Actor/State.swift +++ b/ios/PacketTunnelCore/Actor/State.swift @@ -109,39 +109,39 @@ extension State { struct ConnectionData: Equatable, StateAssociatedData { /// Current selected relay. public var selectedRelay: SelectedRelay - + /// Last relay constraints read from settings. /// This is primarily used by packet tunnel for updating constraints in tunnel provider. public var relayConstraints: RelayConstraints - + /// Last WG key read from settings. /// Can be `nil` if moved to `keyPolicy`. public var currentKey: PrivateKey? - + /// Policy describing the current key that should be used by the tunnel. public var keyPolicy: KeyPolicy - + /// Whether network connectivity outside of tunnel is available. public var networkReachability: NetworkReachability - + /// Connection attempt counter. /// Reset to zero once connection is established. public var connectionAttemptCount: UInt - + /// Last time packet tunnel rotated the key. public var lastKeyRotation: Date? - + /// Increment connection attempt counter by one, wrapping to zero on overflow. public mutating func incrementAttemptCount() { let (value, isOverflow) = connectionAttemptCount.addingReportingOverflow(1) connectionAttemptCount = isOverflow ? 0 : value } - + /// The actual endpoint fed to WireGuard, can be a local endpoint if obfuscation is used. public let connectedEndpoint: MullvadEndpoint /// Via which transport protocol was the connection made to the relay public let transportLayer: TransportLayer - + /// The remote port that was chosen to connect to `connectedEndpoint` public let remotePort: UInt16 } @@ -178,7 +178,6 @@ extension State { } } - /// Reason why packet tunnel entered error state. public enum BlockedStateReason: String, Codable, Equatable { /// Device is locked.