You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Node.js implementation of a [BitTorrent tracker](https://wiki.theory.org/BitTorrentSpecification#Tracker_HTTP.2FHTTPS_Protocol), client and server.
15
17
@@ -31,10 +33,14 @@ This module is used by [WebTorrent](http://webtorrent.io).
31
33
- Supports tracker "scrape" extension
32
34
- Robust and well-tested
33
35
- 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/)
35
37
- Tracker statistics available via web interface at `/stats` or JSON data at `/stats.json`
36
38
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
+

38
44
39
45
## install
40
46
@@ -61,10 +67,12 @@ var requiredOpts = {
61
67
var optionalOpts = {
62
68
// RTCPeerConnection config object (only used in browser)
63
69
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)
65
73
wrtc: {},
66
74
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
68
76
// internally (on timer), or by the user
69
77
return {
70
78
uploaded:0,
@@ -73,7 +81,7 @@ var optionalOpts = {
73
81
customParam:'blah'// custom parameters supported
74
82
}
75
83
},
76
-
84
+
// Proxy config object
77
85
proxyOpts: {
78
86
// Socks proxy options (used to proxy requests in node)
79
87
socksProxy: {
@@ -110,7 +118,7 @@ var optionalOpts = {
110
118
// Populated with Socks.Agent if socksProxy is provided
111
119
httpAgent: {},
112
120
httpsAgent: {}
113
-
}
121
+
},
114
122
}
115
123
116
124
var client =newClient(requiredOpts)
@@ -193,10 +201,14 @@ var server = new Server({
193
201
// This example only allows one torrent.
194
202
195
203
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(newError('disallowed torrent'))
211
+
}
200
212
}
201
213
})
202
214
@@ -255,7 +267,7 @@ Scraping multiple torrent info is possible with a static `Client.scrape` method:
255
267
256
268
```js
257
269
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) {
0 commit comments