Skip to content

Commit

Permalink
Merge pull request #3767 from Roardom/fix-external-tracker-connectivi…
Browse files Browse the repository at this point in the history
…ty-status

(Fix) Connectivity check on external tracker
  • Loading branch information
HDVinnie authored Apr 19, 2024
2 parents 3b6dac0 + f653641 commit ab956c2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/TorrentPeerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function index(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\V
'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')
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function show(Request $request, User $user): \Illuminate\Contracts\View\F
'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(),
Expand Down
4 changes: 3 additions & 1 deletion resources/views/livewire/user-active.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ class="user-active__name"
<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
Expand Down
4 changes: 3 additions & 1 deletion resources/views/torrent/peers.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class="nav-tab__link"
@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
Expand Down
4 changes: 3 additions & 1 deletion resources/views/user/profile/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ class="user-search__avatar"
@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
Expand Down

0 comments on commit ab956c2

Please sign in to comment.