Class: HrrRbSftp::Protocol::Version1::Packets
- Inherits:
-
Object
- Object
- HrrRbSftp::Protocol::Version1::Packets
- Includes:
- Loggable
- Defined in:
- lib/hrr_rb_sftp/protocol/version1/packets.rb,
lib/hrr_rb_sftp/protocol/version1/packets/packet.rb,
lib/hrr_rb_sftp/protocol/version1/packets/003_ssh_fxp_open.rb,
lib/hrr_rb_sftp/protocol/version1/packets/005_ssh_fxp_read.rb,
lib/hrr_rb_sftp/protocol/version1/packets/017_ssh_fxp_stat.rb,
lib/hrr_rb_sftp/protocol/version1/packets/103_ssh_fxp_data.rb,
lib/hrr_rb_sftp/protocol/version1/packets/104_ssh_fxp_name.rb,
lib/hrr_rb_sftp/protocol/version1/packets/004_ssh_fxp_close.rb,
lib/hrr_rb_sftp/protocol/version1/packets/006_ssh_fxp_write.rb,
lib/hrr_rb_sftp/protocol/version1/packets/007_ssh_fxp_lstat.rb,
lib/hrr_rb_sftp/protocol/version1/packets/008_ssh_fxp_fstat.rb,
lib/hrr_rb_sftp/protocol/version1/packets/014_ssh_fxp_mkdir.rb,
lib/hrr_rb_sftp/protocol/version1/packets/015_ssh_fxp_rmdir.rb,
lib/hrr_rb_sftp/protocol/version1/packets/105_ssh_fxp_attrs.rb,
lib/hrr_rb_sftp/protocol/version1/packets/013_ssh_fxp_remove.rb,
lib/hrr_rb_sftp/protocol/version1/packets/101_ssh_fxp_status.rb,
lib/hrr_rb_sftp/protocol/version1/packets/102_ssh_fxp_handle.rb,
lib/hrr_rb_sftp/protocol/version1/packets/009_ssh_fxp_setstat.rb,
lib/hrr_rb_sftp/protocol/version1/packets/011_ssh_fxp_opendir.rb,
lib/hrr_rb_sftp/protocol/version1/packets/012_ssh_fxp_readdir.rb,
lib/hrr_rb_sftp/protocol/version1/packets/010_ssh_fxp_fsetstat.rb,
lib/hrr_rb_sftp/protocol/version1/packets/016_ssh_fxp_realpath.rb
Overview
This class implements SFTP protocol version 1 packet types, formats, and responders.
Direct Known Subclasses
Defined Under Namespace
Classes: Packet, SSH_FXP_ATTRS, SSH_FXP_CLOSE, SSH_FXP_DATA, SSH_FXP_FSETSTAT, SSH_FXP_FSTAT, SSH_FXP_HANDLE, SSH_FXP_LSTAT, SSH_FXP_MKDIR, SSH_FXP_NAME, SSH_FXP_OPEN, SSH_FXP_OPENDIR, SSH_FXP_READ, SSH_FXP_READDIR, SSH_FXP_REALPATH, SSH_FXP_REMOVE, SSH_FXP_RMDIR, SSH_FXP_SETSTAT, SSH_FXP_STAT, SSH_FXP_STATUS, SSH_FXP_WRITE
Instance Attribute Summary
Attributes included from Loggable
Instance Method Summary collapse
-
#initialize(context, logger: nil) ⇒ Packets
constructor
A new instance of Packets.
-
#respond_to(request_payload) ⇒ String
Responds to a request.
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Constructor Details
#initialize(context, logger: nil) ⇒ Packets
Returns a new instance of Packets.
17 18 19 20 21 |
# File 'lib/hrr_rb_sftp/protocol/version1/packets.rb', line 17 def initialize context, logger: nil self.logger = logger @packets = packet_classes.map{|c| {c::TYPE => c.new(context, logger: logger)}}.inject({}, :merge) end |
Instance Method Details
#respond_to(request_payload) ⇒ String
Responds to a request.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hrr_rb_sftp/protocol/version1/packets.rb', line 30 def respond_to request_payload request_type = request_payload[0].unpack("C")[0] response_packet = if @packets.has_key?(request_type) request_packet = @packets[request_type].decode request_payload @packets[request_type].respond_to request_packet else raise RuntimeError, "Unsupported type: #{request_type}" end response_type = response_packet[:"type"] @packets[response_type].encode response_packet end |