mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-02-27 15:49:03 +00:00
minor style
This commit is contained in:
parent
0f57bfcd28
commit
2cb749d739
@ -54,7 +54,8 @@ HTTPTracker.prototype.announce = function (opts) {
|
|||||||
})
|
})
|
||||||
if (self._trackerId) params.trackerid = self._trackerId
|
if (self._trackerId) params.trackerid = self._trackerId
|
||||||
|
|
||||||
self._request(self.announceUrl, params, function (data) {
|
self._request(self.announceUrl, params, function (err, data) {
|
||||||
|
if (err) return self.client.emit('warning', err)
|
||||||
self._onAnnounceResponse(data)
|
self._onAnnounceResponse(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -76,7 +77,8 @@ HTTPTracker.prototype.scrape = function (opts) {
|
|||||||
var params = {
|
var params = {
|
||||||
info_hash: infoHashes
|
info_hash: infoHashes
|
||||||
}
|
}
|
||||||
self._request(self.scrapeUrl, params, function (data) {
|
self._request(self.scrapeUrl, params, function (err, data) {
|
||||||
|
if (err) return self.client.emit('warning', err)
|
||||||
self._onScrapeResponse(data)
|
self._onScrapeResponse(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -142,25 +144,25 @@ HTTPTracker.prototype._request = function (requestUrl, params, cb) {
|
|||||||
cleanup()
|
cleanup()
|
||||||
if (self.destroyed) return
|
if (self.destroyed) return
|
||||||
|
|
||||||
if (err) return self.client.emit('warning', err)
|
if (err) return cb(err)
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
return self.client.emit('warning', new Error('Non-200 response code ' +
|
return cb(new Error('Non-200 response code ' +
|
||||||
res.statusCode + ' from ' + self.announceUrl))
|
res.statusCode + ' from ' + self.announceUrl))
|
||||||
}
|
}
|
||||||
if (!data || data.length === 0) {
|
if (!data || data.length === 0) {
|
||||||
return self.client.emit('warning', new Error('Invalid tracker response from' +
|
return cb(new Error('Invalid tracker response from' +
|
||||||
self.announceUrl))
|
self.announceUrl))
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data = bencode.decode(data)
|
data = bencode.decode(data)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return self.client.emit('warning', new Error('Error decoding tracker response: ' + err.message))
|
return cb(new Error('Error decoding tracker response: ' + err.message))
|
||||||
}
|
}
|
||||||
var failure = data['failure reason']
|
var failure = data['failure reason']
|
||||||
if (failure) {
|
if (failure) {
|
||||||
debug('failure from ' + requestUrl + ' (' + failure + ')')
|
debug('failure from ' + requestUrl + ' (' + failure + ')')
|
||||||
return self.client.emit('warning', new Error(failure))
|
return cb(new Error(failure))
|
||||||
}
|
}
|
||||||
|
|
||||||
var warning = data['warning message']
|
var warning = data['warning message']
|
||||||
@ -171,7 +173,7 @@ HTTPTracker.prototype._request = function (requestUrl, params, cb) {
|
|||||||
|
|
||||||
debug('response from ' + requestUrl)
|
debug('response from ' + requestUrl)
|
||||||
|
|
||||||
cb(data)
|
cb(null, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user