Search code examples
javatracker

Torrent tracker reply with same peer id for every request?


I'm writing a Java app to look at the trackers listed in a torrent file.

I send the following:

http://pow7.com/announce?info_hash=%3f%99%79%31%73%27%9e%be%1d%d2%cd%5f%af%98%7c%17%5f%43%89%f3&peer_id=-jT1000-122843C6A4B0&port=6881&downloaded=0&left=0

But it doesn't matter what info_hash I send I either get the same peers ip address back (74.253.253.31:6757) or an error.

Any ideas why this happens?

Best regards, TX


Solution

  • Ok, I think I found the answer to my question: One needs to generate a SHA1 hash from the value of the info key. I take all the bytes from d (included, next byte after the word "info") to the last e of the info map (included).

    Thus is will be SHA1 of the bold part of the snippet below:

    ...:info d5:filesld6:...[many bytes]...e 9:... (With out the spaces in front of d and after e)

    Then I simple convert the byte array returned by MessageDigest and insert % for every hex 2 digit pair. E.g.:

    %70%47%8F...[snip]...%13%6F%6C