Class: Net::SSH::Transport::ServerVersion

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/net/ssh/transport/server_version.rb

Overview

Negotiates the SSH protocol version and trades information about server and client. This is never used directly--it is always called by the transport layer as part of the initialization process of the transport layer.

Note that this class also encapsulates the negotiated version, and acts as the authoritative reference for any queries regarding the version in effect.

Constant Summary collapse

PROTO_VERSION =

The SSH version string as reported by Net::SSH

"SSH-2.0-Ruby/Net::SSH_#{Net::SSH::Version::CURRENT} #{RUBY_PLATFORM}"
MAX_LINE_LENGTH =

Same limits as OpenSSH, so a server can't make us buffer its banner without bound (GHSA-r75w-7fhp-84w8).

8192
MAX_HEADER_LINES =
1024

Instance Attribute Summary collapse

Attributes included from Loggable

#logger

Instance Method Summary collapse

Methods included from Loggable

#debug, #error, #fatal, #info, #lwarn

Constructor Details

#initialize(socket, logger, timeout = nil) ⇒ ServerVersion

Instantiates a new ServerVersion and immediately (and synchronously) negotiates the SSH protocol in effect, using the given socket.



33
34
35
36
37
38
# File 'lib/net/ssh/transport/server_version.rb', line 33

def initialize(socket, logger, timeout = nil)
  @header = String.new
  @version = nil
  @logger = logger
  negotiate!(socket, timeout)
end

Instance Attribute Details

#header ⇒ Object (readonly)

Any header text sent by the server prior to sending the version.



26
27
28
# File 'lib/net/ssh/transport/server_version.rb', line 26

def header
  @header
end

#version ⇒ Object (readonly)

The version string reported by the server.



29
30
31
# File 'lib/net/ssh/transport/server_version.rb', line 29

def version
  @version
end