@@ -65,7 +65,7 @@ public struct SSHAlgorithms {
65
65
public final class SSHClient {
66
66
private( set) var session : SSHClientSession
67
67
private var userInitiatedClose = false
68
- let authenticationMethod : SSHAuthenticationMethod
68
+ let authenticationMethod : ( ) -> SSHAuthenticationMethod
69
69
let hostKeyValidator : SSHHostKeyValidator
70
70
internal var connectionSettings = SSHConnectionSettings ( )
71
71
private let algorithms : SSHAlgorithms
@@ -83,7 +83,7 @@ public final class SSHClient {
83
83
84
84
init (
85
85
session: SSHClientSession ,
86
- authenticationMethod: SSHAuthenticationMethod ,
86
+ authenticationMethod: @escaping @autoclosure ( ) -> SSHAuthenticationMethod ,
87
87
hostKeyValidator: SSHHostKeyValidator ,
88
88
algorithms: SSHAlgorithms = SSHAlgorithms ( ) ,
89
89
protocolOptions: Set < SSHProtocolOption >
@@ -111,21 +111,21 @@ public final class SSHClient {
111
111
/// - Returns: An SSH client.
112
112
public static func connect(
113
113
on channel: Channel ,
114
- authenticationMethod: SSHAuthenticationMethod ,
114
+ authenticationMethod: @escaping @autoclosure ( ) -> SSHAuthenticationMethod ,
115
115
hostKeyValidator: SSHHostKeyValidator ,
116
116
algorithms: SSHAlgorithms = SSHAlgorithms ( ) ,
117
117
protocolOptions: Set < SSHProtocolOption > = [ ]
118
118
) async throws -> SSHClient {
119
119
let session = try await SSHClientSession . connect (
120
120
on: channel,
121
- authenticationMethod: authenticationMethod,
121
+ authenticationMethod: authenticationMethod ( ) ,
122
122
hostKeyValidator: hostKeyValidator,
123
123
protocolOptions: protocolOptions
124
124
)
125
125
126
126
return SSHClient (
127
127
session: session,
128
- authenticationMethod: authenticationMethod,
128
+ authenticationMethod: authenticationMethod ( ) ,
129
129
hostKeyValidator: hostKeyValidator,
130
130
algorithms: algorithms,
131
131
protocolOptions: protocolOptions
@@ -222,7 +222,7 @@ public final class SSHClient {
222
222
self . session = try await SSHClientSession . connect (
223
223
host: host,
224
224
port: port,
225
- authenticationMethod: authenticationMethod,
225
+ authenticationMethod: self . authenticationMethod ( ) ,
226
226
hostKeyValidator: self . hostKeyValidator,
227
227
protocolOptions: protocolOptions,
228
228
group: session. channel. eventLoop
0 commit comments