Socket
Socket
Sign inDemoInstall

compact2string

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    compact2string

Convert BitTorrent compact hostname & port buffer to a string 'hostname:port'


Version published
Weekly downloads
3.5K
decreased by-9.36%
Maintainers
1
Install size
62.2 kB
Created
Weekly downloads
 

Readme

Source

compact2string

Convert bittorrent's compact ip/host binary returned by Trackers to 'hostname:port' string.

Build Status Coverage Status Dependency Status

browser support

Need the reverse of this? Checkout https://github.com/feross/string2compact

Installation

npm install compact2string

Usage

Single 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"

Multiple in same buffer

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()

Licence

(MIT Licence)

Keywords

FAQs

Last updated on 25 Feb 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc