Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mangled scrape infohashes #486

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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