From 11cce83ddd858813f5684da8a116de4bee6e518b Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Wed, 2 Aug 2023 00:05:46 +0200 Subject: [PATCH] fix: mangled scrape infohashes (#486) --- lib/client/http-tracker.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 162c68fb..9eefd892 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -4,7 +4,7 @@ import clone from 'clone' import Debug from 'debug' import get from 'simple-get' import Socks from 'socks' -import { bin2hex, hex2bin, arr2text } from 'uint8-util' +import { bin2hex, hex2bin, arr2text, text2arr, arr2hex } from 'uint8-util' import common from '../common.js' import Tracker from './tracker.js' @@ -244,12 +244,14 @@ class HTTPTracker extends Tracker { return } - keys.forEach(infoHash => { + keys.forEach(_infoHash => { // TODO: optionally handle data.flags.min_request_interval // (separate from announce interval) - const response = Object.assign(data[infoHash], { + const infoHash = _infoHash.length !== 20 ? arr2hex(text2arr(_infoHash)) : bin2hex(_infoHash) + + const response = Object.assign(data[_infoHash], { announce: this.announceUrl, - infoHash: bin2hex(infoHash) + infoHash }) this.client.emit('scrape', response) })