2603.18 - frequenet added since parameter
This commit is contained in:
@@ -11,7 +11,9 @@
|
||||
* - ?token=<TRIGGER_TOKEN>
|
||||
*
|
||||
* Optional query parameters:
|
||||
* threshold int Override the configured minimum connection count
|
||||
* threshold int Override the configured minimum connection count
|
||||
* since string YYYYMMDDHHmmss (e.g. "20260315000000"); only IPs
|
||||
* with a last_seen >= this value are returned
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../includes/auth.php';
|
||||
@@ -55,11 +57,23 @@ $threshold = isset($_GET['threshold'])
|
||||
? max(1, (int)$_GET['threshold'])
|
||||
: $configured_threshold;
|
||||
|
||||
$rows = frequent_ips($threshold);
|
||||
$since = null;
|
||||
if (isset($_GET['since']) && $_GET['since'] !== '') {
|
||||
$dt = DateTime::createFromFormat('YmdHis', $_GET['since']);
|
||||
if ($dt === false) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'Invalid since parameter; expected YYYYMMDDHHmmss e.g. 20260315000000']);
|
||||
exit;
|
||||
}
|
||||
$since = $dt->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$rows = frequent_ips($threshold, $since);
|
||||
|
||||
echo json_encode([
|
||||
'threshold' => $threshold,
|
||||
'configured_threshold' => $configured_threshold,
|
||||
'since' => $since,
|
||||
'count' => count($rows),
|
||||
'ips' => array_map(fn($r) => [
|
||||
'src_ip' => $r['src_ip'],
|
||||
|
||||
Reference in New Issue
Block a user