Skip to content

Commit f13accf

Browse files
committed
server: Enable WebSocket server by default
1 parent 834bf1d commit f13accf

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

bin/cmd.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ var argv = minimist(process.argv.slice(2), {
2222
'ws'
2323
],
2424
default: {
25-
http: true,
26-
port: 8000,
27-
udp: true,
28-
ws: false
25+
port: 8000
2926
}
3027
})
3128

@@ -40,18 +37,20 @@ if (argv.help) {
4037
bittorrent-tracker - Start a bittorrent tracker server
4138
4239
Usage:
43-
bittorrent-tracker [OPTIONS]
40+
bittorrent-tracker [OPTIONS]
41+
42+
If no --http, --udp, or --ws option is supplied, all tracker types will be started.
4443
4544
Options:
46-
-p, --port [number] change the port [default: 8000]
47-
--trust-proxy trust 'x-forwarded-for' header from reverse proxy
48-
--interval tell clients to announce on this interval (ms)
49-
--http enable http server? [default: true]
50-
--udp enable udp server? [default: true]
51-
--ws enable websocket server? [default: false]
52-
-q, --quiet only show error output
53-
-s, --silent show no output
54-
-v, --version print the current version
45+
-p, --port [number] change the port [default: 8000]
46+
--trust-proxy trust 'x-forwarded-for' header from reverse proxy
47+
--interval client announce interval (ms) [default: 600000]
48+
--http enable http server
49+
--udp enable udp server
50+
--ws enable websocket server
51+
-q, --quiet only show error output
52+
-s, --silent show no output
53+
-v, --version print the current version
5554
5655
Please report bugs! https://github.com/feross/bittorrent-tracker/issues
5756
@@ -62,6 +61,12 @@ if (argv.help) {
6261

6362
if (argv.silent) argv.quiet = true
6463

64+
var allFalsy = !argv.http && !argv.udp && !argv.ws
65+
66+
argv.http = allFalsy || argv.http
67+
argv.udp = allFalsy || argv.udp
68+
argv.ws = allFalsy || argv.ws
69+
6570
var server = new Server({
6671
http: argv.http,
6772
interval: argv.interval,
@@ -90,7 +95,7 @@ server.on('stop', function (addr) {
9095
})
9196

9297
server.listen(argv.port, function () {
93-
if (server.http && !argv.quiet) {
98+
if (server.http && argv.http && !argv.quiet) {
9499
console.log('HTTP tracker: http://localhost:' + server.http.address().port + '/announce')
95100
}
96101
if (server.udp && !argv.quiet) {

server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function Server (opts) {
8686
}
8787

8888
// start a websocket tracker (for WebTorrent) unless the user explicitly says no
89-
if (opts.ws === true) {
89+
if (opts.ws !== false) {
9090
if (!self.http) {
9191
self.http = http.createServer()
9292
self.http.on('request', function (req, res) {

0 commit comments

Comments
 (0)