Skip to content

Commit edb5c6e

Browse files
committed
code style
1 parent 20cb182 commit edb5c6e

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

lib/parse_http.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
module.exports = parseHttpRequest
2+
13
var common = require('./common')
24

35
var REMOVE_IPV6_RE = /^::ffff:/
46

5-
module.exports = parseHttpRequest
6-
77
function parseHttpRequest (req, options) {
88
var s = req.url.split('?')
99
var params = common.querystringParse(s[1])
1010

1111
if (s[0] === '/announce') {
1212
params.action = common.ACTIONS.ANNOUNCE
13-
13+
1414
params.peer_id = typeof params.peer_id === 'string' && common.binaryToUtf8(params.peer_id)
1515
params.port = Number(params.port)
1616

lib/parse_udp.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
module.exports = parseUdpRequest
2+
13
var bufferEqual = require('buffer-equal')
24
var ipLib = require('ip')
35
var common = require('./common')
46

5-
6-
module.exports = parseUdpRequest
7-
87
function parseUdpRequest (msg, rinfo) {
98
if (msg.length < 16) {
109
throw new Error('received packet is too short')
@@ -20,7 +19,7 @@ function parseUdpRequest (msg, rinfo) {
2019
transactionId: msg.readUInt32BE(12)
2120
}
2221

23-
// TODO: randomize:
22+
// TODO: randomize
2423
if (!bufferEqual(params.connectionId, common.CONNECTION_ID)) {
2524
throw new Error('received packet with invalid connection id')
2625
}

lib/swarm.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var debug = require('debug')('bittorrent-tracker')
2-
31
module.exports = Swarm
42

3+
var debug = require('debug')('bittorrent-tracker')
4+
55
// Regard this as the default implementation of an interface that you
66
// need to support when overriding Server.getSwarm()
77
function Swarm (infoHash, server) {
@@ -110,7 +110,7 @@ Swarm.prototype._getPeers = function (numwant) {
110110
return peers
111111
}
112112

113-
Swarm.prototype.scrape = function (infoHash, params, cb) {
113+
Swarm.prototype.scrape = function (params, cb) {
114114
cb(null, {
115115
complete: this.complete,
116116
incomplete: this.incomplete

server.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Server.prototype._onHttpRequest = function (req, res) {
147147
// even though it's an error for the client, it's just a warning for the server.
148148
// don't crash the server because a client sent bad data :)
149149
self.emit('warning', error)
150-
150+
151151
return
152152
}
153153

@@ -185,7 +185,7 @@ Server.prototype._onUdpRequest = function (msg, rinfo) {
185185
'failure reason': err.message
186186
}
187187
}
188-
188+
189189
var socket = dgram.createSocket('udp4')
190190
response.transactionId = params.transactionId
191191
response.connectionId = params.connectionId
@@ -199,7 +199,6 @@ Server.prototype._onUdpRequest = function (msg, rinfo) {
199199
}
200200

201201
Server.prototype._onRequest = function (params, cb) {
202-
var response
203202
if (params && params.action === common.ACTIONS.CONNECT) {
204203
cb(null, { action: common.ACTIONS.CONNECT })
205204
} else if (params && params.action === common.ACTIONS.ANNOUNCE) {
@@ -230,21 +229,21 @@ Server.prototype._onAnnounce = function (params, cb) {
230229

231230
Server.prototype._onScrape = function (params, cb) {
232231
var self = this
233-
232+
234233
if (typeof params.info_hash === 'string') {
235234
params.info_hash = [ params.info_hash ]
236235
} else if (params.info_hash == null) {
237236
// if info_hash param is omitted, stats for all torrents are returned
238237
// TODO: make this configurable!
239238
params.info_hash = Object.keys(self.torrents)
240239
}
241-
240+
242241
if (!Array.isArray(params.info_hash)) {
243242
var err = new Error('invalid info_hash')
244243
self.emit('warning', err)
245244
return cb(err)
246245
}
247-
246+
248247
var response = {
249248
action: common.ACTIONS.SCRAPE,
250249
files: {},
@@ -256,7 +255,7 @@ Server.prototype._onScrape = function (params, cb) {
256255
series(params.info_hash.map(function (infoHash) {
257256
var swarm = self.getSwarm(infoHash)
258257
return function (cb) {
259-
swarm.scrape(infoHash, params, function (err, scrapeInfo) {
258+
swarm.scrape(params, function (err, scrapeInfo) {
260259
cb(err, scrapeInfo && {
261260
infoHash: infoHash,
262261
complete: scrapeInfo.complete || 0,

0 commit comments

Comments
 (0)