Skip to content

Commit ec6ac81

Browse files
committed
Merge remote-tracking branch 'upstream/master' into proxy
2 parents a8724a8 + 2a82829 commit ec6ac81

38 files changed

+2629
-2012
lines changed

.npmignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
img.png
1+
.travis.yml
2+
CONTRIBUTING.md
3+
examples/
4+
img/
5+
test/
6+
tools/

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
language: node_js
22
sudo: false
33
node_js:
4-
- "node"
4+
- lts/*
55
before_script:
6-
- export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start
6+
# Add an IPv6 config - see the corresponding Travis issue
7+
# https://github.com/travis-ci/travis-ci/issues/8361
8+
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
9+
sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6';
10+
fi

AUTHORS.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,31 @@
2424
2525
- Harsh Vakharia ([email protected])
2626
- Yoann Ciabaud ([email protected])
27-
- Diego Rodríguez Baquero ([email protected])
2827
28+
- Diego Rodríguez Baquero ([email protected])
2929
- Kirill Fomichev ([email protected])
3030
- Matt Bell ([email protected])
31+
- Diego Rodríguez ([email protected])
3132
- Philipp Henkel ([email protected])
3233
3334
- Nick Frost ([email protected])
35+
- ZunSThy ([email protected])
36+
- vijayanand nandam ([email protected])
37+
- Luigi Pinca ([email protected])
38+
- Diego R. B ([email protected])
39+
- greenkeeper[bot] (greenkeeper[bot]@users.noreply.github.com)
40+
- hrafnkell orri sigurdsson ([email protected])
41+
- Brian Clifton ([email protected])
42+
- James M Snell ([email protected])
43+
- crapthings ([email protected])
44+
45+
46+
- Jimmy Wärting ([email protected])
47+
- Justin Kalland ([email protected])
48+
- greenkeeper[bot] (23040076+greenkeeper[bot]@users.noreply.github.com)
49+
- Eric Guan ([email protected])
50+
- Koushik Dutta ([email protected])
51+
- KayleePop ([email protected])
52+
- Diego Rodriguez Baquero ([email protected])
3453

35-
#### Generated by bin/update-authors.sh.
54+
#### Generated by tools/update-authors.sh.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ and to avoid style arguments. `npm test` runs `standard` automatically, so you d
2424
to!
2525

2626
[standard-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg
27-
[standard-url]: https://github.com/feross/standard
27+
[standard-url]: https://standardjs.com
2828

2929
## Project Governance
3030

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) Feross Aboukhadijeh
3+
Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# bittorrent-tracker [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url]
1+
# bittorrent-tracker [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
22

3-
[travis-image]: https://img.shields.io/travis/feross/bittorrent-tracker/master.svg
4-
[travis-url]: https://travis-ci.org/feross/bittorrent-tracker
3+
[travis-image]: https://img.shields.io/travis/webtorrent/bittorrent-tracker/master.svg
4+
[travis-url]: https://travis-ci.org/webtorrent/bittorrent-tracker
55
[npm-image]: https://img.shields.io/npm/v/bittorrent-tracker.svg
66
[npm-url]: https://npmjs.org/package/bittorrent-tracker
77
[downloads-image]: https://img.shields.io/npm/dm/bittorrent-tracker.svg
88
[downloads-url]: https://npmjs.org/package/bittorrent-tracker
9+
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
10+
[standard-url]: https://standardjs.com
911

1012
#### Simple, robust, BitTorrent tracker (client & server) implementation
1113

12-
![tracker](https://raw.githubusercontent.com/feross/bittorrent-tracker/master/img.png)
14+
![tracker visualization](img/img.png)
1315

1416
Node.js implementation of a [BitTorrent tracker](https://wiki.theory.org/BitTorrentSpecification#Tracker_HTTP.2FHTTPS_Protocol), client and server.
1517

@@ -31,10 +33,14 @@ This module is used by [WebTorrent](http://webtorrent.io).
3133
- Supports tracker "scrape" extension
3234
- Robust and well-tested
3335
- Comprehensive test suite (runs entirely offline, so it's reliable)
34-
- Used by popular clients: [WebTorrent](http://webtorrent.io), [peerflix](https://github.com/mafintosh/peerflix), and [playback](https://mafintosh.github.io/playback/)
36+
- Used by popular clients: [WebTorrent](http://webtorrent.io), [peerflix](https://www.npmjs.com/package/peerflix), and [playback](https://mafintosh.github.io/playback/)
3537
- Tracker statistics available via web interface at `/stats` or JSON data at `/stats.json`
3638

37-
Also see [bittorrent-dht](https://github.com/feross/bittorrent-dht).
39+
Also see [bittorrent-dht](https://www.npmjs.com/package/bittorrent-dht).
40+
41+
### Tracker stats
42+
43+
![Screenshot](img/trackerStats.png)
3844

3945
## install
4046

@@ -61,10 +67,12 @@ var requiredOpts = {
6167
var optionalOpts = {
6268
// RTCPeerConnection config object (only used in browser)
6369
rtcConfig: {},
64-
// custom webrtc impl, useful in node to specify [wrtc](https://npmjs.com/package/wrtc)
70+
// User-Agent header for http requests
71+
userAgent: '',
72+
// Custom webrtc impl, useful in node to specify [wrtc](https://npmjs.com/package/wrtc)
6573
wrtc: {},
6674
getAnnounceOpts: function () {
67-
// provide a callback that will be called whenever announce() is called
75+
// Provide a callback that will be called whenever announce() is called
6876
// internally (on timer), or by the user
6977
return {
7078
uploaded: 0,
@@ -73,7 +81,7 @@ var optionalOpts = {
7381
customParam: 'blah' // custom parameters supported
7482
}
7583
},
76-
84+
// Proxy config object
7785
proxyOpts: {
7886
// Socks proxy options (used to proxy requests in node)
7987
socksProxy: {
@@ -110,7 +118,7 @@ var optionalOpts = {
110118
// Populated with Socks.Agent if socksProxy is provided
111119
httpAgent: {},
112120
httpsAgent: {}
113-
}
121+
},
114122
}
115123

116124
var client = new Client(requiredOpts)
@@ -193,10 +201,14 @@ var server = new Server({
193201
// This example only allows one torrent.
194202

195203
var allowed = (infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa')
196-
cb(allowed)
197-
198-
// In addition to returning a boolean (`true` for allowed, `false` for disallowed),
199-
// you can return an `Error` object to disallow and provide a custom reason.
204+
if (allowed) {
205+
// If the callback is passed `null`, the torrent will be allowed.
206+
cb(null)
207+
} else {
208+
// If the callback is passed an `Error` object, the torrent will be disallowed
209+
// and the error's `message` property will be given as the reason.
210+
cb(new Error('disallowed torrent'))
211+
}
200212
}
201213
})
202214

@@ -255,7 +267,7 @@ Scraping multiple torrent info is possible with a static `Client.scrape` method:
255267

256268
```js
257269
var Client = require('bittorrent-tracker')
258-
Client.scrape(announceUrl, [ infoHash1, infoHash2 ], function (err, results) {
270+
Client.scrape({ announce: announceUrl, infoHash: [ infoHash1, infoHash2 ]}, function (err, results) {
259271
results[infoHash1].announce
260272
results[infoHash1].infoHash
261273
results[infoHash1].complete
@@ -268,6 +280,12 @@ Client.scrape(announceUrl, [ infoHash1, infoHash2 ], function (err, results) {
268280

269281
## command line
270282

283+
Install `bittorrent-tracker` globally:
284+
285+
```sh
286+
$ npm install -g bittorrent-tracker
287+
```
288+
271289
Easily start a tracker server:
272290

273291
```sh
@@ -298,10 +316,8 @@ $ bittorrent-tracker --help
298316
-q, --quiet only show error output
299317
-s, --silent show no output
300318
-v, --version print the current version
301-
302-
Please report bugs! https://github.com/feross/bittorrent-tracker/issues
303319
```
304320

305321
## license
306322

307-
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
323+
MIT. Copyright (c) [Feross Aboukhadijeh](https://feross.org) and [WebTorrent, LLC](https://webtorrent.io).

bin/cmd.js

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env node
22

3-
var minimist = require('minimist')
4-
var Server = require('../').Server
3+
const minimist = require('minimist')
4+
const Server = require('../').Server
55

6-
var argv = minimist(process.argv.slice(2), {
6+
const argv = minimist(process.argv.slice(2), {
77
alias: {
88
h: 'help',
99
p: 'port',
@@ -63,22 +63,20 @@ if (argv.help) {
6363
-s, --silent show no output
6464
-v, --version print the current version
6565
66-
Please report bugs! https://github.com/feross/bittorrent-tracker/issues
67-
6866
*/
6967
}.toString().split(/\n/).slice(2, -2).join('\n'))
7068
process.exit(0)
7169
}
7270

7371
if (argv.silent) argv.quiet = true
7472

75-
var allFalsy = !argv.http && !argv.udp && !argv.ws
73+
const allFalsy = !argv.http && !argv.udp && !argv.ws
7674

7775
argv.http = allFalsy || argv.http
7876
argv.udp = allFalsy || argv.udp
7977
argv.ws = allFalsy || argv.ws
8078

81-
var server = new Server({
79+
const server = new Server({
8280
http: argv.http,
8381
interval: argv.interval,
8482
stats: argv.stats,
@@ -106,41 +104,41 @@ server.on('stop', function (addr) {
106104
if (!argv.quiet) console.log('stop: ' + addr)
107105
})
108106

109-
var hostname = {
107+
const hostname = {
110108
http: argv['http-hostname'],
111109
udp4: argv['udp-hostname'],
112-
udp6: argv['upd6-hostname']
110+
udp6: argv['udp6-hostname']
113111
}
114112

115113
server.listen(argv.port, hostname, function () {
116114
if (server.http && argv.http && !argv.quiet) {
117-
var httpAddr = server.http.address()
118-
var httpHost = httpAddr.address !== '::' ? httpAddr.address : 'localhost'
119-
var httpPort = httpAddr.port
115+
const httpAddr = server.http.address()
116+
const httpHost = httpAddr.address !== '::' ? httpAddr.address : 'localhost'
117+
const httpPort = httpAddr.port
120118
console.log('HTTP tracker: http://' + httpHost + ':' + httpPort + '/announce')
121119
}
122120
if (server.udp && !argv.quiet) {
123-
var udpAddr = server.udp.address()
124-
var udpHost = udpAddr.address
125-
var udpPort = udpAddr.port
121+
const udpAddr = server.udp.address()
122+
const udpHost = udpAddr.address
123+
const udpPort = udpAddr.port
126124
console.log('UDP tracker: udp://' + udpHost + ':' + udpPort)
127125
}
128126
if (server.udp6 && !argv.quiet) {
129-
var udp6Addr = server.udp6.address()
130-
var udp6Host = udp6Addr.address !== '::' ? udp6Addr.address : 'localhost'
131-
var udp6Port = udp6Addr.port
127+
const udp6Addr = server.udp6.address()
128+
const udp6Host = udp6Addr.address !== '::' ? udp6Addr.address : 'localhost'
129+
const udp6Port = udp6Addr.port
132130
console.log('UDP6 tracker: udp://' + udp6Host + ':' + udp6Port)
133131
}
134132
if (server.ws && !argv.quiet) {
135-
var wsAddr = server.http.address()
136-
var wsHost = wsAddr.address !== '::' ? wsAddr.address : 'localhost'
137-
var wsPort = wsAddr.port
133+
const wsAddr = server.http.address()
134+
const wsHost = wsAddr.address !== '::' ? wsAddr.address : 'localhost'
135+
const wsPort = wsAddr.port
138136
console.log('WebSocket tracker: ws://' + wsHost + ':' + wsPort)
139137
}
140138
if (server.http && argv.stats && !argv.quiet) {
141-
var statsAddr = server.http.address()
142-
var statsHost = statsAddr.address !== '::' ? statsAddr.address : 'localhost'
143-
var statsPort = statsAddr.port
139+
const statsAddr = server.http.address()
140+
const statsHost = statsAddr.address !== '::' ? statsAddr.address : 'localhost'
141+
const statsPort = statsAddr.port
144142
console.log('Tracker stats: http://' + statsHost + ':' + statsPort + '/stats')
145143
}
146144
})

0 commit comments

Comments
 (0)