mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
change level of reject reason to warning
This commit is contained in:
parent
450b84c9d0
commit
a7f81cf12e
1 changed files with 5 additions and 5 deletions
|
@ -71,7 +71,7 @@ def is_accepted_request(inc_get_counter) -> bool:
|
||||||
|
|
||||||
if request.path == '/image_proxy':
|
if request.path == '/image_proxy':
|
||||||
if re_bot.match(user_agent):
|
if re_bot.match(user_agent):
|
||||||
logger.info(f"reject [{client_ip}]: client may be a bot described by UA=\"{user_agent}\"")
|
logger.warning(f"reject [{client_ip}]: client may be a bot described by UA=\"{user_agent}\"")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -80,15 +80,15 @@ def is_accepted_request(inc_get_counter) -> bool:
|
||||||
c_10min = inc_get_counter(interval=600, keys=[b'IP limit, 10 minutes', client_ip])
|
c_10min = inc_get_counter(interval=600, keys=[b'IP limit, 10 minutes', client_ip])
|
||||||
|
|
||||||
if c_burst > c_burst_limit or c_10min > c_10min_limit:
|
if c_burst > c_burst_limit or c_10min > c_10min_limit:
|
||||||
logger.info(f"reject [{client_ip}]: c_burst({c_burst})>{c_burst_limit} or c_10min({c_10min})>{c_10min_limit}")
|
logger.warning(f"reject [{client_ip}]: c_burst({c_burst})>{c_burst_limit} or c_10min({c_10min})>{c_10min_limit}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if re_bot.match(user_agent):
|
if re_bot.match(user_agent):
|
||||||
logger.info(f"reject [{client_ip}]: client may be a bot described by UA=\"{user_agent}\"")
|
logger.warning(f"reject [{client_ip}]: client may be a bot described by UA=\"{user_agent}\"")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if request.headers.get('Accept-Language', '').strip():
|
if request.headers.get('Accept-Language', '').strip():
|
||||||
logger.info(f"reject [{client_ip}]: empty Accept-Language")
|
logger.warning(f"reject [{client_ip}]: empty Accept-Language")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# If SearXNG is behind Cloudflare, all requests will get 429 because
|
# If SearXNG is behind Cloudflare, all requests will get 429 because
|
||||||
|
@ -102,7 +102,7 @@ def is_accepted_request(inc_get_counter) -> bool:
|
||||||
# return False
|
# return False
|
||||||
|
|
||||||
if 'text/html' not in request.accept_mimetypes:
|
if 'text/html' not in request.accept_mimetypes:
|
||||||
logger.info(f"reject [{client_ip}]: non-html request to /search")
|
logger.warning(f"reject [{client_ip}]: non-html request to /search")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# IDK but maybe api limit should based on path not format?
|
# IDK but maybe api limit should based on path not format?
|
||||||
|
|
Loading…
Add table
Reference in a new issue