Sha256: 3f14d7fa6f59859bc921a5dcb411723ff3276d9494da287e438f87d1f583a3fc

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

# -*- coding: binary -*-

module Rex
  module Proto
    module Rmi
      module Model
        # This class provides a representation of an RMI Ping stream. A Ping is a message for testing
        # livereness of a remote virtual machine.
        class Ping < Element

          # @!attribute stream_id
          #   @return [Fixnum] the input stream id
          attr_accessor :stream_id

          private

          # Reads the stream id from the IO
          #
          # @param io [IO] the IO to read from
          # @return [String]
          # @raise [Rex::Proto::Rmi::DecodeError] if fails to decode stream id
          def decode_stream_id(io)
            stream_id = read_byte(io)
            unless stream_id == PING_MESSAGE
              raise Rex::Proto::Rmi::DecodeError, 'Failed to decode Ping stream id'
            end

            stream_id
          end

          # Encodes the stream_id field
          #
          # @return [String]
          def encode_stream_id
            [stream_id].pack('C')
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rex-2.0.13 lib/rex/proto/rmi/model/ping.rb
rex-2.0.12 lib/rex/proto/rmi/model/ping.rb
rex-2.0.11 lib/rex/proto/rmi/model/ping.rb
rex-2.0.10 lib/rex/proto/rmi/model/ping.rb
rex-2.0.9 lib/rex/proto/rmi/model/ping.rb