diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 5bc3d03..cab22cb 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -17,12 +17,11 @@ jobs: name: Unit tests uses: apple/swift-nio/.github/workflows/unit_tests.yml@main with: - linux_5_10_arguments_override: "--explicit-target-dependency-import-check error" - linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors" - linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors" - linux_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors" - linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error" - linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error" + linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors" + linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors" + linux_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors" + linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" benchmarks: name: Benchmarks diff --git a/Benchmarks/Package.swift b/Benchmarks/Package.swift index 58a5f4c..b8e55a0 100644 --- a/Benchmarks/Package.swift +++ b/Benchmarks/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 import PackageDescription diff --git a/Package.swift b/Package.swift index 25ab3c5..121043f 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 //===----------------------------------------------------------------------===// // // This source file is part of the SwiftNIO open source project @@ -17,21 +17,13 @@ import PackageDescription let strictConcurrencyDevelopment = false -let strictConcurrencySettings: [SwiftSetting] = { - var initialSettings: [SwiftSetting] = [] - initialSettings.append(contentsOf: [ - .enableUpcomingFeature("StrictConcurrency"), - .enableUpcomingFeature("InferSendableFromCaptures"), - ]) +var swiftSettings: [SwiftSetting] = [] - if strictConcurrencyDevelopment { - // -warnings-as-errors here is a workaround so that IDE-based development can - // get tripped up on -require-explicit-sendable. - initialSettings.append(.unsafeFlags(["-Xfrontend", "-require-explicit-sendable", "-warnings-as-errors"])) - } - - return initialSettings -}() +if strictConcurrencyDevelopment { + // -warnings-as-errors here is a workaround so that IDE-based development can + // get tripped up on -require-explicit-sendable. + swiftSettings.append(.unsafeFlags(["-Xfrontend", "-require-explicit-sendable", "-warnings-as-errors"])) +} let package = Package( name: "swift-nio-ssh", @@ -59,7 +51,7 @@ let package = Package( .product(name: "Crypto", package: "swift-crypto"), .product(name: "Atomics", package: "swift-atomics"), ], - swiftSettings: strictConcurrencySettings + swiftSettings: swiftSettings ), .executableTarget( name: "NIOSSHClient", @@ -69,7 +61,7 @@ let package = Package( .product(name: "NIOPosix", package: "swift-nio"), .product(name: "NIOConcurrencyHelpers", package: "swift-nio"), ], - swiftSettings: strictConcurrencySettings + swiftSettings: swiftSettings ), .executableTarget( name: "NIOSSHServer", @@ -80,7 +72,7 @@ let package = Package( .product(name: "NIOFoundationCompat", package: "swift-nio"), .product(name: "Crypto", package: "swift-crypto"), ], - swiftSettings: strictConcurrencySettings + swiftSettings: swiftSettings ), .executableTarget( name: "NIOSSHPerformanceTester", @@ -90,7 +82,7 @@ let package = Package( .product(name: "NIOEmbedded", package: "swift-nio"), .product(name: "Crypto", package: "swift-crypto"), ], - swiftSettings: strictConcurrencySettings + swiftSettings: swiftSettings ), .testTarget( name: "NIOSSHTests", @@ -100,7 +92,7 @@ let package = Package( .product(name: "NIOEmbedded", package: "swift-nio"), .product(name: "NIOFoundationCompat", package: "swift-nio"), ], - swiftSettings: strictConcurrencySettings + swiftSettings: swiftSettings ), ] ) diff --git a/README.md b/README.md index 5deb362..9f40cfd 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ SwiftNIO SSH | Minimum Swift Version `0.6.2 ..< 0.9.0` | 5.6 `0.9.0 ..< 0.9.2` | 5.8 `0.9.2 ..< 0.10.0` | 5.9 -`0.10.0 ...` | 5.10 +`0.10.0 ... 0.12.0` | 5.10 +`0.12.0 ...` | 6.0 ## What does SwiftNIO SSH support? diff --git a/Sources/NIOSSH/Connection State Machine/Operations/AcceptsUserAuthMessages.swift b/Sources/NIOSSH/Connection State Machine/Operations/AcceptsUserAuthMessages.swift index 13746f3..19b8f6b 100644 --- a/Sources/NIOSSH/Connection State Machine/Operations/AcceptsUserAuthMessages.swift +++ b/Sources/NIOSSH/Connection State Machine/Operations/AcceptsUserAuthMessages.swift @@ -14,7 +14,7 @@ import NIOCore -protocol AcceptsUserAuthMessages { +protocol AcceptsUserAuthMessages: _NIOSSHSendableMetatype { var userAuthStateMachine: UserAuthenticationStateMachine { get set } var role: SSHConnectionRole { get } diff --git a/Sources/NIOSSH/Constants.swift b/Sources/NIOSSH/Constants.swift index 0ef5190..3540ecf 100644 --- a/Sources/NIOSSH/Constants.swift +++ b/Sources/NIOSSH/Constants.swift @@ -15,7 +15,8 @@ public enum Constants: Sendable { static let version = "SSH-2.0-SwiftNIOSSH_1.0" - public static let bundledTransportProtectionSchemes: [NIOSSHTransportProtection.Type] = [ - AES256GCMOpenSSHTransportProtection.self, AES128GCMOpenSSHTransportProtection.self, - ] + public static let bundledTransportProtectionSchemes: [(NIOSSHTransportProtection & _NIOSSHSendableMetatype).Type] = + [ + AES256GCMOpenSSHTransportProtection.self, AES128GCMOpenSSHTransportProtection.self, + ] } diff --git a/Sources/NIOSSH/Key Exchange/EllipticCurveKeyExchange.swift b/Sources/NIOSSH/Key Exchange/EllipticCurveKeyExchange.swift index 8d60dd2..c30177f 100644 --- a/Sources/NIOSSH/Key Exchange/EllipticCurveKeyExchange.swift +++ b/Sources/NIOSSH/Key Exchange/EllipticCurveKeyExchange.swift @@ -24,7 +24,7 @@ import Foundation /// This protocol defines a container used by the key exchange state machine to manage key exchange. /// This type erases the specific key exchanger. -protocol EllipticCurveKeyExchangeProtocol { +protocol EllipticCurveKeyExchangeProtocol: _NIOSSHSendableMetatype { init(ourRole: SSHConnectionRole, previousSessionIdentifier: ByteBuffer?) func initiateKeyExchangeClientSide(allocator: ByteBufferAllocator) -> SSHMessage.KeyExchangeECDHInitMessage diff --git a/Sources/NIOSSH/TransportProtection/AESGCM.swift b/Sources/NIOSSH/TransportProtection/AESGCM.swift index 690f5b6..ba5e47b 100644 --- a/Sources/NIOSSH/TransportProtection/AESGCM.swift +++ b/Sources/NIOSSH/TransportProtection/AESGCM.swift @@ -162,7 +162,7 @@ extension AESGCMTransportProtection: NIOSSHTransportProtection { /// algorithm, and instead by ignoring the result of the MAC negotiation. /// /// This algorithm does not encrypt the length field, instead encoding it as associated data. -final class AES128GCMOpenSSHTransportProtection: AESGCMTransportProtection { +final class AES128GCMOpenSSHTransportProtection: AESGCMTransportProtection, _NIOSSHSendableMetatype { override static var cipherName: String { "aes128-gcm@openssh.com" } @@ -182,7 +182,7 @@ final class AES128GCMOpenSSHTransportProtection: AESGCMTransportProtection { /// algorithm, and instead by ignoring the result of the MAC negotiation. /// /// This algorithm does not encrypt the length field, instead encoding it as associated data. -final class AES256GCMOpenSSHTransportProtection: AESGCMTransportProtection { +final class AES256GCMOpenSSHTransportProtection: AESGCMTransportProtection, _NIOSSHSendableMetatype { override static var cipherName: String { "aes256-gcm@openssh.com" } diff --git a/Sources/NIOSSH/_NIOSSHSendableMetatype.swift b/Sources/NIOSSH/_NIOSSHSendableMetatype.swift new file mode 100644 index 0000000..6f5ee31 --- /dev/null +++ b/Sources/NIOSSH/_NIOSSHSendableMetatype.swift @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftNIO open source project +// +// Copyright (c) 2019-2020 Apple Inc. and the SwiftNIO project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftNIO project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +#if compiler(>=6.2) +public typealias _NIOSSHSendableMetatype = SendableMetatype +#else +public typealias _NIOSSHSendableMetatype = Any +#endif