diff --git a/bin/cmd.js b/bin/cmd.js index 9ef3536..0fd15e5 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -22,10 +22,7 @@ var argv = minimist(process.argv.slice(2), { 'ws' ], default: { - http: true, - port: 8000, - udp: true, - ws: false + port: 8000 } }) @@ -40,18 +37,20 @@ if (argv.help) { bittorrent-tracker - Start a bittorrent tracker server Usage: - bittorrent-tracker [OPTIONS] + bittorrent-tracker [OPTIONS] + + If no --http, --udp, or --ws option is supplied, all tracker types will be started. Options: - -p, --port [number] change the port [default: 8000] - --trust-proxy trust 'x-forwarded-for' header from reverse proxy - --interval tell clients to announce on this interval (ms) - --http enable http server? [default: true] - --udp enable udp server? [default: true] - --ws enable websocket server? [default: false] - -q, --quiet only show error output - -s, --silent show no output - -v, --version print the current version + -p, --port [number] change the port [default: 8000] + --trust-proxy trust 'x-forwarded-for' header from reverse proxy + --interval client announce interval (ms) [default: 600000] + --http enable http server + --udp enable udp server + --ws enable websocket server + -q, --quiet only show error output + -s, --silent show no output + -v, --version print the current version Please report bugs! https://github.com/feross/bittorrent-tracker/issues @@ -62,6 +61,12 @@ if (argv.help) { if (argv.silent) argv.quiet = true +var allFalsy = !argv.http && !argv.udp && !argv.ws + +argv.http = allFalsy || argv.http +argv.udp = allFalsy || argv.udp +argv.ws = allFalsy || argv.ws + var server = new Server({ http: argv.http, interval: argv.interval, @@ -90,7 +95,7 @@ server.on('stop', function (addr) { }) server.listen(argv.port, function () { - if (server.http && !argv.quiet) { + if (server.http && argv.http && !argv.quiet) { console.log('HTTP tracker: http://localhost:' + server.http.address().port + '/announce') } if (server.udp && !argv.quiet) { diff --git a/server.js b/server.js index b1e2211..87f09d0 100644 --- a/server.js +++ b/server.js @@ -86,7 +86,7 @@ function Server (opts) { } // start a websocket tracker (for WebTorrent) unless the user explicitly says no - if (opts.ws === true) { + if (opts.ws !== false) { if (!self.http) { self.http = http.createServer() self.http.on('request', function (req, res) {