Missing Key: info_hash on announce with bittorrent-4.2.2
| Project: | BitTorrent |
| Version: | 6.x-9.2-alpha3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | overall |
| Status: | closed |
bittorrent-4.2.2 is the most recent avaliable at CentOS/RHEL-4.x without major upgrade. But it's a bit stupid. It considers the announce URL as a final script URL, and does not recognize the ?passkey=XXX... variable.
Here is the example of apache log: "GET /announce.php?passkey=6b901eae9bfda6156a311cade0e4a418ebc11675?info_hash=%14%7Dx%7B%FBt%EB%BA%D7V%09w%81%14E%BF%2B%98r%28&peer_id=M4-2-2--304e2b92bd98&port=9090&key=ded76f66&uploaded=0&downloaded=0&left=102690458&compact=1 HTTP/1.0" 200 305 "-" "BitTorrent/4.2.2"
As you can see, it puts ?info_hash instead of &info_hash.
The simple workaround for me was to add fix in the very beginning of the announce.php:
if ( !empty($_GET['passkey']) and strlen($_GET['passkey']) > 40) {
$_GET['info_hash'] = substr($_GET['passkey'], 51);
$_GET['passkey'] = substr($_GET['passkey'], 0, 40);
}Now I found the same problem with BitTorrent/4.4.0 on RHEL-5.3 (rpm-packet from 'rpmforge' repository).
At the same time, Transmission (the linux torrent client) works fine.
Yes, this is the problem of the client program, bit I feel that it's easier just to fix it in the tracker, than to update all the clients.
The 'scrape.php' is not modified in my config, and I don't know if it's required.

#1
Modified a bit, for the case if the first variable is not the info_hash
if ( !empty($_GET['passkey']) and strlen($_GET['passkey']) > 40) {$data_position = strpos($_GET['passkey'], '=', 41);
$first_variable_name = substr($_GET['passkey'], 41, -41+$data_position);
$_GET[$first_variable_name] = substr($_GET['passkey'], 1+$data_position);
$_GET['passkey'] = substr($_GET['passkey'], 0, 40);
}
#2
I solved that this way:
<?phpparse_str(str_replace('?', '&', $_SERVER['QUERY_STRING']), $params);
?>
I currently don't have ability to test this because I just reinstalled my WinXP and have not configured MySQL yet...
So, please test this and let know results. If this will work, I'll commit this to branch when I'll able to do this.
Patch and patched file (just for case) are attached.
P.S. I see that this module is very popular among people from China and Russian Federation ;)
Hi, fellow ;)
#3
Suppose the issue is fixed.
Feel free to re-open it.
#4
Automatically closed -- issue fixed for 2 weeks with no activity.