diff options
| author | Léon Tiekötter <leon@tiekoetter.com> | 2022-01-22 19:51:40 +0100 |
|---|---|---|
| committer | Léon Tiekötter <leon@tiekoetter.com> | 2022-01-27 22:37:02 +0100 |
| commit | 0cbf73a1f4d8ae894f56d89a20646f5244264a44 (patch) | |
| tree | 882e19b6ea0b519f0a2a4ea2b48d97701a66c195 /searx/engines/__init__.py | |
| parent | 1b03db4c737dbf0d6cf1ba4c5008c9a448f7a707 (diff) | |
Allow 'using_tor_proxy' to be set for each engine individually
Check 'using_tor_proxy' for each engine individually instead of checking globally
[fix] searx.network: update _rdns test to the last httpx version
Co-authored-by: Alexandre Flament <alex@al-f.net>
Diffstat (limited to 'searx/engines/__init__.py')
| -rw-r--r-- | searx/engines/__init__.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index b762c0dd9..ae132f48d 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -42,6 +42,7 @@ ENGINE_DEFAULT_ARGS = { "safesearch": False, "time_range_support": False, "enable_http": False, + "using_tor_proxy": False, "display_error_messages": True, "tokens": [], "about": {}, @@ -230,8 +231,8 @@ def set_language_attributes(engine: Engine): ) -def update_attributes_for_tor(engine): - if settings['outgoing'].get('using_tor_proxy') and hasattr(engine, 'onion_url'): +def update_attributes_for_tor(engine: Engine) -> bool: + if using_tor_proxy(engine) and hasattr(engine, 'onion_url'): engine.search_url = engine.onion_url + getattr(engine, 'search_path', '') engine.timeout += settings['outgoing'].get('extra_proxy_timeout', 0) @@ -249,13 +250,18 @@ def is_missing_required_attributes(engine): return missing +def using_tor_proxy(engine: Engine): + """Return True if the engine configuration declares to use Tor.""" + return settings['outgoing'].get('using_tor_proxy') or getattr(engine, 'using_tor_proxy', False) + + def is_engine_active(engine: Engine): # check if engine is inactive if engine.inactive is True: return False # exclude onion engines if not using tor - if 'onions' in engine.categories and not settings['outgoing'].get('using_tor_proxy'): + if 'onions' in engine.categories and not using_tor_proxy(engine): return False return True |