mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 03:16:24 +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
|
||||
if (typeof params.info_hash === 'string') {
|
||||
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')
|
||||
|
||||
var response = {
|
||||
|
Loading…
Reference in New Issue
Block a user