|
1 | 1 | #!/usr/bin/env node |
2 | 2 |
|
3 | | -var minimist = require('minimist') |
4 | | -var Server = require('../').Server |
| 3 | +const minimist = require('minimist') |
| 4 | +const Server = require('../').Server |
5 | 5 |
|
6 | | -var argv = minimist(process.argv.slice(2), { |
| 6 | +const argv = minimist(process.argv.slice(2), { |
7 | 7 | alias: { |
8 | 8 | h: 'help', |
9 | 9 | p: 'port', |
@@ -70,13 +70,13 @@ if (argv.help) { |
70 | 70 |
|
71 | 71 | if (argv.silent) argv.quiet = true |
72 | 72 |
|
73 | | -var allFalsy = !argv.http && !argv.udp && !argv.ws |
| 73 | +const allFalsy = !argv.http && !argv.udp && !argv.ws |
74 | 74 |
|
75 | 75 | argv.http = allFalsy || argv.http |
76 | 76 | argv.udp = allFalsy || argv.udp |
77 | 77 | argv.ws = allFalsy || argv.ws |
78 | 78 |
|
79 | | -var server = new Server({ |
| 79 | +const server = new Server({ |
80 | 80 | http: argv.http, |
81 | 81 | interval: argv.interval, |
82 | 82 | stats: argv.stats, |
@@ -104,41 +104,41 @@ server.on('stop', function (addr) { |
104 | 104 | if (!argv.quiet) console.log('stop: ' + addr) |
105 | 105 | }) |
106 | 106 |
|
107 | | -var hostname = { |
| 107 | +const hostname = { |
108 | 108 | http: argv['http-hostname'], |
109 | 109 | udp4: argv['udp-hostname'], |
110 | 110 | udp6: argv['udp6-hostname'] |
111 | 111 | } |
112 | 112 |
|
113 | 113 | server.listen(argv.port, hostname, function () { |
114 | 114 | if (server.http && argv.http && !argv.quiet) { |
115 | | - var httpAddr = server.http.address() |
116 | | - var httpHost = httpAddr.address !== '::' ? httpAddr.address : 'localhost' |
117 | | - var httpPort = httpAddr.port |
| 115 | + const httpAddr = server.http.address() |
| 116 | + const httpHost = httpAddr.address !== '::' ? httpAddr.address : 'localhost' |
| 117 | + const httpPort = httpAddr.port |
118 | 118 | console.log('HTTP tracker: http://' + httpHost + ':' + httpPort + '/announce') |
119 | 119 | } |
120 | 120 | if (server.udp && !argv.quiet) { |
121 | | - var udpAddr = server.udp.address() |
122 | | - var udpHost = udpAddr.address |
123 | | - var udpPort = udpAddr.port |
| 121 | + const udpAddr = server.udp.address() |
| 122 | + const udpHost = udpAddr.address |
| 123 | + const udpPort = udpAddr.port |
124 | 124 | console.log('UDP tracker: udp://' + udpHost + ':' + udpPort) |
125 | 125 | } |
126 | 126 | if (server.udp6 && !argv.quiet) { |
127 | | - var udp6Addr = server.udp6.address() |
128 | | - var udp6Host = udp6Addr.address !== '::' ? udp6Addr.address : 'localhost' |
129 | | - var udp6Port = udp6Addr.port |
| 127 | + const udp6Addr = server.udp6.address() |
| 128 | + const udp6Host = udp6Addr.address !== '::' ? udp6Addr.address : 'localhost' |
| 129 | + const udp6Port = udp6Addr.port |
130 | 130 | console.log('UDP6 tracker: udp://' + udp6Host + ':' + udp6Port) |
131 | 131 | } |
132 | 132 | if (server.ws && !argv.quiet) { |
133 | | - var wsAddr = server.http.address() |
134 | | - var wsHost = wsAddr.address !== '::' ? wsAddr.address : 'localhost' |
135 | | - var wsPort = wsAddr.port |
| 133 | + const wsAddr = server.http.address() |
| 134 | + const wsHost = wsAddr.address !== '::' ? wsAddr.address : 'localhost' |
| 135 | + const wsPort = wsAddr.port |
136 | 136 | console.log('WebSocket tracker: ws://' + wsHost + ':' + wsPort) |
137 | 137 | } |
138 | 138 | if (server.http && argv.stats && !argv.quiet) { |
139 | | - var statsAddr = server.http.address() |
140 | | - var statsHost = statsAddr.address !== '::' ? statsAddr.address : 'localhost' |
141 | | - var statsPort = statsAddr.port |
| 139 | + const statsAddr = server.http.address() |
| 140 | + const statsHost = statsAddr.address !== '::' ? statsAddr.address : 'localhost' |
| 141 | + const statsPort = statsAddr.port |
142 | 142 | console.log('Tracker stats: http://' + statsHost + ':' + statsPort + '/stats') |
143 | 143 | } |
144 | 144 | }) |
0 commit comments