summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2022-02-18 22:17:26 +0100
committerGitHub <noreply@github.com>2022-02-18 22:17:26 +0100
commit29182eb1c9b13a2f0e6d390f5aae6bebb71955a7 (patch)
tree689e0e19ccb5a3f4b39707a8835809b887435ece /searx
parentbf2a2ed48faf511a609d3b084b02066d69549015 (diff)
parentd1b7debac684bb426faa11839f788afb6f7a679f (diff)
downloadsearxng-29182eb1c9b13a2f0e6d390f5aae6bebb71955a7.tar.gz
searxng-29182eb1c9b13a2f0e6d390f5aae6bebb71955a7.zip
Merge pull request #899 from dalf/limiter_update
[limiter] update
Diffstat (limited to 'searx')
-rw-r--r--searx/plugins/limiter.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/searx/plugins/limiter.py b/searx/plugins/limiter.py
index e028e3e4a..6accf2c1c 100644
--- a/searx/plugins/limiter.py
+++ b/searx/plugins/limiter.py
@@ -42,19 +42,16 @@ def is_accepted_request(inc_get_counter) -> bool:
return False
return True
- if request.path == '/search' and ('q' in request.args or 'q' in request.form):
- c = inc_get_counter(interval=20, keys=[b'IP limit, burst', x_forwarded_for])
- if c > 30:
- return False
-
- c = inc_get_counter(interval=600, keys=[b'IP limit, 10 minutes', x_forwarded_for])
- if c > 300:
+ if request.path == '/search':
+ c_burst = inc_get_counter(interval=20, keys=[b'IP limit, burst', x_forwarded_for])
+ c_10min = inc_get_counter(interval=600, keys=[b'IP limit, 10 minutes', x_forwarded_for])
+ if c_burst > 15 or c_10min > 150:
return False
if re_bot.match(user_agent):
return False
- if 'Accept-Language' not in request.headers:
+ if len(request.headers.get('Accept-Language', '').strip()) == '':
return False
if request.headers.get('Connection') == 'close':
@@ -113,7 +110,6 @@ def create_pre_request(get_aggregation_count):
def init(app, settings):
-
if not settings['server']['limiter']:
return False