mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Prioritize returning leecher list for seeder announces (#961)
* Show IPv6 peers for cached announces
This commit is contained in:
parent
8f4d00c1cc
commit
50e305390d
3 changed files with 10 additions and 3 deletions
|
@ -58,7 +58,7 @@ if (!isset($peer_id)) {
|
|||
msg_die('peer_id was not provided');
|
||||
}
|
||||
if (strlen($peer_id) !== 20) {
|
||||
msg_die('Invalid peer_id: ' . bin2hex($peer_id));
|
||||
msg_die('Invalid peer_id: ' . $peer_id);
|
||||
}
|
||||
|
||||
// Verify info_hash
|
||||
|
@ -361,16 +361,19 @@ 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()
|
||||
LIMIT $numwant
|
||||
");
|
||||
|
||||
if (empty($rowset)) {
|
||||
$rowset[] = ['ip' => $ip, 'port' => $port];
|
||||
$rowset[] = ['ip' => long2ip(rand(1, 4294967295)), 'port' => rand(1, 65536)];
|
||||
}
|
||||
|
||||
if ($compact_mode) {
|
||||
|
|
|
@ -74,6 +74,10 @@ function dummy_exit($interval = 1800, $cache_dict = [])
|
|||
$output['peers'] = $cache_dict['peers'];
|
||||
}
|
||||
|
||||
if (isset($cache_dict['peers6'])) {
|
||||
$output['peers6'] = $cache_dict['peers6'];
|
||||
}
|
||||
|
||||
$output = \Arokettu\Bencode\Bencode::encode($output);
|
||||
|
||||
die($output);
|
||||
|
|
|
@ -61,7 +61,7 @@ class IPHelper extends Ip
|
|||
* @return string
|
||||
*/
|
||||
|
||||
public static function long2ip_extended($ip)
|
||||
public static function long2ip_extended(string $ip): string
|
||||
{
|
||||
return self::long2ip($ip, $ip > 4294967295);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue