UNPKG

1.61 kBMarkdownView Raw
1# compact2string
2
3Convert bittorrent's [compact](http://wiki.theory.org/BitTorrent_Tracker_Protocol#Peer_Dictionary_Format) ip/host binary returned by Trackers to 'hostname:port' string.
4
5[![Build Status](https://travis-ci.org/bencevans/node-compact2string.png?branch=master)](https://travis-ci.org/bencevans/node-compact2string)
6[![Coverage Status](https://coveralls.io/repos/bencevans/node-compact2string/badge.png?branch=master)](https://coveralls.io/r/bencevans/node-compact2string?branch=master)
7[![Dependency Status](https://david-dm.org/bencevans/node-compact2string.png)](https://david-dm.org/bencevans/node-compact2string)
8
9[![browser support](https://ci.testling.com/bencevans/node-compact2string.png)
10](https://ci.testling.com/bencevans/node-compact2string)
11
12Need the reverse of this? Checkout https://github.com/feross/string2compact
13
14## Installation
15
16```npm install compact2string```
17
18## Usage
19
20### Single compact2string
21
22```javascript
23var compact2string = require("compact2string");
24var Buffer = require("buffer").Buffer;
25var ipport = compact2string(new Buffer("0A0A0A05FF80", "hex"));
26console.log(ipport);
27```
28
29=> ```"10.10.10.5:65408" ```
30
31```javascript
32ipport = compact2string(new Buffer("2a03288021109f07faceb00c000000010050", "hex"));
33console.log(ipport);
34```
35
36=> ```"[2a03:2880:2110:9f07:face:b00c::1]:80" ```
37
38### Multiple in same buffer
39
40```javascript
41var hostports = compact2string.multi(new Buffer("0A0A0A05008064383a636f6d", "hex"));
42console.log(hostports);
43```
44
45=> ```[ '10.10.10.5:128', '100.56.58.99:28525' ]```
46
47IPv6 version: `compact2string.multi6()`
48
49## Licence
50
51(MIT Licence)
52
\No newline at end of file