feat: rate-limit good bots via object cache, add curl/ClaudeBot tiers, whitelist cache warmer
This commit is contained in:
+1
-3
@@ -10,7 +10,6 @@ firefox/19.0
|
|||||||
firefox/38.0
|
firefox/38.0
|
||||||
firefox/18.0
|
firefox/18.0
|
||||||
wget
|
wget
|
||||||
curl
|
|
||||||
libwww-perl
|
libwww-perl
|
||||||
WinHttp
|
WinHttp
|
||||||
okhttp
|
okhttp
|
||||||
@@ -229,7 +228,6 @@ Xaldon
|
|||||||
Zeus
|
Zeus
|
||||||
ZmEu
|
ZmEu
|
||||||
Zyborg
|
Zyborg
|
||||||
crawle
|
|
||||||
igdeSpyder
|
igdeSpyder
|
||||||
Robot
|
Robot
|
||||||
Aport
|
Aport
|
||||||
@@ -373,7 +371,7 @@ PolycomVVX
|
|||||||
^The Knowledge AI
|
^The Knowledge AI
|
||||||
SputnikBot
|
SputnikBot
|
||||||
od-database-crawler
|
od-database-crawler
|
||||||
Hype%20Machine
|
HypeMachine
|
||||||
The Hype Machine Engine
|
The Hype Machine Engine
|
||||||
Apache-HttpClient
|
Apache-HttpClient
|
||||||
Goodzer
|
Goodzer
|
||||||
|
|||||||
@@ -20,4 +20,6 @@ SemrushBot|10
|
|||||||
DotBot|20
|
DotBot|20
|
||||||
PetalBot|20
|
PetalBot|20
|
||||||
Bytespider|20
|
Bytespider|20
|
||||||
GPTBot|0
|
GPTBot|50
|
||||||
|
curl|10
|
||||||
|
ClaudeBot|50
|
||||||
@@ -12,3 +12,7 @@
|
|||||||
# ua:MyMonitoringTool
|
# ua:MyMonitoringTool
|
||||||
#
|
#
|
||||||
# Lines starting with # are comments. Blank lines are ignored.
|
# Lines starting with # are comments. Blank lines are ignored.
|
||||||
|
ua:rss-parser
|
||||||
|
ua:ZelistBot
|
||||||
|
ua:SimplePie
|
||||||
|
ua:SI-CacheWarmer
|
||||||
|
|||||||
@@ -119,10 +119,10 @@ class ITK_Bot_Blocker {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sliding window: track hits per bot per minute using transients.
|
// Sliding window: track hits per bot per minute using object cache (no DB writes).
|
||||||
$window = (int)(time() / 60); // 1-minute window
|
$window = (int)(time() / 60); // 1-minute window
|
||||||
$tk_key = 'itk_rl_' . md5($name) . '_' . $window;
|
$tk_key = 'itk_rl_' . md5($name) . '_' . $window;
|
||||||
$count = (int)get_transient($tk_key);
|
$count = (int)wp_cache_get($tk_key, 'itk_rl');
|
||||||
|
|
||||||
if ($count >= $limit) {
|
if ($count >= $limit) {
|
||||||
// Over the limit – log and send 429.
|
// Over the limit – log and send 429.
|
||||||
@@ -147,7 +147,7 @@ class ITK_Bot_Blocker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Under the limit – increment counter and allow through.
|
// Under the limit – increment counter and allow through.
|
||||||
set_transient($tk_key, $count + 1, 120);
|
wp_cache_set($tk_key, $count + 1, 'itk_rl', 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Blocking ─────────────────────────────────────────────── */
|
/* ── Blocking ─────────────────────────────────────────────── */
|
||||||
|
|||||||
Reference in New Issue
Block a user