fix: connectivity check on external tracker

The external tracker updates the peer row and doesn't touch the redis cache.
This commit is contained in:
Roardom
2024-04-19 14:17:42 +00:00
parent 509ee7316f
commit f653641e2b
5 changed files with 11 additions and 5 deletions
@@ -30,7 +30,7 @@ class TorrentPeerController extends Controller
'torrent' => $torrent,
'peers' => Peer::query()
->with('user')
->select(['torrent_id', 'user_id', 'uploaded', 'downloaded', 'left', 'port', 'agent', 'created_at', 'updated_at', 'seeder', 'active', 'visible'])
->select(['torrent_id', 'user_id', 'uploaded', 'downloaded', 'left', 'port', 'agent', 'created_at', 'updated_at', 'seeder', 'active', 'visible', 'connectable'])
->selectRaw('INET6_NTOA(ip) as ip')
->where('torrent_id', '=', $id)
->orderByDesc('active')
+1 -1
View File
@@ -90,7 +90,7 @@ class UserController extends Controller
'invitedBy' => Invite::where('accepted_by', '=', $user->id)->first(),
'clients' => $user->peers()
->select('agent', 'port')
->selectRaw('INET6_NTOA(ip) as ip, MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as num_peers')
->selectRaw('INET6_NTOA(ip) as ip, MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as num_peers, MAX(connectable) as connectable')
->groupBy(['ip', 'port', 'agent'])
->where('active', '=', true)
->get(),
@@ -294,7 +294,9 @@
<td class="user-active__connectable">
@php
$connectable = null;
if (cache()->has('peers:connectable:' . $active->ip . '-' . $active->port . '-' . $active->agent)) {
if (config('announce.external_tracker.is_enabled')) {
$connectable = $active->connectable;
} elseif (cache()->has('peers:connectable:' . $active->ip . '-' . $active->port . '-' . $active->agent)) {
$connectable = cache()->get('peers:connectable:' . $active->ip . '-' . $active->port . '-' . $active->agent);
}
@endphp
+3 -1
View File
@@ -106,7 +106,9 @@
@if (\config('announce.connectable_check') == true)
@php
$connectable = false;
if (cache()->has('peers:connectable:' . $peer->ip . '-' . $peer->port . '-' . $peer->agent)) {
if (config('announce.external_tracker.is_enabled')) {
$connectable = $peer->connectable;
} elseif (cache()->has('peers:connectable:' . $peer->ip . '-' . $peer->port . '-' . $peer->agent)) {
$connectable = cache()->get('peers:connectable:' . $peer->ip . '-' . $peer->port . '-' . $peer->agent);
}
@endphp
+3 -1
View File
@@ -303,7 +303,9 @@
@if (\config('announce.connectable_check') == true)
@php
$connectable = false;
if (cache()->has('peers:connectable:' . $client->ip . '-' . $client->port . '-' . $client->agent)) {
if (config('announce.external_tracker.is_enabled')) {
$connectable = $client->connectable;
} elseif (cache()->has('peers:connectable:' . $client->ip . '-' . $client->port . '-' . $client->agent)) {
$connectable = cache()->get('peers:connectable:' . $client->ip . '-' . $client->port . '-' . $client->agent);
}
@endphp