summaryrefslogtreecommitdiff
path: root/searx/limiter.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2023-10-02 18:29:58 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-11-01 06:44:56 +0100
commitd13a8f64534b2ba7883cabdae1d08ea68b7899c8 (patch)
treefa9148bf302c9b0af9352c7813ff19c9cb09b026 /searx/limiter.py
parentfd814aac863673047c46a9d80682415dae180969 (diff)
downloadsearxng-d13a8f64534b2ba7883cabdae1d08ea68b7899c8.tar.gz
searxng-d13a8f64534b2ba7883cabdae1d08ea68b7899c8.zip
[mod] document server:public_instance & remove it out of the botdetection
- the option server:public_instance lacks some documentation - the processing of this option belongs in the limiter and not in botdetection module Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/limiter.py')
-rw-r--r--searx/limiter.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/searx/limiter.py b/searx/limiter.py
index b61292d70..fa7418922 100644
--- a/searx/limiter.py
+++ b/searx/limiter.py
@@ -211,23 +211,33 @@ def pre_request():
def is_installed():
+ """Returns ``True`` if limiter is active and a redis DB is available."""
return _INSTALLED
def initialize(app: flask.Flask, settings):
- """Instal the botlimiter aka limiter"""
+ """Install the limiter"""
global _INSTALLED # pylint: disable=global-statement
- if not settings['server']['limiter'] and not settings['server']['public_instance']:
+
+ if not (settings['server']['limiter'] or settings['server']['public_instance']):
return
+
redis_client = redisdb.client()
if not redis_client:
logger.error(
"The limiter requires Redis, please consult the documentation: "
- + "https://docs.searxng.org/admin/searx.botdetection.html#limiter"
+ "https://docs.searxng.org/admin/searx.limiter.html"
)
if settings['server']['public_instance']:
sys.exit(1)
return
- botdetection.init(get_cfg(), redis_client)
- app.before_request(pre_request)
+
_INSTALLED = True
+
+ cfg = get_cfg()
+ if settings['server']['public_instance']:
+ # overwrite limiter.toml setting
+ cfg.set('botdetection.ip_limit.link_token', True)
+
+ botdetection.init(cfg, redis_client)
+ app.before_request(pre_request)