From 23d2c02fe65d2e6c137733251f38b7da0116ce2f Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 10 Jul 2014 21:30:10 -0700 Subject: [PATCH] Support scrape without info_hash specified (Fix #28) --- server.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server.js b/server.js index 8d3a0eb..55366c7 100644 --- a/server.js +++ b/server.js @@ -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 = {