diff options
Diffstat (limited to 'searx/botdetection/__init__.py')
| -rw-r--r-- | searx/botdetection/__init__.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/searx/botdetection/__init__.py b/searx/botdetection/__init__.py index 4079d97a9..e686e3de9 100644 --- a/searx/botdetection/__init__.py +++ b/searx/botdetection/__init__.py @@ -4,19 +4,22 @@ Implementations used for bot detection. """ +from __future__ import annotations + +__all__ = ["init", "dump_request", "get_network", "too_many_requests", "ProxyFix"] + + +import valkey from ._helpers import dump_request -from ._helpers import get_real_ip from ._helpers import get_network from ._helpers import too_many_requests - -__all__ = ['dump_request', 'get_network', 'get_real_ip', 'too_many_requests'] - -valkey_client = None -cfg = None +from . import config +from . import valkeydb +from .trusted_proxies import ProxyFix -def init(_cfg, _valkey_client): - global valkey_client, cfg # pylint: disable=global-statement - valkey_client = _valkey_client - cfg = _cfg +def init(cfg: config.Config, valkey_client: valkey.Valkey | None): + config.set_global_cfg(cfg) + if valkey_client: + valkeydb.set_valkey_client(valkey_client) |