mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 13:24:07 +00:00
sort output of blocked list by block timestamp
This commit is contained in:
@@ -17,6 +17,12 @@
|
|||||||
(defined('CONST_ConnectionBucket_PageType')?constant('CONST_ConnectionBucket_Cost_'.CONST_ConnectionBucket_PageType):1) + user_busy_cost(),
|
(defined('CONST_ConnectionBucket_PageType')?constant('CONST_ConnectionBucket_Cost_'.CONST_ConnectionBucket_PageType):1) + user_busy_cost(),
|
||||||
CONST_ConnectionBucket_LeakRate, CONST_ConnectionBucket_BlockLimit);
|
CONST_ConnectionBucket_LeakRate, CONST_ConnectionBucket_BlockLimit);
|
||||||
|
|
||||||
|
if ($fBucketVal > CONST_ConnectionBucket_WaitLimit && $fBucketVal < CONST_ConnectionBucket_BlockLimit)
|
||||||
|
{
|
||||||
|
sleep(($fBucketVal - CONST_ConnectionBucket_WaitLimit)/CONST_ConnectionBucket_LeakRate);
|
||||||
|
$fBucketVal = doBucket($aBucketKeys, 0, 0, CONST_ConnectionBucket_BlockLimit);
|
||||||
|
}
|
||||||
|
|
||||||
if (strpos(CONST_BlockedIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false || $fBucketVal >= CONST_ConnectionBucket_BlockLimit)
|
if (strpos(CONST_BlockedIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false || $fBucketVal >= CONST_ConnectionBucket_BlockLimit)
|
||||||
{
|
{
|
||||||
echo "Your IP has been blocked. \n";
|
echo "Your IP has been blocked. \n";
|
||||||
@@ -25,9 +31,4 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fBucketVal > CONST_ConnectionBucket_WaitLimit)
|
|
||||||
{
|
|
||||||
sleep(($fBucketVal - CONST_ConnectionBucket_WaitLimit)/CONST_ConnectionBucket_LeakRate);
|
|
||||||
}
|
|
||||||
|
|
||||||
header('Content-type: text/html; charset=utf-8');
|
header('Content-type: text/html; charset=utf-8');
|
||||||
|
|||||||
10
lib/lib.php
10
lib/lib.php
@@ -994,6 +994,15 @@
|
|||||||
return $iMaxVal;
|
return $iMaxVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function byLastBlockTime($a, $b)
|
||||||
|
{
|
||||||
|
if ($a['lastBlockTimestamp'] == $b['lastBlockTimestamp'])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ($a['lastBlockTimestamp'] > $b['lastBlockTimestamp']) ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
function getBucketBlocks()
|
function getBucketBlocks()
|
||||||
{
|
{
|
||||||
$m = getBucketMemcache();
|
$m = getBucketMemcache();
|
||||||
@@ -1014,6 +1023,7 @@
|
|||||||
'currentlyBlocked' => $iCurrentBucketSize + (CONST_ConnectionBucket_Cost_Reverse) >= CONST_ConnectionBucket_BlockLimit,
|
'currentlyBlocked' => $iCurrentBucketSize + (CONST_ConnectionBucket_Cost_Reverse) >= CONST_ConnectionBucket_BlockLimit,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
uasort($aBlockedList, 'byLastBlockTime');
|
||||||
return $aBlockedList;
|
return $aBlockedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user