Module: Net::SSH::Transport::PacketStream

Module | Net::SSH::Transport::PacketStream
In: | lib/net/ssh/transport/packet_stream.rb

A module that builds additional functionality onto the Net::SSH::BufferedIo module. It adds SSH encryption, compression, and packet validation, as per the SSH2 protocol. It also adds an abstraction for polling packets, to allow for both blocking and non-blocking reads.

### Methods

available_for_read? cleanup client_name enqueue_packet extended if_needs_rekey? initialize_ssh next_packet peer_ip poll_next_packet send_packet

### Included Modules

BufferedIo

### Attributes

client | [R] | The client state object, which encapsulates the algorithms used to build packets to send to the server.
hints | [R] | The map of "hints" that can be used to modify the behavior of the packet stream. For instance, when authentication succeeds, an "authenticated" hint is set, which is used to determine whether or not to compress the data when using the "delayed" compression algorithm.
server | [R] | The server state object, which encapsulates the algorithms used to interpret packets coming from the server.

### Public Class methods

extended(object)

### Public Instance methods

available_for_read?()

Returns true if the IO is available for reading, and false otherwise.

cleanup()

Performs any pending cleanup necessary on the IO and its associated state objects. (See State#cleanup).

client_name()

The name of the client (local) end of the socket, as reported by the socket.

enqueue_packet(payload)

Enqueues a packet to be sent, but does not immediately send the packet. The given payload is pre-processed according to the algorithms specified in the client state (compression, cipher, and hmac).

if_needs_rekey?() {|| ...}

If the IO object requires a rekey operation (as indicated by either its client or server state objects, see State#needs_rekey?), this will yield. Otherwise, this does nothing.

next_packet(mode=:nonblock)

Returns the next full packet. If the mode parameter is :nonblock (the default), then this will return immediately, whether a packet is available or not, and will return nil if there is no packet ready to be returned. If the mode parameter is :block, then this method will block until a packet is available.

peer_ip()

The IP address of the peer (remote) end of the socket, as reported by the socket.

send_packet(payload)

Enqueues a packet to be sent, and blocks until the entire packet is sent.

### Protected Instance methods

initialize_ssh()

Called when this module is used to extend an object. It initializes the states and generally prepares the object for use as a packet stream.

poll_next_packet()

Tries to read the next packet. If there is insufficient data to read an entire packet, this returns immediately, otherwise the packet is read, post-processed according to the cipher, hmac, and compression algorithms specified in the server state object, and returned as a new Packet object.

[Validate]