dht-infohash-crawler

0.3.2 • Public • Published

dht-infohash-crawler

Crawl the DHT network for resource infohashes

This module partially implements BEP-5 to listen on DHT network for infohashes. It's based on dontcontactme's nodeDHT. The example code shows how to create multipul crawler instances to boost the crawling speed. After getting infohashes from DHT network peers, bep9-metadata-dl can be used to fetch the metadata.

Features

  • Simple API
  • Find peers from the DHT network
  • Node.js event emitter based interface

Install

npm install dht-infohash-crawler

API

createCrawler(opts)

crawler.on('infohash', callbackFn(infohash, peerId, peerAddress) {})

Options are:

{ 
  address: '0.0.0.0',     // Listening address, (default='0.0.0.0') 
  port: 6881,             // Listening port (default=6881)
  kbucketSize: 128,       // Size of kbucket (default=128)
  name: 'crawler'         // Crawler name (default='crawler')
}

Example:

const createCrawler = require('dht-infohash-crawler');
 
const crawler = createCrawler();
crawler.on('infohash', (infohash, peerId, peerAddress) => {
  console.log(`magnet:?xt=urn:btih:${infohash} peerId: ${peerId} ` + 
    `from ${peerAddress.address}:${peerAddress.port}`);
  }
);

License

MIT © Hong Yan.

Package Sidebar

Install

npm i dht-infohash-crawler

Weekly Downloads

2

Version

0.3.2

License

MIT

Last publish

Collaborators

  • hongyan