Better way to prioritize peers (#962)

This commit is contained in:
Cønstantine Kovalensky 2023-10-06 17:51:08 +04:00 committed by GitHub
commit 9b3d2a4ebd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -361,19 +361,16 @@ if (!$output) {
$numwant = (int)$bb_cfg['tracker']['numwant'];
$compact_mode = ($bb_cfg['tracker']['compact_mode'] || !empty($compact));
$leechers_only = $seeder ? 'AND seeder = 0' : ''; // Return leechers for seeders
$rowset = DB()->fetch_rowset("
SELECT ip, port
FROM " . BB_BT_TRACKER . "
WHERE topic_id = $topic_id
$leechers_only
ORDER BY RAND()
ORDER BY seeder ASC, RAND()
LIMIT $numwant
");
if (empty($rowset)) {
$rowset[] = ['ip' => long2ip(rand(1, 4294967295)), 'port' => rand(1, 65536)];
$rowset[] = ['ip' => \TorrentPier\Helpers\IPHelper::ip2long($ip), 'port' => (int)$port];
}
if ($compact_mode) {