mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 14:23:57 -07:00
feat(announcer): Blocking all ports lower then 1024
(#1762)
* feat(announcer): Blocking all ports lower then `1024` * Update announce.php
This commit is contained in:
parent
a1e0170770
commit
1bc7e09ddb
1 changed files with 10 additions and 4 deletions
|
@ -100,12 +100,21 @@ $info_hash_hex = bin2hex($info_hash);
|
||||||
// Store peer id
|
// Store peer id
|
||||||
$peer_id_sql = preg_replace('/[^a-zA-Z0-9\-\_]/', '', $peer_id);
|
$peer_id_sql = preg_replace('/[^a-zA-Z0-9\-\_]/', '', $peer_id);
|
||||||
|
|
||||||
|
// Stopped event
|
||||||
|
$stopped = ($event === 'stopped');
|
||||||
|
|
||||||
// Check info_hash length
|
// Check info_hash length
|
||||||
if (strlen($info_hash) !== 20) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($port) || $port < 0 || $port > 0xFFFF) {
|
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)
|
||||||
|
|| ($port < 1024 && !$stopped)
|
||||||
|
|| $port > 0xFFFF) {
|
||||||
msg_die('Invalid port: ' . $port);
|
msg_die('Invalid port: ' . $port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,9 +167,6 @@ if ($ip_version === 'ipv6') {
|
||||||
// Peer unique id
|
// Peer unique id
|
||||||
$peer_hash = hash('xxh128', $passkey . $info_hash_hex . $port);
|
$peer_hash = hash('xxh128', $passkey . $info_hash_hex . $port);
|
||||||
|
|
||||||
// Events
|
|
||||||
$stopped = ($event === 'stopped');
|
|
||||||
|
|
||||||
// Set seeder & complete
|
// Set seeder & complete
|
||||||
$complete = $seeder = ($left == 0) ? 1 : 0;
|
$complete = $seeder = ($left == 0) ? 1 : 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue