[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: 
This commit is contained in:
bearz314 2025-02-09 00:25:13 +11:00
parent 28ead13eb9
commit 3e409047e5

View File

@ -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: