From 55c7a9ef821d56f64693df0d709ea7b68a3c0f65 Mon Sep 17 00:00:00 2001 From: Jon Petersson Date: Thu, 19 Sep 2024 14:52:06 +0200 Subject: [PATCH] Fix compiler concurrency warnings, target level --- .../Relay/RelaySelectorProtocol.swift | 4 ++-- ios/MullvadTypes/AnyIPEndpoint.swift | 2 +- ios/MullvadTypes/Cancellable.swift | 6 +++--- ios/MullvadTypes/IPv4Endpoint.swift | 2 +- ios/MullvadTypes/IPv6Endpoint.swift | 2 +- ios/MullvadTypes/Location.swift | 2 +- ios/MullvadTypes/MullvadEndpoint.swift | 2 +- ios/MullvadTypes/RelayConstraint.swift | 2 +- ios/MullvadTypes/RelayConstraints.swift | 2 +- ios/MullvadTypes/RelayFilter.swift | 4 ++-- ios/MullvadTypes/RelayLocation.swift | 6 +++--- ios/MullvadTypes/TransportLayer.swift | 2 +- ios/MullvadVPN.xcodeproj/project.pbxproj | 16 ++++++++-------- .../PacketTunnelPathObserver.swift | 2 +- .../WireGuardAdapter/WgAdapter.swift | 4 ++-- .../Actor/EphemeralPeerNegotiationState.swift | 8 ++++---- ios/PacketTunnelCore/Actor/ObservedState.swift | 8 ++++---- .../PacketTunnelActor+ConnectionMonitoring.swift | 2 +- .../Actor/PacketTunnelActor+ErrorState.swift | 2 +- .../Actor/PacketTunnelActor+Extensions.swift | 1 + .../Actor/PacketTunnelActor+PostQuantum.swift | 2 +- .../Actor/PacketTunnelActor+SleepCycle.swift | 2 +- .../Actor/PacketTunnelActor.swift | 4 ++-- .../Actor/PacketTunnelActorCommand.swift | 2 +- .../Actor/PacketTunnelActorReducer.swift | 2 +- .../Actor/Protocols/TunnelAdapterProtocol.swift | 9 ++++----- ios/PacketTunnelCore/Actor/StartOptions.swift | 4 ++-- ios/PacketTunnelCore/Actor/State.swift | 8 ++++---- ios/PacketTunnelCore/Actor/Timings.swift | 2 +- ios/PacketTunnelCore/Pinger/Pinger.swift | 2 +- ios/PacketTunnelCore/Pinger/PingerProtocol.swift | 2 +- ios/PacketTunnelCore/Pinger/TunnelPinger.swift | 2 +- .../DefaultPathObserverProtocol.swift | 2 +- .../TunnelMonitor/TunnelDeviceInfoProtocol.swift | 2 +- .../TunnelMonitor/TunnelMonitor.swift | 2 +- .../TunnelMonitor/TunnelMonitorProtocol.swift | 4 ++-- .../TunnelMonitor/TunnelMonitorTimings.swift | 2 +- 37 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ios/MullvadREST/Relay/RelaySelectorProtocol.swift b/ios/MullvadREST/Relay/RelaySelectorProtocol.swift index 92d48a823938..d7070055e72c 100644 --- a/ios/MullvadREST/Relay/RelaySelectorProtocol.swift +++ b/ios/MullvadREST/Relay/RelaySelectorProtocol.swift @@ -19,7 +19,7 @@ public protocol RelaySelectorProtocol { } /// Struct describing the selected relay. -public struct SelectedRelay: Equatable, Codable { +public struct SelectedRelay: Equatable, Codable, Sendable { /// Selected relay endpoint. public let endpoint: MullvadEndpoint @@ -43,7 +43,7 @@ extension SelectedRelay: CustomDebugStringConvertible { } } -public struct SelectedRelays: Equatable, Codable { +public struct SelectedRelays: Equatable, Codable, Sendable { public let entry: SelectedRelay? public let exit: SelectedRelay public let retryAttempt: UInt diff --git a/ios/MullvadTypes/AnyIPEndpoint.swift b/ios/MullvadTypes/AnyIPEndpoint.swift index cf294c70282d..e90976a331a3 100644 --- a/ios/MullvadTypes/AnyIPEndpoint.swift +++ b/ios/MullvadTypes/AnyIPEndpoint.swift @@ -9,7 +9,7 @@ import Foundation import protocol Network.IPAddress -public enum AnyIPEndpoint: Hashable, Equatable, Codable, CustomStringConvertible { +public enum AnyIPEndpoint: Hashable, Equatable, Codable, CustomStringConvertible, Sendable { case ipv4(IPv4Endpoint) case ipv6(IPv6Endpoint) diff --git a/ios/MullvadTypes/Cancellable.swift b/ios/MullvadTypes/Cancellable.swift index 8f658a6da1a8..0bfd93825cfb 100644 --- a/ios/MullvadTypes/Cancellable.swift +++ b/ios/MullvadTypes/Cancellable.swift @@ -15,11 +15,11 @@ public protocol Cancellable { extension Operation: Cancellable {} /// An object representing a cancellation token. -public final class AnyCancellable: Cancellable { - private let block: (() -> Void)? +public final class AnyCancellable: Cancellable, Sendable { + private let block: (@Sendable () -> Void)? /// Create cancellation token with block handler. - public init(block: @escaping () -> Void) { + public init(block: @Sendable @escaping () -> Void) { self.block = block } diff --git a/ios/MullvadTypes/IPv4Endpoint.swift b/ios/MullvadTypes/IPv4Endpoint.swift index c0ed1e477112..2e771aaa3317 100644 --- a/ios/MullvadTypes/IPv4Endpoint.swift +++ b/ios/MullvadTypes/IPv4Endpoint.swift @@ -9,7 +9,7 @@ import Foundation import Network -public struct IPv4Endpoint: Hashable, Equatable, Codable, CustomStringConvertible { +public struct IPv4Endpoint: Hashable, Equatable, Codable, CustomStringConvertible, Sendable { public let ip: IPv4Address public let port: UInt16 diff --git a/ios/MullvadTypes/IPv6Endpoint.swift b/ios/MullvadTypes/IPv6Endpoint.swift index 5dd56a49829c..e65ce0f225fd 100644 --- a/ios/MullvadTypes/IPv6Endpoint.swift +++ b/ios/MullvadTypes/IPv6Endpoint.swift @@ -9,7 +9,7 @@ import Foundation import Network -public struct IPv6Endpoint: Hashable, Equatable, Codable, CustomStringConvertible { +public struct IPv6Endpoint: Hashable, Equatable, Codable, CustomStringConvertible, Sendable { public let ip: IPv6Address public let port: UInt16 diff --git a/ios/MullvadTypes/Location.swift b/ios/MullvadTypes/Location.swift index 13cf93542558..508454122083 100644 --- a/ios/MullvadTypes/Location.swift +++ b/ios/MullvadTypes/Location.swift @@ -9,7 +9,7 @@ import CoreLocation import Foundation -public struct Location: Codable, Equatable { +public struct Location: Codable, Equatable, Sendable { public var country: String public var countryCode: String public var city: String diff --git a/ios/MullvadTypes/MullvadEndpoint.swift b/ios/MullvadTypes/MullvadEndpoint.swift index 9c05111c8cb7..7d11fdd11b4c 100644 --- a/ios/MullvadTypes/MullvadEndpoint.swift +++ b/ios/MullvadTypes/MullvadEndpoint.swift @@ -10,7 +10,7 @@ import Foundation import Network /// Contains server data needed to connect to a single mullvad endpoint. -public struct MullvadEndpoint: Equatable, Codable { +public struct MullvadEndpoint: Equatable, Codable, Sendable { public let ipv4Relay: IPv4Endpoint public let ipv6Relay: IPv6Endpoint? public let ipv4Gateway: IPv4Address diff --git a/ios/MullvadTypes/RelayConstraint.swift b/ios/MullvadTypes/RelayConstraint.swift index 189bee95683c..dea997e7f525 100644 --- a/ios/MullvadTypes/RelayConstraint.swift +++ b/ios/MullvadTypes/RelayConstraint.swift @@ -10,7 +10,7 @@ import Foundation private let anyConstraint = "any" -public enum RelayConstraint: Codable, Equatable, +public enum RelayConstraint: Codable, Equatable, Sendable, CustomDebugStringConvertible where T: Codable & Equatable { case any case only(T) diff --git a/ios/MullvadTypes/RelayConstraints.swift b/ios/MullvadTypes/RelayConstraints.swift index b6396767d8a3..18241e095880 100644 --- a/ios/MullvadTypes/RelayConstraints.swift +++ b/ios/MullvadTypes/RelayConstraints.swift @@ -8,7 +8,7 @@ import Foundation -public struct RelayConstraints: Codable, Equatable, CustomDebugStringConvertible { +public struct RelayConstraints: Codable, Equatable, CustomDebugStringConvertible, Sendable { @available(*, deprecated, renamed: "locations") private var location: RelayConstraint = .only(.country("se")) diff --git a/ios/MullvadTypes/RelayFilter.swift b/ios/MullvadTypes/RelayFilter.swift index 48b5c0a326e9..73a48d7b9071 100644 --- a/ios/MullvadTypes/RelayFilter.swift +++ b/ios/MullvadTypes/RelayFilter.swift @@ -8,8 +8,8 @@ import Foundation -public struct RelayFilter: Codable, Equatable { - public enum Ownership: Codable { +public struct RelayFilter: Codable, Equatable, Sendable { + public enum Ownership: Codable, Sendable { case any case owned case rented diff --git a/ios/MullvadTypes/RelayLocation.swift b/ios/MullvadTypes/RelayLocation.swift index 279f3cb6bc8e..b2ef8fa95448 100644 --- a/ios/MullvadTypes/RelayLocation.swift +++ b/ios/MullvadTypes/RelayLocation.swift @@ -8,7 +8,7 @@ import Foundation -public enum RelayLocation: Codable, Hashable, CustomDebugStringConvertible { +public enum RelayLocation: Codable, Hashable, CustomDebugStringConvertible, Sendable { case country(String) case city(String, String) case hostname(String, String, String) @@ -107,7 +107,7 @@ public enum RelayLocation: Codable, Hashable, CustomDebugStringConvertible { } } -public struct UserSelectedRelays: Codable, Equatable { +public struct UserSelectedRelays: Codable, Equatable, Sendable { public let locations: [RelayLocation] public let customListSelection: CustomListSelection? @@ -118,7 +118,7 @@ public struct UserSelectedRelays: Codable, Equatable { } extension UserSelectedRelays { - public struct CustomListSelection: Codable, Equatable { + public struct CustomListSelection: Codable, Equatable, Sendable { /// The ID of the custom list that the selected relays belong to. public let listId: UUID /// Whether the selected relays are subnodes or the custom list itself. diff --git a/ios/MullvadTypes/TransportLayer.swift b/ios/MullvadTypes/TransportLayer.swift index b4a7e6c3cdd2..cb25c7249084 100644 --- a/ios/MullvadTypes/TransportLayer.swift +++ b/ios/MullvadTypes/TransportLayer.swift @@ -8,7 +8,7 @@ import Foundation -public enum TransportLayer: Codable { +public enum TransportLayer: Codable, Sendable { case udp case tcp } diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index eaac38f6895b..81f04b80e4f3 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -6664,7 +6664,7 @@ SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_STRICT_CONCURRENCY = minimal; + SWIFT_STRICT_CONCURRENCY = targeted; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -6704,7 +6704,7 @@ SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_STRICT_CONCURRENCY = minimal; + SWIFT_STRICT_CONCURRENCY = targeted; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -6810,7 +6810,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_PRECOMPILE_BRIDGING_HEADER = NO; - SWIFT_STRICT_CONCURRENCY = minimal; + SWIFT_STRICT_CONCURRENCY = targeted; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -6869,7 +6869,7 @@ SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_PRECOMPILE_BRIDGING_HEADER = NO; - SWIFT_STRICT_CONCURRENCY = minimal; + SWIFT_STRICT_CONCURRENCY = targeted; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -7514,7 +7514,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_PRECOMPILE_BRIDGING_HEADER = NO; - SWIFT_STRICT_CONCURRENCY = minimal; + SWIFT_STRICT_CONCURRENCY = targeted; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -7819,7 +7819,7 @@ SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_STRICT_CONCURRENCY = minimal; + SWIFT_STRICT_CONCURRENCY = targeted; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -8356,7 +8356,7 @@ SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_PRECOMPILE_BRIDGING_HEADER = NO; - SWIFT_STRICT_CONCURRENCY = minimal; + SWIFT_STRICT_CONCURRENCY = targeted; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -8657,7 +8657,7 @@ SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_STRICT_CONCURRENCY = minimal; + SWIFT_STRICT_CONCURRENCY = targeted; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; diff --git a/ios/PacketTunnel/PacketTunnelProvider/PacketTunnelPathObserver.swift b/ios/PacketTunnel/PacketTunnelProvider/PacketTunnelPathObserver.swift index 56953553dde2..8a7698901082 100644 --- a/ios/PacketTunnel/PacketTunnelProvider/PacketTunnelPathObserver.swift +++ b/ios/PacketTunnel/PacketTunnelProvider/PacketTunnelPathObserver.swift @@ -51,4 +51,4 @@ final class PacketTunnelPathObserver: DefaultPathObserverProtocol { } } -extension NetworkExtension.NWPath: NetworkPath {} +extension NetworkExtension.NWPath: @retroactive NetworkPath, @unchecked Sendable {} diff --git a/ios/PacketTunnel/WireGuardAdapter/WgAdapter.swift b/ios/PacketTunnel/WireGuardAdapter/WgAdapter.swift index dd2d562c2e57..7e8eb7f1335d 100644 --- a/ios/PacketTunnel/WireGuardAdapter/WgAdapter.swift +++ b/ios/PacketTunnel/WireGuardAdapter/WgAdapter.swift @@ -7,11 +7,11 @@ // import Foundation -import MullvadLogging +@preconcurrency import MullvadLogging import MullvadTypes import NetworkExtension import PacketTunnelCore -import WireGuardKit +@preconcurrency import WireGuardKit struct WgAdapter: TunnelAdapterProtocol { let logger = Logger(label: "WgAdapter") diff --git a/ios/PacketTunnelCore/Actor/EphemeralPeerNegotiationState.swift b/ios/PacketTunnelCore/Actor/EphemeralPeerNegotiationState.swift index 339e458ce266..1a06a82f278f 100644 --- a/ios/PacketTunnelCore/Actor/EphemeralPeerNegotiationState.swift +++ b/ios/PacketTunnelCore/Actor/EphemeralPeerNegotiationState.swift @@ -7,9 +7,9 @@ // import MullvadREST -import WireGuardKitTypes +@preconcurrency import WireGuardKitTypes -public enum EphemeralPeerNegotiationState: Equatable { +public enum EphemeralPeerNegotiationState: Equatable, Sendable { case single(EphemeralPeerRelayConfiguration) case multi(entry: EphemeralPeerRelayConfiguration, exit: EphemeralPeerRelayConfiguration) @@ -25,7 +25,7 @@ public enum EphemeralPeerNegotiationState: Equatable { } } -public struct EphemeralPeerRelayConfiguration: Equatable, CustomDebugStringConvertible { +public struct EphemeralPeerRelayConfiguration: Equatable, CustomDebugStringConvertible, Sendable { public let relay: SelectedRelay public let configuration: EphemeralPeerConfiguration @@ -39,7 +39,7 @@ public struct EphemeralPeerRelayConfiguration: Equatable, CustomDebugStringConve } } -public struct EphemeralPeerConfiguration: Equatable, CustomDebugStringConvertible { +public struct EphemeralPeerConfiguration: Equatable, CustomDebugStringConvertible, Sendable { public let privateKey: PrivateKey public let preSharedKey: PreSharedKey? public let allowedIPs: [IPAddressRange] diff --git a/ios/PacketTunnelCore/Actor/ObservedState.swift b/ios/PacketTunnelCore/Actor/ObservedState.swift index 8b3779284e85..16c4b08f9d0a 100644 --- a/ios/PacketTunnelCore/Actor/ObservedState.swift +++ b/ios/PacketTunnelCore/Actor/ObservedState.swift @@ -11,10 +11,10 @@ import Foundation import MullvadREST import MullvadTypes import Network -import WireGuardKitTypes +@preconcurrency import WireGuardKitTypes /// A serializable representation of internal state. -public enum ObservedState: Equatable, Codable { +public enum ObservedState: Equatable, Codable, Sendable { case initial case connecting(ObservedConnectionState) case reconnecting(ObservedConnectionState) @@ -26,7 +26,7 @@ public enum ObservedState: Equatable, Codable { } /// A serializable representation of internal connection state. -public struct ObservedConnectionState: Equatable, Codable { +public struct ObservedConnectionState: Equatable, Codable, Sendable { public var selectedRelays: SelectedRelays public var relayConstraints: RelayConstraints public var networkReachability: NetworkReachability @@ -65,7 +65,7 @@ public struct ObservedConnectionState: Equatable, Codable { } /// A serializable representation of internal blocked state. -public struct ObservedBlockedState: Equatable, Codable { +public struct ObservedBlockedState: Equatable, Codable, Sendable { public var reason: BlockedStateReason public var relayConstraints: RelayConstraints? diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+ConnectionMonitoring.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+ConnectionMonitoring.swift index 4c53a977b361..e6f2411d4e88 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+ConnectionMonitoring.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+ConnectionMonitoring.swift @@ -1,5 +1,5 @@ // -// Actor+ConnectionMonitoring.swift +// PacketTunnelActor+ConnectionMonitoring.swift // PacketTunnelCore // // Created by pronebird on 26/09/2023. diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+ErrorState.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+ErrorState.swift index 064445ff1ea6..d975801c6e00 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+ErrorState.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+ErrorState.swift @@ -9,7 +9,7 @@ import Foundation import MullvadTypes import Network -import WireGuardKitTypes +@preconcurrency import WireGuardKitTypes extension PacketTunnelActor { /** diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+Extensions.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+Extensions.swift index 3610c3ff5064..ac235066d9ca 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+Extensions.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+Extensions.swift @@ -7,6 +7,7 @@ // import Foundation +@preconcurrency import Combine extension PacketTunnelActor { /// Returns a stream yielding `ObservedState`. diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+PostQuantum.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+PostQuantum.swift index 3b3c5ad560ed..acaf205ab542 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+PostQuantum.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+PostQuantum.swift @@ -7,7 +7,7 @@ // import Foundation -import WireGuardKitTypes +@preconcurrency import WireGuardKitTypes extension PacketTunnelActor { /** diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+SleepCycle.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+SleepCycle.swift index c6339ce11ebe..f3e420ae97fe 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+SleepCycle.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+SleepCycle.swift @@ -1,5 +1,5 @@ // -// Actor+SleepCycle.swift +// PacketTunnelActor+SleepCycle.swift // PacketTunnelCore // // Created by pronebird on 26/09/2023. diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor.swift index 98dbeea262b7..218c3c8eaac6 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor.swift @@ -7,13 +7,13 @@ // import Foundation -import MullvadLogging +@preconcurrency import MullvadLogging import MullvadREST import MullvadRustRuntime import MullvadSettings import MullvadTypes import NetworkExtension -import WireGuardKitTypes +@preconcurrency import WireGuardKitTypes /** Packet tunnel state machine implemented as an actor. diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActorCommand.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActorCommand.swift index b677986d041b..38dcd0ba4206 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActorCommand.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActorCommand.swift @@ -11,7 +11,7 @@ import WireGuardKitTypes extension PacketTunnelActor { /// Describes events that the state machine handles. These can be user commands or non-user-initiated events - enum Event { + enum Event: Sendable { /// Start tunnel. case start(StartOptions) diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActorReducer.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActorReducer.swift index 3382baf2092a..ac9ff300abee 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActorReducer.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActorReducer.swift @@ -11,7 +11,7 @@ import WireGuardKitTypes extension PacketTunnelActor { /// A structure encoding an effect; each event will yield zero or more of those, which can then be sequentially executed. - enum Effect: Equatable { + enum Effect: Equatable, Sendable { case startDefaultPathObserver case stopDefaultPathObserver case startTunnelMonitor diff --git a/ios/PacketTunnelCore/Actor/Protocols/TunnelAdapterProtocol.swift b/ios/PacketTunnelCore/Actor/Protocols/TunnelAdapterProtocol.swift index ac992c76c99e..d1a93dae5259 100644 --- a/ios/PacketTunnelCore/Actor/Protocols/TunnelAdapterProtocol.swift +++ b/ios/PacketTunnelCore/Actor/Protocols/TunnelAdapterProtocol.swift @@ -9,11 +9,10 @@ import Foundation import MullvadTypes import Network - -import WireGuardKitTypes +@preconcurrency import WireGuardKitTypes /// Protocol describing interface for any kind of adapter implementing a VPN tunnel. -public protocol TunnelAdapterProtocol { +public protocol TunnelAdapterProtocol: Sendable { /// Start tunnel adapter or update active configuration. func start(configuration: TunnelAdapterConfiguration, daita: DaitaConfiguration?) async throws @@ -29,7 +28,7 @@ public protocol TunnelAdapterProtocol { } /// Struct describing tunnel adapter configuration. -public struct TunnelAdapterConfiguration { +public struct TunnelAdapterConfiguration: Sendable { public var privateKey: PrivateKey public var interfaceAddresses: [IPAddressRange] public var dns: [IPAddress] @@ -38,7 +37,7 @@ public struct TunnelAdapterConfiguration { } /// Struct describing a single peer. -public struct TunnelPeer { +public struct TunnelPeer: Sendable { public var endpoint: AnyIPEndpoint public var publicKey: PublicKey public var preSharedKey: PreSharedKey? diff --git a/ios/PacketTunnelCore/Actor/StartOptions.swift b/ios/PacketTunnelCore/Actor/StartOptions.swift index 9af92fe34ce2..25e38e93b3e3 100644 --- a/ios/PacketTunnelCore/Actor/StartOptions.swift +++ b/ios/PacketTunnelCore/Actor/StartOptions.swift @@ -10,7 +10,7 @@ import Foundation import MullvadREST /// Packet tunnel start options parsed from dictionary passed to packet tunnel with a call to `startTunnel()`. -public struct StartOptions { +public struct StartOptions: Sendable { /// The system that triggered the launch of packet tunnel. public var launchSource: LaunchSource @@ -36,7 +36,7 @@ public struct StartOptions { } /// The source facility that triggered a launch of packet tunnel extension. -public enum LaunchSource: String, CustomStringConvertible { +public enum LaunchSource: String, CustomStringConvertible, Sendable { /// Launched by the main bundle app using network extension framework. case app diff --git a/ios/PacketTunnelCore/Actor/State.swift b/ios/PacketTunnelCore/Actor/State.swift index 10a28b5a2486..dd6b3e342f00 100644 --- a/ios/PacketTunnelCore/Actor/State.swift +++ b/ios/PacketTunnelCore/Actor/State.swift @@ -87,7 +87,7 @@ enum State: Equatable { } /// Enum describing network availability. -public enum NetworkReachability: Equatable, Codable { +public enum NetworkReachability: Equatable, Codable, Sendable { case undetermined, reachable, unreachable } @@ -188,7 +188,7 @@ extension State { } /// Reason why packet tunnel entered error state. -public enum BlockedStateReason: String, Codable, Equatable { +public enum BlockedStateReason: String, Codable, Equatable, Sendable { /// Device is locked. case deviceLocked @@ -241,7 +241,7 @@ extension State.BlockingData { } /// Describes which relay the tunnel should connect to next. -public enum NextRelays: Equatable, Codable { +public enum NextRelays: Equatable, Codable, Sendable { /// Select next relays randomly. case random @@ -253,7 +253,7 @@ public enum NextRelays: Equatable, Codable { } /// Describes the reason for reconnection request. -public enum ActorReconnectReason: Equatable { +public enum ActorReconnectReason: Equatable, Sendable { /// Initiated by user. case userInitiated diff --git a/ios/PacketTunnelCore/Actor/Timings.swift b/ios/PacketTunnelCore/Actor/Timings.swift index 5a62f7b05858..947bbaf4a874 100644 --- a/ios/PacketTunnelCore/Actor/Timings.swift +++ b/ios/PacketTunnelCore/Actor/Timings.swift @@ -10,7 +10,7 @@ import Foundation import MullvadTypes /// Struct holding all timings used by tunnel actor. -public struct PacketTunnelActorTimings { +public struct PacketTunnelActorTimings: Sendable { /// Periodicity at which actor will attempt to restart when an error occurred on system boot when filesystem is locked until device is unlocked or tunnel adapter error. public var bootRecoveryPeriodicity: Duration diff --git a/ios/PacketTunnelCore/Pinger/Pinger.swift b/ios/PacketTunnelCore/Pinger/Pinger.swift index 69ae1ab5af35..c531c13db742 100644 --- a/ios/PacketTunnelCore/Pinger/Pinger.swift +++ b/ios/PacketTunnelCore/Pinger/Pinger.swift @@ -12,7 +12,7 @@ import Network // This is the legacy Pinger using native TCP/IP networking. /// ICMP client. -public final class Pinger: PingerProtocol { +public final class Pinger: PingerProtocol, @unchecked Sendable { // Socket read buffer size. private static let bufferSize = 65535 diff --git a/ios/PacketTunnelCore/Pinger/PingerProtocol.swift b/ios/PacketTunnelCore/Pinger/PingerProtocol.swift index 67c64c14482e..16b02e614f2f 100644 --- a/ios/PacketTunnelCore/Pinger/PingerProtocol.swift +++ b/ios/PacketTunnelCore/Pinger/PingerProtocol.swift @@ -29,7 +29,7 @@ public struct PingerSendResult { } /// A type capable of sending and receving ICMP traffic. -public protocol PingerProtocol { +public protocol PingerProtocol: Sendable { var onReply: ((PingerReply) -> Void)? { get set } func openSocket(bindTo interfaceName: String?, destAddress: IPv4Address) throws diff --git a/ios/PacketTunnelCore/Pinger/TunnelPinger.swift b/ios/PacketTunnelCore/Pinger/TunnelPinger.swift index f011fc9a01b8..b76786eda5e4 100644 --- a/ios/PacketTunnelCore/Pinger/TunnelPinger.swift +++ b/ios/PacketTunnelCore/Pinger/TunnelPinger.swift @@ -12,7 +12,7 @@ import Network import PacketTunnelCore import WireGuardKit -public final class TunnelPinger: PingerProtocol { +public final class TunnelPinger: PingerProtocol, @unchecked Sendable { private var sequenceNumber: UInt16 = 0 private let stateLock = NSRecursiveLock() private let pingQueue: DispatchQueue diff --git a/ios/PacketTunnelCore/TunnelMonitor/DefaultPathObserverProtocol.swift b/ios/PacketTunnelCore/TunnelMonitor/DefaultPathObserverProtocol.swift index d4d192fb743e..96bfb5d7ddd2 100644 --- a/ios/PacketTunnelCore/TunnelMonitor/DefaultPathObserverProtocol.swift +++ b/ios/PacketTunnelCore/TunnelMonitor/DefaultPathObserverProtocol.swift @@ -23,6 +23,6 @@ public protocol DefaultPathObserverProtocol { } /// A type that represents a network path. -public protocol NetworkPath { +public protocol NetworkPath: Sendable { var status: NetworkExtension.NWPathStatus { get } } diff --git a/ios/PacketTunnelCore/TunnelMonitor/TunnelDeviceInfoProtocol.swift b/ios/PacketTunnelCore/TunnelMonitor/TunnelDeviceInfoProtocol.swift index 829265c60732..efd29add7e5f 100644 --- a/ios/PacketTunnelCore/TunnelMonitor/TunnelDeviceInfoProtocol.swift +++ b/ios/PacketTunnelCore/TunnelMonitor/TunnelDeviceInfoProtocol.swift @@ -9,7 +9,7 @@ import Foundation /// A type that can provide statistics and basic information about tunnel device. -public protocol TunnelDeviceInfoProtocol { +public protocol TunnelDeviceInfoProtocol: Sendable { /// Returns tunnel interface name (i.e utun0) if available. var interfaceName: String? { get } diff --git a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift index e2b3dbd17bfc..360c29ee9218 100644 --- a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift +++ b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift @@ -13,7 +13,7 @@ import Network import NetworkExtension /// Tunnel monitor. -public final class TunnelMonitor: TunnelMonitorProtocol { +public final class TunnelMonitor: TunnelMonitorProtocol, @unchecked Sendable { private let tunnelDeviceInfo: TunnelDeviceInfoProtocol private let nslock = NSLock() diff --git a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitorProtocol.swift b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitorProtocol.swift index 0a47d01fb716..63677eb9ee4e 100644 --- a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitorProtocol.swift +++ b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitorProtocol.swift @@ -10,7 +10,7 @@ import Foundation import Network /// Tunnel monitor event. -public enum TunnelMonitorEvent { +public enum TunnelMonitorEvent: Sendable { /// Dispatched after receiving the first ping response case connectionEstablished @@ -20,7 +20,7 @@ public enum TunnelMonitorEvent { } /// A type that can provide tunnel monitoring. -public protocol TunnelMonitorProtocol: AnyObject { +public protocol TunnelMonitorProtocol: AnyObject, Sendable { /// Event handler that starts receiving events after the call to `start(probeAddress:)`. var onEvent: ((TunnelMonitorEvent) -> Void)? { get set } diff --git a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitorTimings.swift b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitorTimings.swift index 3bb689a47330..e2aa2fabb1bd 100644 --- a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitorTimings.swift +++ b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitorTimings.swift @@ -8,7 +8,7 @@ import MullvadTypes -public struct TunnelMonitorTimings { +public struct TunnelMonitorTimings: Sendable { /// Interval for periodic heartbeat ping issued when traffic is flowing. /// Should help to detect connectivity issues on networks that drop traffic in one of directions, /// regardless if tx/rx counters are being updated.