mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 06:13:58 -07:00
Better way to prioritize peers (#962)
This commit is contained in:
parent
50e305390d
commit
9b3d2a4ebd
1 changed files with 7 additions and 10 deletions
|
@ -361,19 +361,16 @@ if (!$output) {
|
||||||
$numwant = (int)$bb_cfg['tracker']['numwant'];
|
$numwant = (int)$bb_cfg['tracker']['numwant'];
|
||||||
$compact_mode = ($bb_cfg['tracker']['compact_mode'] || !empty($compact));
|
$compact_mode = ($bb_cfg['tracker']['compact_mode'] || !empty($compact));
|
||||||
|
|
||||||
$leechers_only = $seeder ? 'AND seeder = 0' : ''; // Return leechers for seeders
|
|
||||||
|
|
||||||
$rowset = DB()->fetch_rowset("
|
$rowset = DB()->fetch_rowset("
|
||||||
SELECT ip, port
|
SELECT ip, port
|
||||||
FROM " . BB_BT_TRACKER . "
|
FROM " . BB_BT_TRACKER . "
|
||||||
WHERE topic_id = $topic_id
|
WHERE topic_id = $topic_id
|
||||||
$leechers_only
|
ORDER BY seeder ASC, RAND()
|
||||||
ORDER BY RAND()
|
LIMIT $numwant
|
||||||
LIMIT $numwant
|
");
|
||||||
");
|
|
||||||
|
|
||||||
if (empty($rowset)) {
|
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) {
|
if ($compact_mode) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue