|
1 | 1 | import NIO |
2 | 2 | import NIOSSH |
| 3 | +import Logging |
3 | 4 |
|
4 | 5 | final class ClientHandshakeHandler: ChannelInboundHandler { |
5 | 6 | typealias InboundIn = Any |
6 | 7 |
|
7 | 8 | private let promise: EventLoopPromise<Void> |
| 9 | + let logger = Logger(label: "nl.orlandos.citadel.handshake") |
8 | 10 |
|
9 | 11 | /// A future that will be fulfilled when the handshake is complete. |
10 | 12 | public var authenticated: EventLoopFuture<Void> { |
11 | 13 | promise.futureResult |
12 | 14 | } |
13 | 15 |
|
14 | | - init(eventLoop: EventLoop) { |
| 16 | + init(eventLoop: EventLoop, loginTimeout: TimeAmount) { |
15 | 17 | let promise = eventLoop.makePromise(of: Void.self) |
16 | 18 | self.promise = promise |
17 | 19 | } |
@@ -54,7 +56,10 @@ final class SSHClientSession { |
54 | 56 | algorithms: SSHAlgorithms = SSHAlgorithms(), |
55 | 57 | protocolOptions: Set<SSHProtocolOption> = [] |
56 | 58 | ) async throws -> SSHClientSession { |
57 | | - let handshakeHandler = ClientHandshakeHandler(eventLoop: channel.eventLoop) |
| 59 | + let handshakeHandler = ClientHandshakeHandler( |
| 60 | + eventLoop: channel.eventLoop, |
| 61 | + loginTimeout: .seconds(10) |
| 62 | + ) |
58 | 63 | var clientConfiguration = SSHClientConfiguration( |
59 | 64 | userAuthDelegate: authenticationMethod(), |
60 | 65 | serverAuthDelegate: hostKeyValidator |
@@ -101,7 +106,10 @@ final class SSHClientSession { |
101 | 106 | group: EventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1), |
102 | 107 | connectTimeout: TimeAmount = .seconds(30) |
103 | 108 | ) async throws -> SSHClientSession { |
104 | | - let handshakeHandler = ClientHandshakeHandler(eventLoop: group.next()) |
| 109 | + let handshakeHandler = ClientHandshakeHandler( |
| 110 | + eventLoop: group.next(), |
| 111 | + loginTimeout: .seconds(10) |
| 112 | + ) |
105 | 113 | var clientConfiguration = SSHClientConfiguration( |
106 | 114 | userAuthDelegate: authenticationMethod(), |
107 | 115 | serverAuthDelegate: hostKeyValidator |
|
0 commit comments