Class: HrrRbSftp::Protocol::Version3::Packets::SSH_FXP_EXTENDED

Inherits:
Packets::Packet
  • Object
show all
Defined in:
lib/hrr_rb_sftp/protocol/version3/packets/200_ssh_fxp_extended.rb

Overview

This class implements SFTP protocol version 1 SSH_FXP_EXTENDED packet type, format, and responder.

Constant Summary collapse

TYPE =

Represents SSH_FXP_EXTENDED packet type.

200
FORMAT =

Represents SSH_FXP_EXTENDED packet format.

[
  [DataTypes::Byte,   :"type"            ],
  [DataTypes::Uint32, :"request-id"      ],
  [DataTypes::String, :"extended-request"],
]
CONDITIONAL_FORMAT =

Private method #conditional_format is used instead.

Examples:

{
  :"extended-request" => {
    "[email protected]" => [
      [DataTypes::String, :"oldpath"],
      [DataTypes::String, :"newpath"],
    ],
  },
}
nil

Instance Method Summary collapse

Instance Method Details

#respond_to(request) ⇒ Hash{Symbol=>Object}

Responds to SSH_FXP_EXTENDED request.

Parameters:

  • request (Hash{Symbol=>Object})

    SSH_FXP_EXTENDED request represented in Hash.

Returns:

  • (Hash{Symbol=>Object})

    Response represented in Hash. Its type is SSH_FXP_STATUS.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/hrr_rb_sftp/protocol/version3/packets/200_ssh_fxp_extended.rb', line 47

def respond_to request
  begin
    if extensions.respond_to? request
      extensions.respond_to request
    else
      {
        :"type"          => Packets::SSH_FXP_STATUS::TYPE,
        :"request-id"    => request[:"request-id"],
        :"code"          => Packets::SSH_FXP_STATUS::SSH_FX_OP_UNSUPPORTED,
        :"error message" => "Unsupported extended-request: #{request[:"extended-request"]}",
        :"language tag"  => "",
      }
    end
  rescue => e
    log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
    {
      :"type"          => Packets::SSH_FXP_STATUS::TYPE,
      :"request-id"    => request[:"request-id"],
      :"code"          => Packets::SSH_FXP_STATUS::SSH_FX_FAILURE,
      :"error message" => e.message,
      :"language tag"  => "",
    }
  end
end