summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Fazekas <mfazekas@szemafor.com>2016-04-24 05:24:27 +0200
committerMiklos Fazekas <mfazekas@szemafor.com>2016-05-01 13:59:19 +0200
commit9115c32e93ee574f4f3bfd68252ffc93e485249b (patch)
tree1cf5b9242c9b3aca8c51eb35515b2b7314a237bd
parente0ca4a97439357307210cf46ab7376de0d9affbd (diff)
downloadnet-ssh-9115c32e93ee574f4f3bfd68252ffc93e485249b.tar.gz
Send KEXINIT without waiting from server.
-rw-r--r--lib/net/ssh/test/socket.rb2
-rw-r--r--lib/net/ssh/transport/algorithms.rb6
-rw-r--r--lib/net/ssh/transport/session.rb1
-rw-r--r--test/transport/test_session.rb2
4 files changed, 9 insertions, 2 deletions
diff --git a/lib/net/ssh/test/socket.rb b/lib/net/ssh/test/socket.rb
index 76ff18e..877aad4 100644
--- a/lib/net/ssh/test/socket.rb
+++ b/lib/net/ssh/test/socket.rb
@@ -25,8 +25,8 @@ module Net; module SSH; module Test
@script = Script.new
- script.gets(:kexinit, 1, 2, 3, 4, "test", "ssh-rsa", "none", "none", "none", "none", "none", "none", "", "", false)
script.sends(:kexinit)
+ script.gets(:kexinit, 1, 2, 3, 4, "test", "ssh-rsa", "none", "none", "none", "none", "none", "none", "", "", false)
script.sends(:newkeys)
script.gets(:newkeys)
end
diff --git a/lib/net/ssh/transport/algorithms.rb b/lib/net/ssh/transport/algorithms.rb
index 6260473..861b193 100644
--- a/lib/net/ssh/transport/algorithms.rb
+++ b/lib/net/ssh/transport/algorithms.rb
@@ -116,6 +116,12 @@ module Net; module SSH; module Transport
prepare_preferred_algorithms!
end
+ # Start the algorithm negotation
+ def start
+ raise ArgumentError, "Cannot call start if it's negoitation started or done" if @pending || @initialized
+ send_kexinit
+ end
+
# Request a rekey operation. This will return immediately, and does not
# actually perform the rekey operation. It does cause the session to change
# state, however--until the key exchange finishes, no new packets will be
diff --git a/lib/net/ssh/transport/session.rb b/lib/net/ssh/transport/session.rb
index a8b303a..f4905a6 100644
--- a/lib/net/ssh/transport/session.rb
+++ b/lib/net/ssh/transport/session.rb
@@ -84,6 +84,7 @@ module Net; module SSH; module Transport
@server_version = ServerVersion.new(socket, logger, options[:timeout])
@algorithms = Algorithms.new(self, options)
+ @algorithms.start
wait { algorithms.initialized? }
rescue Errno::ETIMEDOUT
raise Net::SSH::ConnectionTimeout
diff --git a/test/transport/test_session.rb b/test/transport/test_session.rb
index 205908e..af354ca 100644
--- a/test/transport/test_session.rb
+++ b/test/transport/test_session.rb
@@ -309,7 +309,7 @@ module Transport
end
def algorithms
- @algorithms ||= stub("algorithms", :initialized? => true, :allow? => true)
+ @algorithms ||= stub("algorithms", :initialized? => true, :allow? => true, :start => true)
end
def session(options={})