mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-05 14:00:10 +00:00
Support scrape without info_hash specified (Fix #28)
This commit is contained in:
parent
5bc1b50ff5
commit
23d2c02fe6
@ -220,7 +220,13 @@ Server.prototype._onHttpRequest = function (req, res) {
|
|||||||
} else if (s[0] === '/scrape') { // unofficial scrape message
|
} else if (s[0] === '/scrape') { // unofficial scrape message
|
||||||
if (typeof params.info_hash === 'string') {
|
if (typeof params.info_hash === 'string') {
|
||||||
params.info_hash = [ params.info_hash ]
|
params.info_hash = [ params.info_hash ]
|
||||||
|
} else if (params.info_hash == null) {
|
||||||
|
// if info_hash param is omitted, stats for all torrents are returned
|
||||||
|
params.info_hash = Object.keys(self.torrents).map(function (infoHashHex) {
|
||||||
|
return common.bytewiseEncodeURIComponent(new Buffer(infoHashHex, 'hex'))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(params.info_hash)) return error('invalid info_hash')
|
if (!Array.isArray(params.info_hash)) return error('invalid info_hash')
|
||||||
|
|
||||||
var response = {
|
var response = {
|
||||||
|
Loading…
Reference in New Issue
Block a user