Skip to content

Commit

Permalink
Removed SOCK5 negotiate fix from Net::SSH::Proxy::SOCKS5 and applied …
Browse files Browse the repository at this point in the history
…a new fix to ServerVersion#negotiate!
  • Loading branch information
delano committed Aug 11, 2009
1 parent 0b06816 commit 570c038
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

=== 2.0.13 / ?? Aug 2009

* Applied patch for Socks5 negotiation fix [Gerald Talton]
* Added fix for hanging in ServerVersion#negotiate! when using SOCKS5 proxy [Delano Mandelbaum, Gerald Talton]

* Added support for specifying a list of hosts in .ssh/config, with tests (GH-6) [Delano Mandelbaum]

Expand Down
26 changes: 5 additions & 21 deletions lib/net/ssh/proxy/socks5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,11 @@ def open(host, port)

packet << [port].pack("n")
socket.send packet, 0

version, reply = socket.recv(2).unpack("C*")
socket.recv(1)
address_type = socket.recv(1).getbyte(0)
if ( address_type == 1 )
socket.recv(4) # get four bytes for IPv4 address
else
if ( address_type == 3 )
len = socket.recv(1).getbyte(0)
hostname = socket.recv(len)
else
if ( address_type == 4 )
ipv6addr hostname = socket.recv(16)
else
socket.close
raise ConnectionError, "Illegal response type"
end
end
end
#portnum = socket.recv(2)


version, reply, = socket.recv(4).unpack("C*")
len = socket.recv(1).getbyte(0)
socket.recv(len + 2)

unless reply == SUCCESS
socket.close
raise ConnectError, "#{reply}"
Expand Down
2 changes: 2 additions & 0 deletions lib/net/ssh/transport/server_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def negotiate!(socket)
loop do
@version = ""
loop do
break unless socket.available_for_read?
b = socket.recv(1)

if b.nil?
raise Net::SSH::Disconnect, "connection closed by remote host"
end
Expand Down

0 comments on commit 570c038

Please sign in to comment.