From 174f42bfec0c49654558583121be9a525f25194b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Peignier?= Date: Fri, 18 Aug 2023 15:27:14 -0700 Subject: [PATCH 1/4] Add support for channel_direct_streamlocal --- shard.yml | 3 +++ src/lib_ssh2.cr | 1 + src/session.cr | 15 +++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/shard.yml b/shard.yml index f3f0f8f..9b1b291 100644 --- a/shard.yml +++ b/shard.yml @@ -2,6 +2,9 @@ name: ssh2 version: 1.5.3 crystal: ">= 0.36.1" +libraries: + libssh2: ">= 1.11.0" + development_dependencies: ameba: github: veelenga/ameba diff --git a/src/lib_ssh2.cr b/src/lib_ssh2.cr index 370088d..d343165 100644 --- a/src/lib_ssh2.cr +++ b/src/lib_ssh2.cr @@ -279,6 +279,7 @@ Void*) -> Void message_len : UInt32) : Channel fun channel_direct_tcpip = libssh2_channel_direct_tcpip_ex(session : Session, host : UInt8*, port : Int32, shost : UInt8*, sport : Int32) : Channel + fun channel_direct_streamlocal = libssh2_channel_direct_streamlocal_ex(session : Session, socket_path : UInt8*, shost : UInt8*, sport : Int32) : Channel fun channel_close = libssh2_channel_close(ch : Channel) : Int32 fun channel_eof = libssh2_channel_eof(ch : Channel) : Int32 fun channel_process_startup = libssh2_channel_process_startup(ch : Channel, request : UInt8*, request_len : UInt32, diff --git a/src/session.cr b/src/session.cr index 1a0d4d8..554706d 100644 --- a/src/session.cr +++ b/src/session.cr @@ -385,6 +385,21 @@ class SSH2::Session end end + # Tunnel TCP/IP connect through the SSH session to direct UNIX socket. + def direct_streamlocal(path, host, port) + handle = nonblock_handle { LibSSH2.channel_direct_streamlocal(self, path, host, port) } + Channel.new self, handle + end + + def direct_streamlocal(path, host, port) + channel = direct_streamlocal(path, host, port) + begin + yield channel + ensure + channel.close + end + end + # Send a file to the remote host via SCP. def scp_send(path, mode, size, mtime, atime) handle = nonblock_handle { LibSSH2.scp_send(self, path, mode.to_i32, size.to_u64, From 03f70f3e69a43bc07f7acc2b2baaab6e859bb551 Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Mon, 21 Aug 2023 08:33:22 +1000 Subject: [PATCH 2/4] chore(shard.yml) bump version --- shard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shard.yml b/shard.yml index 9b1b291..018da2d 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: ssh2 -version: 1.5.3 +version: 1.6.0 crystal: ">= 0.36.1" libraries: From 7f78b60f20d2a117aa736b806a597d23737888b9 Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Tue, 6 Feb 2024 07:47:12 +1100 Subject: [PATCH 3/4] fix(sftp/attributes.cr): update time helpers --- src/sftp/attributes.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sftp/attributes.cr b/src/sftp/attributes.cr index 8daa642..8cd0c23 100644 --- a/src/sftp/attributes.cr +++ b/src/sftp/attributes.cr @@ -52,19 +52,19 @@ class SSH2::SFTP::Attributes end def atime - Time.unix(@stat.atime.to_i32) + Time.unix(@stat.atime.to_i64) end def atime=(v : Time) - @stat.atime = v.to_utc.to_i.to_u64 + @stat.atime = v.to_unix end def mtime - Time.epoch(@stat.mtime.to_i32) + Time.unix(@stat.mtime.to_i64) end def mtime=(v : Time) - @stat.mtime = v.to_utc.to_i.to_u64 + @stat.mtime = v.to_unix end def to_unsafe From 1e3fc7da3cc5d7689dea6b57e50e1713050f84fd Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Tue, 6 Feb 2024 07:47:42 +1100 Subject: [PATCH 4/4] chore(shard.yml): bump version --- shard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shard.yml b/shard.yml index 018da2d..695cafd 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: ssh2 -version: 1.6.0 +version: 1.6.1 crystal: ">= 0.36.1" libraries: