From 3e409047e5cf6fd28a0e7052ee54587077ab0f23 Mon Sep 17 00:00:00 2001 From: bearz314 Date: Sun, 9 Feb 2025 00:25:13 +1100 Subject: [PATCH] [fix] botdetection: return error, do not fail silently Returns 429 (too many requests) when too many suspicious requests, instead of returning to homepage with 302 (found). This is in line with how other botdetections are handled. This partially reverts b8c7c2c where this was changed without reason. Without this commit, users in the blocked state, upon searching, will see that their query disappear without further explanation. Refer: #3191 --- searx/botdetection/ip_limit.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/searx/botdetection/ip_limit.py b/searx/botdetection/ip_limit.py index b4c6825b3..8d8ac6a3c 100644 --- a/searx/botdetection/ip_limit.py +++ b/searx/botdetection/ip_limit.py @@ -122,8 +122,7 @@ def filter_request( redis_client, 'ip_limit.SUSPICIOUS_IP_WINDOW' + network.compressed, SUSPICIOUS_IP_WINDOW ) if c > SUSPICIOUS_IP_MAX: - logger.error("BLOCK: too many request from %s in SUSPICIOUS_IP_WINDOW (redirect to /)", network) - return flask.redirect(flask.url_for('index'), code=302) + return too_many_requests(network, "too many request in SUSPICIOUS_IP_WINDOW (SUSPICIOUS_IP_MAX)") c = incr_sliding_window(redis_client, 'ip_limit.BURST_WINDOW' + network.compressed, BURST_WINDOW) if c > BURST_MAX_SUSPICIOUS: