mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 02:21:36 +00:00
server: Enable WebSocket server by default
This commit is contained in:
parent
834bf1db5e
commit
f13accfc42
23
bin/cmd.js
23
bin/cmd.js
@ -22,10 +22,7 @@ var argv = minimist(process.argv.slice(2), {
|
|||||||
'ws'
|
'ws'
|
||||||
],
|
],
|
||||||
default: {
|
default: {
|
||||||
http: true,
|
port: 8000
|
||||||
port: 8000,
|
|
||||||
udp: true,
|
|
||||||
ws: false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -42,13 +39,15 @@ if (argv.help) {
|
|||||||
Usage:
|
Usage:
|
||||||
bittorrent-tracker [OPTIONS]
|
bittorrent-tracker [OPTIONS]
|
||||||
|
|
||||||
|
If no --http, --udp, or --ws option is supplied, all tracker types will be started.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-p, --port [number] change the port [default: 8000]
|
-p, --port [number] change the port [default: 8000]
|
||||||
--trust-proxy trust 'x-forwarded-for' header from reverse proxy
|
--trust-proxy trust 'x-forwarded-for' header from reverse proxy
|
||||||
--interval tell clients to announce on this interval (ms)
|
--interval client announce interval (ms) [default: 600000]
|
||||||
--http enable http server? [default: true]
|
--http enable http server
|
||||||
--udp enable udp server? [default: true]
|
--udp enable udp server
|
||||||
--ws enable websocket server? [default: false]
|
--ws enable websocket server
|
||||||
-q, --quiet only show error output
|
-q, --quiet only show error output
|
||||||
-s, --silent show no output
|
-s, --silent show no output
|
||||||
-v, --version print the current version
|
-v, --version print the current version
|
||||||
@ -62,6 +61,12 @@ if (argv.help) {
|
|||||||
|
|
||||||
if (argv.silent) argv.quiet = true
|
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({
|
var server = new Server({
|
||||||
http: argv.http,
|
http: argv.http,
|
||||||
interval: argv.interval,
|
interval: argv.interval,
|
||||||
@ -90,7 +95,7 @@ server.on('stop', function (addr) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
server.listen(argv.port, function () {
|
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')
|
console.log('HTTP tracker: http://localhost:' + server.http.address().port + '/announce')
|
||||||
}
|
}
|
||||||
if (server.udp && !argv.quiet) {
|
if (server.udp && !argv.quiet) {
|
||||||
|
@ -86,7 +86,7 @@ function Server (opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start a websocket tracker (for WebTorrent) unless the user explicitly says no
|
// start a websocket tracker (for WebTorrent) unless the user explicitly says no
|
||||||
if (opts.ws === true) {
|
if (opts.ws !== false) {
|
||||||
if (!self.http) {
|
if (!self.http) {
|
||||||
self.http = http.createServer()
|
self.http = http.createServer()
|
||||||
self.http.on('request', function (req, res) {
|
self.http.on('request', function (req, res) {
|
||||||
|
Loading…
Reference in New Issue
Block a user