ipv4-peers
An abstract-encoding compliant encoder for encoding a list of ipv4 peers to buffers.
npm install ipv4-peers
Usage
var peers =var buf = peersconsole // 12 byte bufferconsole // the peer list
API
var buf = peers.encode(peerList, [buffer], [offset])
Encode a list of ipv4 peers into a buffer.
var peers = peers.decode(buffer, [offset], [end])
Decode a buffer into a list of peers.
var length = peers.encodingLength(peerList)
Returns the amount of bytes needed to encode the peers into a buffer
peers = peers.idLength(idByteLength)
Create a new ipv4-peers decoder that encodes/decodes a fixed size peer id in addition to host/port. The peer id is exposed as the .id
property on a peer object.
License
MIT