class Rex::Proto::Kademlia::Message
A simple Kademlia
message
Constants
- COMPRESSED_PACKET
The header that compressed Kad messages use, which is currently unsupported
- STANDARD_PACKET
The header that non-compressed Kad messages use
Attributes
body[R]
@return [String] the message body
type[R]
@return [Integer] the message type
Public Class Methods
from_data(data)
click to toggle source
Construct a new Message
from the provided data
@param data [String] the data to interpret as a Kademlia
message @return [Message] the message if valid, nil otherwise
# File lib/rex/proto/kademlia/message.rb, line 44 def self.from_data(data) return if data.length < 2 header, type = data.unpack('CC') if header == COMPRESSED_PACKET fail NotImplementedError, "Unable to handle #{data.length}-byte compressed Kademlia message" end return if header != STANDARD_PACKET Message.new(type, data[2, data.length]) end
new(type, body = '')
click to toggle source
Construct a new Message
from the provided type and body
@param type [String] the message type @param body [String] the message body
# File lib/rex/proto/kademlia/message.rb, line 35 def initialize(type, body = '') @type = type @body = body end
Public Instance Methods
==(other)
click to toggle source