Module: Rex::Proto::Kademlia

Defined in:
lib/rex/proto/kademlia/ping.rb,
lib/rex/proto/kademlia/pong.rb,
lib/rex/proto/kademlia/util.rb,
lib/rex/proto/kademlia/message.rb,
lib/rex/proto/kademlia/bootstrap_request.rb,
lib/rex/proto/kademlia/bootstrap_response.rb

Defined Under Namespace

Classes: BootstrapRequest, BootstrapResponse, Message, Ping, Pong

Constant Summary collapse

PING =

Opcode for a PING request

0x60
PONG =

Opcode for a PING response

0x61
BOOTSTRAP_REQUEST =

Opcode for a BOOTSTRAP request

0x01
BOOTSTRAP_RESPONSE =

Opcode for a bootstrap response

0x09

Class Method Summary collapse

Class Method Details

.decode_peer_id(bytes) ⇒ String

Decodes an on-the-wire representation of a Kademlia peer to its 16-character hex equivalent

Parameters:

  • bytes (String)

    the on-the-wire representation of a Kademlia peer

Returns:

  • (String)

    the peer ID if valid, nil otherwise



10
11
12
13
14
15
# File 'lib/rex/proto/kademlia/util.rb', line 10

def self.decode_peer_id(bytes)
  peer_id = 0
  return nil unless bytes.size == 16
  bytes.unpack('VVVV').map { |p| peer_id = ((peer_id << 32) ^ p) }
  peer_id.to_s(16).upcase
end