diff --git a/Sources/Citadel/Client.swift b/Sources/Citadel/Client.swift index 67a44f6..881bbb3 100644 --- a/Sources/Citadel/Client.swift +++ b/Sources/Citadel/Client.swift @@ -189,6 +189,8 @@ public final class SSHClient { /// - algorithms: The algorithms to use. See `SSHAlgorithms` for more information. /// - protocolOptions: The protocol options to use. See `SSHProtocolOption` for more information. /// - group: The event loop group to use. Defaults to a single-threaded event loop group. + /// - channelHandlers: Pass in an array of channel prehandlers that execute first. Default empty array + /// - connectTimeout: Pass in the time before the connection times out. Default 30 seconds. /// - Returns: An SSH client. public static func connect( host: String, @@ -199,6 +201,7 @@ public final class SSHClient { algorithms: SSHAlgorithms = SSHAlgorithms(), protocolOptions: Set = [], group: MultiThreadedEventLoopGroup = .init(numberOfThreads: 1), + channelHandlers: [ChannelHandler] = [], connectTimeout:TimeAmount = .seconds(30) ) async throws -> SSHClient { let session = try await SSHClientSession.connect( @@ -209,6 +212,7 @@ public final class SSHClient { algorithms: algorithms, protocolOptions: protocolOptions, group: group, + channelHandlers: channelHandlers, connectTimeout: connectTimeout ) diff --git a/Sources/Citadel/ClientSession.swift b/Sources/Citadel/ClientSession.swift index 68bcccc..111dd65 100644 --- a/Sources/Citadel/ClientSession.swift +++ b/Sources/Citadel/ClientSession.swift @@ -96,6 +96,8 @@ final class SSHClientSession { /// - algorithms: The algorithms to use, will use the default algorithms if not specified. /// - protocolOptions: The protocol options to use, will use the default options if not specified. /// - group: The event loop group to use, will use a new group with one thread if not specified. + /// - channelHandlers: Pass in an array of channel prehandlers that execute first. Default empty array + /// - connectTimeout: Pass in the time before the connection times out. Default 30 seconds. public static func connect( host: String, port: Int = 22, @@ -104,6 +106,7 @@ final class SSHClientSession { algorithms: SSHAlgorithms = SSHAlgorithms(), protocolOptions: Set = [], group: EventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1), + channelHandlers: [ChannelHandler] = [], connectTimeout: TimeAmount = .seconds(30) ) async throws -> SSHClientSession { let handshakeHandler = ClientHandshakeHandler( @@ -122,7 +125,7 @@ final class SSHClientSession { } let bootstrap = ClientBootstrap(group: group).channelInitializer { channel in - channel.pipeline.addHandlers([ + channel.pipeline.addHandlers(channelHandlers + [ NIOSSHHandler( role: .client(clientConfiguration), allocator: channel.allocator,