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',
port: 6881,
kbucketSize: 128,
name: '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.