mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 10:31:36 +00:00
code style
This commit is contained in:
parent
20cb18272e
commit
edb5c6e854
@ -1,9 +1,9 @@
|
||||
module.exports = parseHttpRequest
|
||||
|
||||
var common = require('./common')
|
||||
|
||||
var REMOVE_IPV6_RE = /^::ffff:/
|
||||
|
||||
module.exports = parseHttpRequest
|
||||
|
||||
function parseHttpRequest (req, options) {
|
||||
var s = req.url.split('?')
|
||||
var params = common.querystringParse(s[1])
|
||||
|
@ -1,10 +1,9 @@
|
||||
module.exports = parseUdpRequest
|
||||
|
||||
var bufferEqual = require('buffer-equal')
|
||||
var ipLib = require('ip')
|
||||
var common = require('./common')
|
||||
|
||||
|
||||
module.exports = parseUdpRequest
|
||||
|
||||
function parseUdpRequest (msg, rinfo) {
|
||||
if (msg.length < 16) {
|
||||
throw new Error('received packet is too short')
|
||||
@ -20,7 +19,7 @@ function parseUdpRequest (msg, rinfo) {
|
||||
transactionId: msg.readUInt32BE(12)
|
||||
}
|
||||
|
||||
// TODO: randomize:
|
||||
// TODO: randomize
|
||||
if (!bufferEqual(params.connectionId, common.CONNECTION_ID)) {
|
||||
throw new Error('received packet with invalid connection id')
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
var debug = require('debug')('bittorrent-tracker')
|
||||
|
||||
module.exports = Swarm
|
||||
|
||||
var debug = require('debug')('bittorrent-tracker')
|
||||
|
||||
// Regard this as the default implementation of an interface that you
|
||||
// need to support when overriding Server.getSwarm()
|
||||
function Swarm (infoHash, server) {
|
||||
@ -110,7 +110,7 @@ Swarm.prototype._getPeers = function (numwant) {
|
||||
return peers
|
||||
}
|
||||
|
||||
Swarm.prototype.scrape = function (infoHash, params, cb) {
|
||||
Swarm.prototype.scrape = function (params, cb) {
|
||||
cb(null, {
|
||||
complete: this.complete,
|
||||
incomplete: this.incomplete
|
||||
|
@ -199,7 +199,6 @@ Server.prototype._onUdpRequest = function (msg, rinfo) {
|
||||
}
|
||||
|
||||
Server.prototype._onRequest = function (params, cb) {
|
||||
var response
|
||||
if (params && params.action === common.ACTIONS.CONNECT) {
|
||||
cb(null, { action: common.ACTIONS.CONNECT })
|
||||
} else if (params && params.action === common.ACTIONS.ANNOUNCE) {
|
||||
@ -256,7 +255,7 @@ Server.prototype._onScrape = function (params, cb) {
|
||||
series(params.info_hash.map(function (infoHash) {
|
||||
var swarm = self.getSwarm(infoHash)
|
||||
return function (cb) {
|
||||
swarm.scrape(infoHash, params, function (err, scrapeInfo) {
|
||||
swarm.scrape(params, function (err, scrapeInfo) {
|
||||
cb(err, scrapeInfo && {
|
||||
infoHash: infoHash,
|
||||
complete: scrapeInfo.complete || 0,
|
||||
|
Loading…
Reference in New Issue
Block a user