npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bittorrent-udp-tracker

v1.2.0

Published

udp tracker for bittorrent

Readme

Bittorrent Udp Tracker

udp tracker implementation for bittorrent.

js-standard-style

Features

  1. implemented spcification from here and here
  2. fully tested

Installation

npm i bittorrent-udp-tracker --save

Test

npm test

Usage

var UdpTracker = require('bittorrent-udp-tracker')

var udpTracker = new UdpTracker(new Buffer('01234567890123456789'), new Buffer('12345678901234567890'), announceUrl, {'port': 1234})
udpTracker.announce(2, {
  downloaded: 0,
  left: 0,
  uploaded: 0
})

udpTracker.on('error', function (err) {
  throw new Error(err)
})

udpTracker.on('update', function (msg) {
  console.log(msg)
  udpTracker.destory()
})

update event will return json stringified object. It will have following format

{
  leechers: 12,
  seeds: 12,
  peers: ['10.12.12.12.:1234', '109.12.90.15.:1234']
}

error event will return error message.

API

  1. new UdpTracker(peerId, infoHash, opts)

    It will return instance of UdpTracker.It is also instance of EventEmitter.

    
    var udpTracker = new UdpTracker(new Buffer('01234567890123456789'), new Buffer('12345678901234567890'), announceUrl, {'port': 1234})
    
    • peerId: unique Id for peer (20 bytes)
    • infoHash: infoHash for torrent (20 bytes)
    • opts:
    {
      port: (16 bytes),
      _timeout: timeout for announce try in miliseconds
    }
  2. udpTracker.announce(event, opts)

announce event to tracker

  • event: event type to announce
  none = 0
  completed = 1
  started = 2
  stopped = 3
  • opts: announce options to send following are consider,

    • downloaded: 8 bytes long
    • left: 8 bytes long
    • uploaded: 8 byte long
  1. udpTracker.destroy()

stop sending announce request to trackers.

TODO

following things need to implement.

  • [x] udp tracker timeout
  • [x] announce interval handling
  • [ ] implement scraping
  • [ ] support IP6
  • [ ] implement extensions
  • [ ] authentication
  • [ ] request string

Implementation Details

  1. Time outs

bittorrent udp tracker timeout specification is implemented

  1. Announce Interval

announce response sends interval (in second) which says do not send another announce request before interval. So even you called announce we do not send announce request immediately instead we wait till interval time is over. After Interval time is over we send announce request with most recent announce request options.

  1. Stoping Tracker

As announce return interval to make new announce request.We keep making announce request. To stop tracker you have to call explicitly destory() api

Inspiration

This module Inspiration is taken from feross's bittorrent-tracker modules's file. udp-tracker.js.

Contributions

please create issue if you are having problem with module.

License

MIT