Skip to content

Commit f65983e

Browse files
committed
do not filter out extra keys from 'update' events
1 parent 8482c3a commit f65983e

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

lib/client/http-tracker.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ HTTPTracker.prototype._onAnnounceResponse = function (data) {
190190
self._trackerId = trackerId
191191
}
192192

193-
self.client.emit('update', {
193+
var response = Object.assign({}, data, {
194194
announce: self.announceUrl,
195-
complete: data.complete,
196-
incomplete: data.incomplete
195+
infoHash: common.binaryToHex(data.info_hash)
197196
})
197+
self.client.emit('update', response)
198198

199199
var addrs
200200
if (Buffer.isBuffer(data.peers)) {
@@ -248,15 +248,12 @@ HTTPTracker.prototype._onScrapeResponse = function (data) {
248248
}
249249

250250
keys.forEach(function (infoHash) {
251-
var response = data[infoHash]
252251
// TODO: optionally handle data.flags.min_request_interval
253252
// (separate from announce interval)
254-
self.client.emit('scrape', {
253+
var response = Object.assign(data[infoHash], {
255254
announce: self.announceUrl,
256-
infoHash: common.binaryToHex(infoHash),
257-
complete: response.complete,
258-
incomplete: response.incomplete,
259-
downloaded: response.downloaded
255+
infoHash: common.binaryToHex(infoHash)
260256
})
257+
self.client.emit('scrape', response)
261258
})
262259
}

lib/client/websocket-tracker.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,11 @@ WebSocketTracker.prototype._onAnnounceResponse = function (data) {
266266
}
267267

268268
if (data.complete != null) {
269-
data.announce = self.announceUrl
270-
self.client.emit('update', data)
269+
var response = Object.assign({}, data, {
270+
announce: self.announceUrl,
271+
infoHash: common.binaryToHex(data.info_hash)
272+
})
273+
self.client.emit('update', response)
271274
}
272275

273276
var peer
@@ -323,16 +326,13 @@ WebSocketTracker.prototype._onScrapeResponse = function (data) {
323326
}
324327

325328
keys.forEach(function (infoHash) {
326-
var response = data[infoHash]
327329
// TODO: optionally handle data.flags.min_request_interval
328330
// (separate from announce interval)
329-
self.client.emit('scrape', {
331+
var response = Object.assign(data[infoHash], {
330332
announce: self.announceUrl,
331-
infoHash: common.binaryToHex(infoHash),
332-
complete: response.complete,
333-
incomplete: response.incomplete,
334-
downloaded: response.downloaded
333+
infoHash: common.binaryToHex(infoHash)
335334
})
335+
self.client.emit('scrape', response)
336336
})
337337
}
338338

0 commit comments

Comments
 (0)