Skip to content
A fast and stable DHT crawler.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
example
lib
.babelrc
.gitignore
.travis.yml
LICENSE
README.md
jest.init.js
package.json
yarn.lock

README.md

node-dht-peer-crawler

Travis Build Status Coverage Status MIT licensed npm version Downloads

A fast and stable DHT crawler.

Installation

$ npm install dht-peer-crawler

Usage

import Crawler from 'dht-peer-crawler'

const crawler = new Crawler()

crawler.on('announce_peer', (infoHashStr, addressStr) => {
  console.log(`got a peer ${addressStr} on ${infoHashStr}`)
})

crawler.start().then(() => {
  console.log('start crawler success')
}, (error) => {
  console.error(`start crawler failed: ${error}`)
})

const signalTraps = ['SIGTERM', 'SIGINT', 'SIGUSR2']

signalTraps.map(type => {
  process.once(type, async () => {
    try {
      await crawler.stop()
      console.log('stop crawler success')
    } finally {
      process.kill(process.pid, type)
    }
  })
})

Test

$ npm test

API

crawler = new Crawler(listenPort)

Create a new crawler instance.

crawler.announcePeers(infoHashStr, port)

announce the peer.

crawler.on('announce_peer', [infoHashStr, addressStr, impliedPort, torrent])

Emitted when received an announce_peer message.

crawler.on('new_info_hash', [infoHashStr])

Emitted when find a new info_hash.

You can’t perform that action at this time.