mirror of https://github.com/searxng/searxng.git
[fix] even if limiter not activated, botdetection must be activated
Closes: #2975 Closes: #2995 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
b6fe2cad71
commit
4acb52f68f
|
@ -218,10 +218,16 @@ def initialize(app: flask.Flask, settings):
|
||||||
"""Install the limiter"""
|
"""Install the limiter"""
|
||||||
global _INSTALLED # pylint: disable=global-statement
|
global _INSTALLED # pylint: disable=global-statement
|
||||||
|
|
||||||
|
# even if the limiter is not activated, the botdetection must be activated
|
||||||
|
# (e.g. the self_info plugin uses the botdetection to get client IP)
|
||||||
|
|
||||||
|
cfg = get_cfg()
|
||||||
|
redis_client = redisdb.client()
|
||||||
|
botdetection.init(cfg, redis_client)
|
||||||
|
|
||||||
if not (settings['server']['limiter'] or settings['server']['public_instance']):
|
if not (settings['server']['limiter'] or settings['server']['public_instance']):
|
||||||
return
|
return
|
||||||
|
|
||||||
redis_client = redisdb.client()
|
|
||||||
if not redis_client:
|
if not redis_client:
|
||||||
logger.error(
|
logger.error(
|
||||||
"The limiter requires Redis, please consult the documentation: "
|
"The limiter requires Redis, please consult the documentation: "
|
||||||
|
@ -233,10 +239,8 @@ def initialize(app: flask.Flask, settings):
|
||||||
|
|
||||||
_INSTALLED = True
|
_INSTALLED = True
|
||||||
|
|
||||||
cfg = get_cfg()
|
|
||||||
if settings['server']['public_instance']:
|
if settings['server']['public_instance']:
|
||||||
# overwrite limiter.toml setting
|
# overwrite limiter.toml setting
|
||||||
cfg.set('botdetection.ip_limit.link_token', True)
|
cfg.set('botdetection.ip_limit.link_token', True)
|
||||||
|
|
||||||
botdetection.init(cfg, redis_client)
|
|
||||||
app.before_request(pre_request)
|
app.before_request(pre_request)
|
||||||
|
|
Loading…
Reference in New Issue