Manages the negotiation of the version strings between client and server.

Methods
Constants
VERSION_LINE = /^SSH-/
  For processing the version header. The version reported by the server must match this pattern.
REQUIRED_VERSION_PATTERN = /^SSH-(1.99|2.0)-/
  Only versions matching this pattern are supported by Net::SSH.
Attributes
[R] header_lines An array of lines returned by the server prior to reporting the version.
Public Class methods
new( logger )

Creates a new VersionNegotiator object that logs to the given logger instance.

    # File lib/net/ssh/transport/version-negotiator.rb, line 40
40:         def initialize( logger )
41:           @logger = logger
42:         end
Public Instance methods
negotiate( socket, version )

Negotiate version information over the given socket. This will return the version reported by the server.

    # File lib/net/ssh/transport/version-negotiator.rb, line 46
46:         def negotiate( socket, version )
47:           server_version = ""
48:           @header_lines = []
49: 
50:           loop do
51:             server_version = socket.readline
52:             break if server_version.nil? || VERSION_LINE.match( server_version )
53:             @header_lines << server_version
54:           end
55: 
56:           if !REQUIRED_VERSION_PATTERN.match( server_version )
57:             raise Net::SSH::Exception,
58:               "incompatible ssh version #{server_version.inspect}"
59:           end
60: 
61:           if @logger.debug?
62:             @logger.debug "remote server is #{server_version.chomp.inspect}"
63:           end
64:           socket.print "#{version}\r\n"
65: 
66:           return server_version.chomp
67:         end

[Validate]