diff --git a/Sources/Citadel/Client.swift b/Sources/Citadel/Client.swift index c319a3c..9457f4f 100644 --- a/Sources/Citadel/Client.swift +++ b/Sources/Citadel/Client.swift @@ -151,7 +151,8 @@ public final class SSHClient { reconnect: SSHReconnectMode, algorithms: SSHAlgorithms = SSHAlgorithms(), protocolOptions: Set = [], - group: MultiThreadedEventLoopGroup = .init(numberOfThreads: 1) + group: MultiThreadedEventLoopGroup = .init(numberOfThreads: 1), + connectTimeout:TimeAmount = .seconds(30) ) async throws -> SSHClient { let session = try await SSHClientSession.connect( host: host, @@ -160,7 +161,8 @@ public final class SSHClient { hostKeyValidator: hostKeyValidator, algorithms: algorithms, protocolOptions: protocolOptions, - group: group + group: group, + connectTimeout: connectTimeout ) let client = SSHClient( diff --git a/Sources/Citadel/ClientSession.swift b/Sources/Citadel/ClientSession.swift index 97f9a09..0795a5f 100644 --- a/Sources/Citadel/ClientSession.swift +++ b/Sources/Citadel/ClientSession.swift @@ -99,7 +99,8 @@ final class SSHClientSession { hostKeyValidator: SSHHostKeyValidator, algorithms: SSHAlgorithms = SSHAlgorithms(), protocolOptions: Set = [], - group: EventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1) + group: EventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1), + connectTimeout: TimeAmount = .seconds(30) ) async throws -> SSHClientSession { let handshakeHandler = ClientHandshakeHandler(eventLoop: group.next()) var clientConfiguration = SSHClientConfiguration( @@ -123,7 +124,7 @@ final class SSHClientSession { handshakeHandler ]) } - .connectTimeout(.seconds(30)) + .connectTimeout(connectTimeout) .channelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1) .channelOption(ChannelOptions.socket(SocketOptionLevel(IPPROTO_TCP), TCP_NODELAY), value: 1)