mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 12:11:36 +00:00
Fixes for PR #142
This commit is contained in:
parent
74f9cda6f9
commit
3cd84411fb
@ -32,7 +32,7 @@ This module is used by [WebTorrent](http://webtorrent.io).
|
||||
- Robust and well-tested
|
||||
- Comprehensive test suite (runs entirely offline, so it's reliable)
|
||||
- Used by popular clients: [WebTorrent](http://webtorrent.io), [peerflix](https://github.com/mafintosh/peerflix), and [playback](https://mafintosh.github.io/playback/)
|
||||
- Web-Based Statistics
|
||||
- Tracker stats avaialable via web interface at `/stats`
|
||||
|
||||
Also see [bittorrent-dht](https://github.com/feross/bittorrent-dht).
|
||||
|
||||
@ -144,7 +144,7 @@ var server = new Server({
|
||||
udp: true, // enable udp server? [default=true]
|
||||
http: true, // enable http server? [default=true]
|
||||
ws: true, // enable websocket server? [default=true]
|
||||
stats: true, // enable web-based statistics [default=true]
|
||||
stats: true, // enable web-based statistics? [default=true]
|
||||
filter: function (infoHash, params, cb) {
|
||||
// Blacklist/whitelist function for allowing/disallowing torrents. If this option is
|
||||
// omitted, all torrents are allowed. It is possible to interface with a database or
|
||||
|
15
bin/cmd.js
15
bin/cmd.js
@ -20,7 +20,7 @@ var argv = minimist(process.argv.slice(2), {
|
||||
'udp',
|
||||
'version',
|
||||
'ws',
|
||||
'no-stats'
|
||||
'stats'
|
||||
],
|
||||
string: [
|
||||
'http-hostname',
|
||||
@ -28,7 +28,8 @@ var argv = minimist(process.argv.slice(2), {
|
||||
'udp6-hostname'
|
||||
],
|
||||
default: {
|
||||
port: 8000
|
||||
port: 8000,
|
||||
stats: true
|
||||
}
|
||||
})
|
||||
|
||||
@ -57,7 +58,7 @@ if (argv.help) {
|
||||
--http enable http server
|
||||
--udp enable udp server
|
||||
--ws enable websocket server
|
||||
--no-stats disable web-based statistics
|
||||
--stats enable web-based statistics (default: true)
|
||||
-q, --quiet only show error output
|
||||
-s, --silent show no output
|
||||
-v, --version print the current version
|
||||
@ -77,12 +78,10 @@ argv.http = allFalsy || argv.http
|
||||
argv.udp = allFalsy || argv.udp
|
||||
argv.ws = allFalsy || argv.ws
|
||||
|
||||
argv['no-stats'] = !!argv['no-stats']
|
||||
|
||||
var server = new Server({
|
||||
http: argv.http,
|
||||
interval: argv.interval,
|
||||
stats: argv['no-stats'],
|
||||
stats: argv.stats,
|
||||
trustProxy: argv['trust-proxy'],
|
||||
udp: argv.udp,
|
||||
ws: argv.ws
|
||||
@ -138,10 +137,10 @@ server.listen(argv.port, hostname, function () {
|
||||
var wsPort = wsAddr.port
|
||||
console.log('WebSocket tracker: ws://' + wsHost + ':' + wsPort)
|
||||
}
|
||||
if (server.http && argv['no-stats'] && !argv.quiet) {
|
||||
if (server.http && argv.stats && !argv.quiet) {
|
||||
var statsAddr = server.http.address()
|
||||
var statsHost = statsAddr.address !== '::' ? statsAddr.address : 'localhost'
|
||||
var statsPort = statsAddr.port
|
||||
console.log('Tracker statistics: http://' + statsHost + ':' + statsPort)
|
||||
console.log('Tracker stats: http://' + statsHost + ':' + statsPort + '/stats')
|
||||
}
|
||||
})
|
||||
|
@ -31,6 +31,7 @@ inherits(Server, EventEmitter)
|
||||
* @param {boolean} opts.http start an http server? (default: true)
|
||||
* @param {boolean} opts.udp start a udp server? (default: true)
|
||||
* @param {boolean} opts.ws start a websocket server? (default: true)
|
||||
* @param {boolean} opts.stats enable web-based statistics? (default: true)
|
||||
* @param {function} opts.filter black/whitelist fn for disallowing/allowing torrents
|
||||
*/
|
||||
function Server (opts) {
|
||||
@ -128,7 +129,7 @@ function Server (opts) {
|
||||
}
|
||||
|
||||
// Http handler for '/stats' route
|
||||
self.http.on('request', function (req, res, opts) {
|
||||
self.http.on('request', function (req, res) {
|
||||
if (res.headersSent) return
|
||||
|
||||
var infoHashes = Object.keys(self.torrents)
|
||||
|
Loading…
Reference in New Issue
Block a user