fix: Peer country flag not shown in peers list (#1894)

* fix: Peer country flag not shown in peers list

* Update functions.php
This commit is contained in:
Roman Kelesidis 2025-05-04 16:20:02 +03:00 committed by GitHub
commit 8edba72f09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -2189,7 +2189,9 @@ function readUpdaterFile(): array|bool
*/
function infoByIP(string $ipAddress, int $port = 0): array
{
if (!$data = CACHE('bb_ip2countries')->get($ipAddress . '_' . $port)) {
$ipAddress = \TorrentPier\Helpers\IPHelper::long2ip_extended($ipAddress);
$cacheName = hash('xxh128', ($ipAddress . '_' . $port));
if (!$data = CACHE('bb_ip2countries')->get($cacheName)) {
$data = [];
$response = file_get_contents(API_IP_URL . $ipAddress);
$json = json_decode($response, true);
@ -2200,7 +2202,7 @@ function infoByIP(string $ipAddress, int $port = 0): array
'continent' => $json['continent'],
'continentCode' => $json['continentCode']
];
CACHE('bb_ip2countries')->set($ipAddress . '_' . $port, $data, 1200);
CACHE('bb_ip2countries')->set($cacheName, $data, 1200);
}
}