Skip to content

Commit 8b35703

Browse files
committed
This change is to add option version to SFTP session to override
HIGHEST_PROTOCOL_VERSION_SUPPORTED during negotiation. This parameter is useful when SFTP server has bug which terminates the connection before version negotiationi if correct version is not passed.
1 parent 9d4e24a commit 8b35703

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/net/sftp/session.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ class Session
7575
#
7676
# sftp = Net::SFTP::Session.new(ssh)
7777
# sftp.loop { sftp.opening? }
78-
def initialize(session, &block)
78+
def initialize(session, version = nil, &block)
7979
@session = session
80+
@version = version
8081
@input = Net::SSH::Buffer.new
8182
self.logger = session.logger
8283
@state = :closed
@@ -876,7 +877,7 @@ def when_subsystem_started(channel, success)
876877
channel.on_close(&method(:when_channel_closed))
877878
channel.on_process(&method(:when_channel_polled))
878879

879-
send_packet(FXP_INIT, :long, HIGHEST_PROTOCOL_VERSION_SUPPORTED)
880+
send_packet(FXP_INIT, :long, @version || HIGHEST_PROTOCOL_VERSION_SUPPORTED)
880881
end
881882

882883
# Called when the SSH server closes the underlying channel.

0 commit comments

Comments
 (0)