diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 629ae16..2cffc2a 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -190,11 +190,11 @@ HTTPTracker.prototype._onAnnounceResponse = function (data) { self._trackerId = trackerId } - self.client.emit('update', { + var response = Object.assign({}, data, { announce: self.announceUrl, - complete: data.complete, - incomplete: data.incomplete + infoHash: common.binaryToHex(data.info_hash) }) + self.client.emit('update', response) var addrs if (Buffer.isBuffer(data.peers)) { @@ -248,15 +248,12 @@ HTTPTracker.prototype._onScrapeResponse = function (data) { } keys.forEach(function (infoHash) { - var response = data[infoHash] // TODO: optionally handle data.flags.min_request_interval // (separate from announce interval) - self.client.emit('scrape', { + var response = Object.assign(data[infoHash], { announce: self.announceUrl, - infoHash: common.binaryToHex(infoHash), - complete: response.complete, - incomplete: response.incomplete, - downloaded: response.downloaded + infoHash: common.binaryToHex(infoHash) }) + self.client.emit('scrape', response) }) } diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index c37ea7f..058bc28 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -266,8 +266,11 @@ WebSocketTracker.prototype._onAnnounceResponse = function (data) { } if (data.complete != null) { - data.announce = self.announceUrl - self.client.emit('update', data) + var response = Object.assign({}, data, { + announce: self.announceUrl, + infoHash: common.binaryToHex(data.info_hash) + }) + self.client.emit('update', response) } var peer @@ -323,16 +326,13 @@ WebSocketTracker.prototype._onScrapeResponse = function (data) { } keys.forEach(function (infoHash) { - var response = data[infoHash] // TODO: optionally handle data.flags.min_request_interval // (separate from announce interval) - self.client.emit('scrape', { + var response = Object.assign(data[infoHash], { announce: self.announceUrl, - infoHash: common.binaryToHex(infoHash), - complete: response.complete, - incomplete: response.incomplete, - downloaded: response.downloaded + infoHash: common.binaryToHex(infoHash) }) + self.client.emit('scrape', response) }) }