Skip to content

Commit d7d410f

Browse files
Fix build on non-macOS Apple platforms (#164)
1 parent b8751cc commit d7d410f

File tree

10 files changed

+29
-0
lines changed

10 files changed

+29
-0
lines changed

Sources/NIOSSHServer/DataToBufferCodec.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if canImport(Foundation.Process)
16+
1517
import Dispatch
1618
import Foundation
1719
import NIOCore
@@ -57,3 +59,5 @@ func createOutboundConnection(targetHost: String, targetPort: Int, loop: EventLo
5759
channel.eventLoop.makeSucceededFuture(())
5860
}.connect(host: targetHost, port: targetPort)
5961
}
62+
63+
#endif // canImport(Foundation.Process)

Sources/NIOSSHServer/ExecHandler.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if canImport(Foundation.Process)
16+
1517
import Dispatch
1618
import Foundation
1719
import NIOCore
@@ -156,3 +158,5 @@ final class ExampleExecHandler: ChannelDuplexHandler {
156158
}
157159
}
158160
}
161+
162+
#endif // canImport(Foundation.Process)

Sources/NIOSSHServer/GlueHandler.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if canImport(Foundation.Process)
16+
1517
import NIOCore
1618

1719
final class GlueHandler {
@@ -122,3 +124,5 @@ extension GlueHandler: ChannelDuplexHandler {
122124
}
123125
}
124126
}
127+
128+
#endif // canImport(Foundation.Process)

Sources/NIOSSHServer/RemotePortForwarding.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if canImport(Foundation.Process)
16+
1517
import Dispatch
1618
import Foundation
1719
import NIOCore
@@ -97,3 +99,5 @@ final class RemotePortForwarderGlobalRequestDelegate: GlobalRequestDelegate {
9799
self.forwarder?.stopListening()
98100
}
99101
}
102+
103+
#endif // canImport(Foundation.Process)

Sources/NIOSSHServer/main.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if canImport(Foundation.Process)
16+
1517
import Crypto
1618
import Dispatch
1719
import NIOCore
@@ -85,3 +87,9 @@ let channel = try bootstrap.bind(host: "0.0.0.0", port: 2222).wait()
8587

8688
// Run forever
8789
try channel.closeFuture.wait()
90+
91+
#else // canImport(Foundation.Process)
92+
93+
fatalError("NIOSSHServer is only supported on platforms with Foundation.Process")
94+
95+
#endif // !canImport(Foundation.Process)

Tests/NIOSSHTests/SSHConnectionStateMachineTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ final class SSHConnectionStateMachineTests: XCTestCase {
591591
}
592592
}
593593

594+
@available(iOS 13.2, macOS 10.15, watchOS 6.1, tvOS 13.2, *)
594595
func testFirstBlockDecodedOnce() throws {
595596
let allocator = ByteBufferAllocator()
596597
let loop = EmbeddedEventLoop()

Tests/NIOSSHTests/SSHPackerSerializerTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ final class SSHPacketSerializerTests: XCTestCase {
243243
}
244244
}
245245

246+
@available(iOS 13.2, macOS 10.15, watchOS 6.1, tvOS 13.2, *)
246247
func testSequencePreservedBetweenPlainAndCypher() {
247248
let message = SSHMessage.newKeys
248249
let allocator = ByteBufferAllocator()

Tests/NIOSSHTests/SSHPacketParserTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ final class SSHPacketParserTests: XCTestCase {
249249
XCTAssertEqual(parser._discardableBytes, 0)
250250
}
251251

252+
@available(iOS 13.2, macOS 10.15, watchOS 6.1, tvOS 13.2, *)
252253
func testSequencePreservedBetweenPlainAndCypher() throws {
253254
let allocator = ByteBufferAllocator()
254255
var parser = SSHPacketParser(isServer: false, allocator: allocator)

Tests/NIOSSHTests/Utilities.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct InsecureEncryptionAlgorithm {
9898
}
9999
}
100100

101+
@available(iOS 13.2, macOS 10.15, watchOS 6.1, tvOS 13.2, *)
101102
class TestTransportProtection: NIOSSHTransportProtection {
102103
enum TestError: Error {
103104
case doubleDecode

Tests/NIOSSHTests/UtilitiesTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ final class UtilitiesTests: XCTestCase {
2828
XCTAssertEqual(message, plaintext)
2929
}
3030

31+
@available(iOS 13.2, macOS 10.15, watchOS 6.1, tvOS 13.2, *)
3132
func testTestTransportProtection() throws {
3233
let inboundEncryptionKey = SymmetricKey(size: .bits128)
3334
let outboundEncryptionKey = SymmetricKey(size: .bits128)

0 commit comments

Comments
 (0)