Class Net::SSH::Transport::State
In: lib/net/ssh/transport/state.rb
Parent: Object

Encapsulates state information about one end of an SSH connection. Such state includes the packet sequence number, the algorithms in use, how many packets and blocks have been processed since the last reset, and so forth. This class will never be instantiated directly, but is used as part of the internal state of the PacketStream module.

Methods

Attributes

block_size  [R]  The block size for the cipher
blocks  [R]  The number of data blocks processed since the last call to reset!
cipher  [R]  The cipher algorithm in use for this socket endpoint.
compression  [R]  The compression algorithm in use for this endpoint.
compression_level  [R]  The compression level to use when compressing data (or nil, for the default).
hmac  [R]  The hmac algorithm in use for this endpoint.
max_blocks  [RW]  The maximum number of blocks that this endpoint wants to process before needing a rekey.
max_packets  [RW]  The maximum number of packets that this endpoint wants to process before needing a rekey.
packets  [R]  The number of packets processed since the last call to reset!
rekey_limit  [RW]  The user-specified maximum number of bytes that this endpoint ought to process before needing a rekey.
role  [R]  The role that this state plays (either :client or :server)
sequence_number  [R]  The next packet sequence number for this socket endpoint.
socket  [R]  The socket object that owns this state object.

Public Class methods

Creates a new state object, belonging to the given socket. Initializes the algorithms to "none".

Public Instance methods

Closes any the compressor and/or decompressor objects that have been instantiated.

Compresses the data. If no compression is in effect, this will just return the data unmodified, otherwise it uses compressor to compress the data.

Returns true if data compression/decompression is enabled. This will return true if :standard compression is selected, or if :delayed compression is selected and the :authenticated hint has been received by the socket.

The compressor object to use when compressing data. This takes into account the desired compression level.

Deompresses the data. If no compression is in effect, this will just return the data unmodified, otherwise it uses decompressor to decompress the data.

The decompressor object to use when decompressing data.

Increments the counters. The sequence number is incremented (and remapped so it always fits in a 32-bit integer). The number of packets and blocks are also incremented.

Returns true if the number of packets processed exceeds the maximum number of packets, or if the number of blocks processed exceeds the maximum number of blocks.

Resets the counters on the state object, but leaves the sequence_number unchanged. It also sets defaults for and recomputes the max_packets and max_blocks values.

A convenience method for quickly setting multiple values in a single command.

[Validate]