Class: Net::SFTP::Protocol::Base

Class | Net::SFTP::Protocol::Base
In: | lib/net/sftp/protocol/base.rb lib/net/sftp/protocol/base.rb
Parent: | Object

The abstract superclass of the specific implementations for each supported SFTP protocol version. It implements general packet parsing logic, and provides a way for subclasses to send requests.

### Methods

new new parse parse

### Included Modules

Net::SSH::Loggable Net::SFTP::Constants Net::SFTP::Constants::PacketTypes Net::SSH::Loggable Net::SFTP::Constants Net::SFTP::Constants::PacketTypes

### Attributes

session | [R] | The SFTP session object that acts as client to this protocol instance
session | [R] | The SFTP session object that acts as client to this protocol instance

### Public Class methods

new(session)

Create a new instance of a protocol driver, servicing the given session.

[Source]

        # File lib/net/sftp/protocol/base.rb, line 18
    18:     def initialize(session)
    19:       @session = session
    20:       self.logger = session.logger
    21:       @request_id_counter = -1
    22:     end

new(session)

Create a new instance of a protocol driver, servicing the given session.

[Source]

        # File lib/net/sftp/protocol/base.rb, line 18
    18:     def initialize(session)
    19:       @session = session
    20:       self.logger = session.logger
    21:       @request_id_counter = -1
    22:     end

### Public Instance methods

parse(packet)

Attept to parse the given packet. If the packet is of an unsupported type, an exception will be raised. Returns the parsed data as a hash (the keys in the hash are packet-type specific).

[Source]

        # File lib/net/sftp/protocol/base.rb, line 27
    27:     def parse(packet)
    28:       case packet.type
    29:       when FXP_STATUS then parse_status_packet(packet)
    30:       when FXP_HANDLE then parse_handle_packet(packet)
    31:       when FXP_DATA   then parse_data_packet(packet)
    32:       when FXP_NAME   then parse_name_packet(packet)
    33:       when FXP_ATTRS  then parse_attrs_packet(packet)
    34:       else raise NotImplementedError, "unknown packet type: #{packet.type}"
    35:       end
    36:     end

parse(packet)

Attept to parse the given packet. If the packet is of an unsupported type, an exception will be raised. Returns the parsed data as a hash (the keys in the hash are packet-type specific).

[Source]

        # File lib/net/sftp/protocol/base.rb, line 27
    27:     def parse(packet)
    28:       case packet.type
    29:       when FXP_STATUS then parse_status_packet(packet)
    30:       when FXP_HANDLE then parse_handle_packet(packet)
    31:       when FXP_DATA   then parse_data_packet(packet)
    32:       when FXP_NAME   then parse_name_packet(packet)
    33:       when FXP_ATTRS  then parse_attrs_packet(packet)
    34:       else raise NotImplementedError, "unknown packet type: #{packet.type}"
    35:       end
    36:     end

[Validate]