package
Convert BitTorrent compact hostname & port buffer to a string 'hostname:port'
npm install compact2stringGitHub-flavored package documentation.
Across all versions, last 30 days.
139,378 in 30 days
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
70.4 kB
Includes dependencies.
Convert bittorrent's compact ip/host binary returned by Trackers to 'hostname:port' string.
Need the reverse of this? Checkout https://github.com/feross/string2compact
npm install compact2string
var compact2string = require("compact2string");
var Buffer = require("buffer").Buffer;
var ipport = compact2string(new Buffer("0A0A0A05FF80", "hex"));
console.log(ipport);=> "10.10.10.5:65408"
ipport = compact2string(new Buffer("2a03288021109f07faceb00c000000010050", "hex"));
console.log(ipport);=> "[2a03:2880:2110:9f07:face:b00c::1]:80"
var hostports = compact2string.multi(new Buffer("0A0A0A05008064383a636f6d", "hex"));
console.log(hostports);=> [ '10.10.10.5:128', '100.56.58.99:28525' ]
IPv6 version: compact2string.multi6()
MIT — see LICENSE for the full copyright and permission notice.
This MIT notice also applies to compact2string 1.4.1 (source revision
c68be5e).
That release’s package metadata says BSD, while its README says MIT; the
licence is clarified here as MIT. The already-published npm archive is unchanged.