Skip to content

Commit

Permalink
related to \#1119 : spam is restricted by 20 records per 300 seconds,…
Browse files Browse the repository at this point in the history
… at the same time clear DB from old entries
  • Loading branch information
ihptru committed Oct 6, 2011
1 parent c5f6f90 commit 33fcd87
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ping.php
Expand Up @@ -29,9 +29,14 @@ function check_port($ip, $port)

$select->execute();
$count = (int)$select->fetchColumn();
if ( $count > 10 )
if ( $count > 20 )
{
exit();
$stale = 60 * 5;
// If someone really spams master server using GET requests, he is restricted by 20 records per 300 seconds
// At the same time: remove old entries (why to keep them?)
$delete = $db->prepare('DELETE FROM servers WHERE (' . time() . ' - ts > ' . $stale . ')');
$delete->execute();
exit();
}

$port = $_REQUEST['port'];
Expand Down

0 comments on commit 33fcd87

Please sign in to comment.