(Update) Announce Controller 🚀

- allow for rate limit to be configuarable
This commit is contained in:
HDVinnie
2018-12-14 12:12:24 -05:00
parent 47724aaa06
commit 7358d3d0bb
2 changed files with 14 additions and 3 deletions
+3 -3
View File
@@ -187,10 +187,10 @@ class AnnounceController extends Controller
$peers = $torrent->peers->where('info_hash', $info_hash)->take(100)->toArray();
// Pull Count On Users Peers Per Torrent
$limit = $torrent->peers->where('user_id', $user->id)->count();
$connections = $torrent->peers->where('user_id', $user->id)->count();
// If Users Peer Count On A Single Torrent Is Greater Than 3 Return Error to Client
if ($limit > 3) {
// If Users Peer Count On A Single Torrent Is Greater Than X Return Error to Client
if ($connections > config('announce.rate_limit')) {
//info('Client Attempted To Connect To Announce But Has Hit Rate Limits');
return response(Bencode::bencode(['failure reason' => 'You have reached the rate limit']), 200, ['Content-Type' => 'text/plain']);
}