ipv4-peers
An abstract-encoding compliant encoder for encoding a list of ipv4 peers to buffers
Last updated 5 years ago by mafintosh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install ipv4-peers 
SYNC missed versions from official npm registry.

ipv4-peers

An abstract-encoding compliant encoder for encoding a list of ipv4 peers to buffers.

npm install ipv4-peers

build status

Usage

var peers = require('ipv4-peers')

var buf = peers.encode([{
  host: '127.0.0.1',
  port: 8080
}, {
  host: '127.0.0.1',
  port: 9090
}])

console.log(buf) // 12 byte buffer
console.log(peers.decode(buf)) // 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

Current Tags

  • 2.0.0                                ...           latest (5 years ago)

4 Versions

  • 2.0.0                                ...           5 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)

Copyright 2013 - present © cnpmjs.org | Home |