dht-infohash-pub

Crawls the DHT Network and publishes infohashes using ØMQ.

Usage no npm install needed!

<script type="module">
  import dhtInfohashPub from 'https://cdn.skypack.dev/dht-infohash-pub';
</script>

README

dht-infohash-pub

Crawl the DHT network for resource infohashes and publish them using ØMQ

This program wraps dht-infohash-crawler in a Node.js command line executive.

Features

  • Option to create multiple DHT crawler instances
  • Find peers from the DHT network

Requirement

Install ØMQ for your platform. And then install ØMQ bindings for Node.js.

npm install zmq

If Node.js is upgraded or downgraded after npm install zmq, please run npm rebuild to rebuild ØMQ bindings.

If you experience binding problems like Error: Could not locate the bindings file., please change to dht-infohash-pub's directory and run npm rebuild to rebuild ØMQ bindings.

Install

npm install dht-infohash-pub

Usage:

node dht-infohash-pub.js [options]

  Options:

    -h, --help          output usage information
    -V, --version       output the version number
    -q, --quiet         Do not log infohashes to the console
    -n, --number <n>    Number of crawler instance, default = 2
    -a, --dhtaddr <da>  DHT network listening address, default = 0.0.0.0
    -p, --dhtport <dp>  DHT network listening port, default = 6881
    -k, --kbucket <k>   DHT k-bucket size, default = 128
    --zmqaddr <za>      ØMQ publishing address, default = 0.0.0.0
    --zmqport <zp>      ØMQ publishing port, default = 65534

Subscribe to the ØMQ publisher:

const zmq = require('zmq');
const sub = zmq.socket('sub');

sub.on('message', function (...args) {
  console.log(`${args.reduce((prev, curr) => prev+curr)}`);
});
sub.connect('tcp://PUBLISHER_IP_ADDRESS:PUBLISHER_PORT');
sub.subscribe('');

Subscribe to the ØMQ publisher, use subscriber side filter:

const zmq = require('zmq');
const sub = zmq.socket('sub');

sub.on('message', function (...args) {
  console.log(`${args.reduce((prev, curr) => prev+curr)}`);
});
sub.connect('tcp://PUBLISHER_IP_ADDRESS:PUBLISHER_PORT');
// Only subscribe to infohashes starting from '89abcdef'
['8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
  .map(letter => sub.subscribe(letter));

License

MIT © Hong Yan.