New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bittorrent-dht

Package Overview
Dependencies
Maintainers
1
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bittorrent-dht

Simple, robust, BitTorrent DHT implementation

  • 0.7.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.9K
decreased by-2.14%
Maintainers
1
Weekly downloads
 
Created
Source

bittorrent-dht build npm npm downloads gittip

Simple, robust, BitTorrent DHT implementation

Node.js implementation of the BitTorrent DHT protocol. BitTorrent DHT is the main peer discovery layer for BitTorrent, which allows for trackerless torrents. DHTs are awesome!

This module is used by WebTorrent. Works in the browser with browserify and a dgram shim (like chrome-dgram for chrome apps).

install

npm install bittorrent-dht

example

npm install magnet-uri
var DHT    = require('bittorrent-dht');
var magnet = require('magnet-uri');

var uri = "magnet:?xt=urn:btih:e3811b9539cacff680e418124272177c47477157&dn=Ubuntu+13.10+Desktop+Live+ISO+amd64";
var parsed = magnet(uri);

var dht = new DHT();

dht.on('peer', function (addr, hash) {
  console.log('Found peer at ' + addr + '!');
});

dht.setInfoHash(parsed.infoHash);

var port = 20000;
dht.listen(port, function (port) {
  console.log("Now listening on port " + port);
});

dht.findPeers();

methods

setInfoHash(infoHash)

Associate an infoHash with the DHT object. Can be a String or Buffer.

dht.listen([port], [callback])

Open the socket. If port is undefined, one is picked with portfinder. callback is equivalent to listening event.

findPeers([num])

Get num peers from the DHT. Defaults to unlimited.

events

'peer'
function (addr, infoHash){ ... }

Called when a peer is found. addr is of the form IP_ADDRESS:PORT

'message'
function (data, rinfo){ ... }

Called when a message is received. rinfo is an object with properties address, port

'node'
function (addr){ ... }

Called when client finds a new DHT node.

'listening'
function () { ... }
'error'
function (err){ ... }

license

MIT. Copyright (c) Feross Aboukhadijeh.

Keywords

FAQs

Package last updated on 17 May 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc