mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
feat(announcer): Block User-Agent
strings that are too long (#1763)
* feat(announcer): Block `User-Agent` strings that are too long * Update announce.php
This commit is contained in:
parent
9b1dbbbcb6
commit
a98f8f102a
1 changed files with 15 additions and 3 deletions
|
@ -108,10 +108,13 @@ if (strlen($info_hash) !== 20) {
|
||||||
msg_die('Invalid info_hash: ' . (mb_check_encoding($info_hash, 'UTF8') ? $info_hash : $info_hash_hex));
|
msg_die('Invalid info_hash: ' . (mb_check_encoding($info_hash, 'UTF8') ? $info_hash : $info_hash_hex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block system-reserved ports since 99.9% of the time they're fake and thus not connectable
|
||||||
|
* Some clients will send port of 0 on 'stopped' events. Let them through as they won't receive peers anyway.
|
||||||
|
*
|
||||||
|
* @see https://github.com/HDInnovations/UNIT3D-Community-Edition/blob/c64275f0b5dcb3c4c845d5204871adfe24f359d6/app/Http/Controllers/AnnounceController.php#L284
|
||||||
|
*/
|
||||||
if (
|
if (
|
||||||
// https://github.com/HDInnovations/UNIT3D-Community-Edition/blob/c64275f0b5dcb3c4c845d5204871adfe24f359d6/app/Http/Controllers/AnnounceController.php#L284
|
|
||||||
// Block system-reserved ports since 99.9% of the time they're fake and thus not connectable
|
|
||||||
// Some clients will send port of 0 on 'stopped' events. Let them through as they won't receive peers anyway.
|
|
||||||
!isset($port)
|
!isset($port)
|
||||||
|| ($port < 1024 && !$stopped)
|
|| ($port < 1024 && !$stopped)
|
||||||
|| $port > 0xFFFF) {
|
|| $port > 0xFFFF) {
|
||||||
|
@ -130,6 +133,15 @@ if (!isset($left) || $left < 0) {
|
||||||
msg_die('Invalid left value: ' . $left);
|
msg_die('Invalid left value: ' . $left);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check User-Agent length
|
||||||
|
*
|
||||||
|
* @see https://github.com/HDInnovations/UNIT3D-Community-Edition/blob/c64275f0b5dcb3c4c845d5204871adfe24f359d6/app/Http/Controllers/AnnounceController.php#L177
|
||||||
|
*/
|
||||||
|
if (strlen((string)$_SERVER['HTTP_USER_AGENT']) > 64) {
|
||||||
|
msg_die('User-Agent must be less than 64 characters long');
|
||||||
|
}
|
||||||
|
|
||||||
// IP
|
// IP
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue