2"""Compatibility with older versions"""
17if sys.version_info >= (3, 11):
20 import tomli
as tomllib
26LIMITER_CFG_DEPRECATED = {
27 "real_ip":
"limiter: config section 'real_ip' is deprecated",
28 "real_ip.x_for":
"real_ip.x_for has been replaced by botdetection.trusted_proxies",
29 "real_ip.ipv4_prefix":
"real_ip.ipv4_prefix has been replaced by botdetection.ipv4_prefix",
30 "real_ip.ipv6_prefix":
"real_ip.ipv6_prefix has been replaced by botdetection.ipv6_prefix'",
37 "category": DeprecationWarning,
38 "filename": str(cfg_file),
40 "module":
"searx.limiter",
43 for opt, msg
in LIMITER_CFG_DEPRECATED.items():
49 warnings.warn_explicit(msg, **kwargs)
50 if opt ==
"real_ip.ipv4_prefix":
51 cfg.set(
"botdetection.ipv4_prefix", val)
52 if opt ==
"real_ip.ipv6_prefix":
53 cfg.set(
"botdetection.ipv6_prefix", val)
limiter_fix_cfg(cfg, cfg_file)