Skip to content

Commit

Permalink
fix: mangled scrape infohashes (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed Aug 1, 2023
1 parent b487809 commit 11cce83
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/client/http-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit 11cce83

Please sign in to comment.