uwt
µWT (µWebTorrentTracker) is a simple, robust and lightweight WebTorrent tracker server implementation
Node.js implementation of a BitTorrent tracker for WebTorrent clients.
A BitTorrent tracker is a web service which responds to requests from BitTorrent
clients. The requests include metrics from clients that help the tracker keep overall
statistics about the torrent. The response includes a peer list that helps the client
participate in the torrent swarm.
This module is used by βTorrent Tracker, the first community operated WebTorrent tracker.
Features
- Fast & lightweight server implementation
- Supports ipv4 & ipv6
- Supports tracker "scrape" extension
- Robust and well-tested
- Comprehensive test suite (runs entirely offline, so it's reliable)
- Tracker statistics available via web interface at
/stats
or JSON data at /stats.json
Requires NodeJS 6+
Install
npm install uwt
Usage
To start a WebTorrent tracker server to track swarms of peers:
const Server = require('uwt')
const server = new Server({
stats: true,
filter: function (infoHash, params, cb) {
const allowed = (infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa')
if (allowed) {
cb(null)
} else {
cb(new Error('disallowed torrent'))
}
}
})
server.ws
server.http
server.on('error', function (err) {
console.log(err.message)
})
server.on('warning', function (err) {
console.log(err.message)
})
server.on('listening', function () {
console.log('listening on http port:' + server.http.address().port)
})
server.listen(port, onlistening)
server.on('start', function (addr) {
console.log('got start message from ' + addr)
})
server.on('complete', function (addr) {})
server.on('update', function (addr) {})
server.on('stop', function (addr) {})
Object.keys(server.torrents)
server.torrents[infoHash].complete
server.torrents[infoHash].incomplete
server.torrents[infoHash].peers
CLI
Install uwt
globally
$ npm install -g uwt
Easily start a tracker server:
$ webtorrent-tracker
Tracker: ws://localhost:8000
Tracker stats: http://localhost:8000/stats
Lots of options:
$ webtorrent-tracker --help
webtorrent-tracker - Start a webtorrent tracker server
Usage:
webtorrent-tracker [OPTIONS]
Options:
-p, --port [number] change the port [default: 8000]
--trust-proxy trust 'x-forwarded-for' header from reverse proxy
--interval client announce interval (ms) [default: 120000]
--stats enable web-based statistics (default: true)
-q, --quiet only show error output
-s, --silent show no output
-v, --version print the current version
Please report bugs! https://github.com/DiegoRBaquero/uwt/issues
License
MIT
Copyright (c) Diego Rodríguez Baquero (uwt)
Copyright (c) Feross Aboukhadijeh (bittorrent-tracker)