summaryrefslogtreecommitdiff
path: root/searx/limiter.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2024-10-27 07:08:28 +0100
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-10-28 12:51:05 +0100
commitda28f5280b8f5cac79963e10c79ddc2a3e65f93a (patch)
tree6b758a49fae78d9e4063b4bf9cf8be9020e83f0d /searx/limiter.py
parent543ab92fde232fdda7407fa1123ce9378c795bc3 (diff)
downloadsearxng-da28f5280b8f5cac79963e10c79ddc2a3e65f93a.tar.gz
searxng-da28f5280b8f5cac79963e10c79ddc2a3e65f93a.zip
[fix] limiter: don't hard code settings folder to /etc/searxng
The location of the local settings depends on environment ``SEARXNG_SETTINGS_PATH`` and can be different from ``/etc/searxng``. Issue was reported on Matrix [1]. To get the location function ``searx.settings_loader.get_user_cfg_folder()`` should be used. [1] https://matrix.to/#/!vxScbLNEAmRvOraXBn:matrix.org/$_eLS0JpE9oVEWsiGJkqJnWcFWEeZClIMGDK6cWv_Q4g?via=matrix.org&via=tchncs.de&via=envs.net Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/limiter.py')
-rw-r--r--searx/limiter.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/searx/limiter.py b/searx/limiter.py
index 93070dac5..6c1c8894b 100644
--- a/searx/limiter.py
+++ b/searx/limiter.py
@@ -128,9 +128,6 @@ _INSTALLED = False
LIMITER_CFG_SCHEMA = Path(__file__).parent / "limiter.toml"
"""Base configuration (schema) of the botdetection."""
-LIMITER_CFG = Path('/etc/searxng/limiter.toml')
-"""Local Limiter configuration."""
-
CFG_DEPRECATED = {
# "dummy.old.foo": "config 'dummy.old.foo' exists only for tests. Don't use it in your real project config."
}
@@ -138,8 +135,12 @@ CFG_DEPRECATED = {
def get_cfg() -> config.Config:
global CFG # pylint: disable=global-statement
+
if CFG is None:
- CFG = config.Config.from_toml(LIMITER_CFG_SCHEMA, LIMITER_CFG, CFG_DEPRECATED)
+ from . import settings_loader # pylint: disable=import-outside-toplevel
+
+ cfg_file = (settings_loader.get_user_cfg_folder() or Path("/etc/searxng")) / "limiter.toml"
+ CFG = config.Config.from_toml(LIMITER_CFG_SCHEMA, cfg_file, CFG_DEPRECATED)
return CFG