diff --git a/shard.yml b/shard.yml index 33490e5..1e09ede 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,8 @@ name: ssh2 -version: 1.6.0 +version: 1.7.0 + +libraries: + libssh2: ">= 1.11.0" development_dependencies: ameba: diff --git a/src/lib_ssh2.cr b/src/lib_ssh2.cr index e657fa0..d416f78 100644 --- a/src/lib_ssh2.cr +++ b/src/lib_ssh2.cr @@ -282,6 +282,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 1358852..c867c32 100644 --- a/src/session.cr +++ b/src/session.cr @@ -405,6 +405,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, 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