Path: blob/master/lib/rex/proto/kademlia/pong.rb
19778 views
# -*- coding: binary -*-123module Rex4module Proto5module Kademlia6# Opcode for a PING response7PONG = 0x6189# A Kademlia pong message.10class Pong < Message11# @return [Integer] the source port from which the PING was received12attr_reader :port1314def initialize(port = nil)15super(PONG)16@port = port17end1819# Builds a pong from given data20#21# @param data [String] the data to decode22# @return [Pong] the pong if the data is valid, nil otherwise23def self.from_data(data)24message = super(data)25return if message.type != PONG26return if message.body.size != 227Pong.new(message.body.unpack('v')[0])28end2930# Get this Pong as a String31#32# @return [String] the string representation of this Pong33def to_str34super + [@port].pack('v')35end36end37end38end39end404142