Skip to content

Commit

Permalink
Merge branch 'master' into upgrade-default-hash-alg
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach authored Nov 12, 2024
2 parents 2d4c682 + 1e3fc7d commit 1129632
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
5 changes: 4 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: ssh2
version: 1.6.0
version: 1.7.0

libraries:
libssh2: ">= 1.11.0"

development_dependencies:
ameba:
Expand Down
1 change: 1 addition & 0 deletions src/lib_ssh2.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions src/session.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/sftp/attributes.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1129632

Please sign in to comment.