Class: HrrRbSftp::Protocol
- Inherits:
-
Object
- Object
- HrrRbSftp::Protocol
- Includes:
- Loggable
- Defined in:
- lib/hrr_rb_sftp/protocol.rb,
lib/hrr_rb_sftp/protocol/common.rb,
lib/hrr_rb_sftp/protocol/version1.rb,
lib/hrr_rb_sftp/protocol/version2.rb,
lib/hrr_rb_sftp/protocol/version3.rb,
lib/hrr_rb_sftp/protocol/common/packets.rb,
lib/hrr_rb_sftp/protocol/version1/packets.rb,
lib/hrr_rb_sftp/protocol/version2/packets.rb,
lib/hrr_rb_sftp/protocol/version3/packets.rb,
lib/hrr_rb_sftp/protocol/common/data_types.rb,
lib/hrr_rb_sftp/protocol/version1/data_types.rb,
lib/hrr_rb_sftp/protocol/version2/data_types.rb,
lib/hrr_rb_sftp/protocol/version3/data_types.rb,
lib/hrr_rb_sftp/protocol/version3/extensions.rb,
lib/hrr_rb_sftp/protocol/common/packets/packet.rb,
lib/hrr_rb_sftp/protocol/common/data_types/byte.rb,
lib/hrr_rb_sftp/protocol/version1/packets/packet.rb,
lib/hrr_rb_sftp/protocol/common/data_types/string.rb,
lib/hrr_rb_sftp/protocol/common/data_types/uint32.rb,
lib/hrr_rb_sftp/protocol/common/data_types/uint64.rb,
lib/hrr_rb_sftp/protocol/version1/data_types/attrs.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/extension.rb,
lib/hrr_rb_sftp/protocol/common/packets/001_ssh_fxp_init.rb,
lib/hrr_rb_sftp/protocol/common/data_types/extension_pair.rb,
lib/hrr_rb_sftp/protocol/common/data_types/extension_pairs.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/common/packets/002_ssh_fxp_version.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/version3/packets/014_ssh_fxp_mkdir.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/version2/packets/018_ssh_fxp_rename.rb,
lib/hrr_rb_sftp/protocol/version3/packets/101_ssh_fxp_status.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/version3/packets/020_ssh_fxp_symlink.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,
lib/hrr_rb_sftp/protocol/version3/packets/019_ssh_fxp_readlink.rb,
lib/hrr_rb_sftp/protocol/version3/packets/200_ssh_fxp_extended.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/fsync_at_openssh_com.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/hardlink_at_openssh_com.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/lsetstat_at_openssh_com.rb,
lib/hrr_rb_sftp/protocol/version3/packets/201_ssh_fxp_extended_reply.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/posix_rename_at_openssh_com.rb
Overview
This class implements SFTP protocol operations.
Defined Under Namespace
Modules: Common, Version1, Version2, Version3
Instance Attribute Summary
Attributes included from Loggable
Class Method Summary collapse
-
.extension_pairs(version) ⇒ Array
A list of extension-pair that the library supports.
-
.versions ⇒ Array
A list of SFTP protocol versions that the library supports.
Instance Method Summary collapse
-
#close_handles ⇒ Object
Closes opened and not closed handles.
-
#initialize(version, logger: nil) ⇒ Protocol
constructor
A new instance of Protocol.
-
#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(version, logger: nil) ⇒ Protocol
Returns a new instance of Protocol.
32 33 34 35 36 37 38 39 |
# File 'lib/hrr_rb_sftp/protocol.rb', line 32 def initialize version, logger: nil self.logger = logger @context = Hash.new @context[:version] = version @context[:handles] = Hash.new @packets = self.class.const_get(:"Version#{version}")::Packets.new(@context, logger: logger) end |
Class Method Details
.extension_pairs(version) ⇒ Array
Returns A list of extension-pair that the library supports.
19 20 21 22 23 24 25 26 |
# File 'lib/hrr_rb_sftp/protocol.rb', line 19 def self.extension_pairs version version_class = const_get(:"Version#{version}") if version_class.const_defined?(:Extensions) version_class::Extensions.extension_pairs else [] end end |
.versions ⇒ Array
Returns A list of SFTP protocol versions that the library supports.
12 13 14 |
# File 'lib/hrr_rb_sftp/protocol.rb', line 12 def self.versions constants.select{|c| c.to_s.start_with?("Version")}.map{|c| const_get(c)}.map{|klass| klass::PROTOCOL_VERSION} end |
Instance Method Details
#close_handles ⇒ Object
Closes opened and not closed handles.
54 55 56 57 58 59 60 61 |
# File 'lib/hrr_rb_sftp/protocol.rb', line 54 def close_handles log_info { "closing handles" } @context[:handles].each do |k, v| v.close rescue nil end @context[:handles].clear log_info { "handles closed" } end |
#respond_to(request_payload) ⇒ String
Responds to a request.
47 48 49 |
# File 'lib/hrr_rb_sftp/protocol.rb', line 47 def respond_to request_payload @packets.respond_to request_payload end |