Skip to content

Commit 4d66e69

Browse files
committed
Pass the timeout down to the SSH session
1 parent 9612c13 commit 4d66e69

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Sources/Shout/SSH.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class SSH {
4949
/// - Throws: SSHError if the SSH session couldn't be created
5050
public init(host: String, port: Int32 = 22, timeout: UInt = 0) throws {
5151
self.sock = try Socket.create()
52-
self.session = try Session()
52+
self.session = try Session(timeout: timeout)
5353

5454
session.blocking = 1
5555
try sock.connect(to: host, port: port, timeout: timeout)

Sources/Shout/Session.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Session {
2626
}
2727
}
2828

29-
init() throws {
29+
init(timeout: UInt = 0) throws {
3030
guard Session.initResult == 0 else {
3131
throw SSHError.genericError("libssh2_init failed")
3232
}
@@ -36,6 +36,7 @@ class Session {
3636
}
3737

3838
self.cSession = cSession
39+
libssh2_session_set_timeout(cSession, Int(timeout))
3940
}
4041

4142
func handshake(over socket: Socket) throws {

0 commit comments

Comments
 (0)