I’m stuck on Stage Discover peers #fi9
I have tried fetching from the tracker server url using the following url : http://bittorrent-test-(mentioned in the comments below
But it gives me a 404 not found error.
And here’s a snippet of my code:
is my infohash correct ?
//http://bittorrent-test-tracker.codecrafters.io/announce/info_hash=%d6%9f%91%e6%b2%ae%4c%54%24%68%d1%07%3a%71%d4%ea%13%87%9a%7f&peer_id=-PC0001-B1A6OIvyXa9I&port=6881&uploaded=0&downloaded=0&left=92063&compact=1
else if (command === "peers") {
const filePath = process.argv[3]
const obj = await infoTorrent(filePath)
const trackerUrl = obj.announce
const bencodedInfo = bencode(obj.info)
const hexInfo = Buffer.from(bencodedInfo, "binary")
const infoHash = calculateSHA1(hexInfo)
console.log("infohash", uriEncodeInfoHash(infoHash))
const params = new URLSearchParams({
info_hash : uriEncodeInfoHash(infoHash),
peer_id : generatePeerId(),
port : 6881,
uploaded : 0,
downloaded : 0,
left: obj.info.length,
compact : 1
});
console.log(`${obj.announce}/${decodeURIComponent(params.toString())}`)
const response = await fetch(`${obj.announce}/${decodeURIComponent(params.toString())}`);
const res = await response.json()
// console.log("res")
}