summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2020-09-01 15:57:35 +0200
committerAdam Tauber <asciimoo@gmail.com>2020-09-01 15:59:22 +0200
commit4a913247b29286299e678e0756119fb62293760f (patch)
tree1f935147a6aae256639f65f248aa7abdddc62aa7
parentb329058c1ad06fe9c1afd56c81e0ad27dbef06b8 (diff)
downloadsearxng-4a913247b29286299e678e0756119fb62293760f.tar.gz
searxng-4a913247b29286299e678e0756119fb62293760f.zip
[enh] add option to configure proxies per engine - closes #1827
-rw-r--r--docs/dev/engine_overview.rst9
-rw-r--r--searx/poolrequests.py3
-rw-r--r--searx/search.py4
3 files changed, 12 insertions, 4 deletions
diff --git a/docs/dev/engine_overview.rst b/docs/dev/engine_overview.rst
index c3c81fff8..268995a45 100644
--- a/docs/dev/engine_overview.rst
+++ b/docs/dev/engine_overview.rst
@@ -49,16 +49,19 @@ offline boolean engine runs offline
settings.yml
------------
-======================= =========== ===========================================
+======================= =========== =============================================
argument type information
-======================= =========== ===========================================
+======================= =========== =============================================
name string name of search-engine
engine string name of searx-engine
(filename without ``.py``)
shortcut string shortcut of search-engine
timeout string specific timeout for search-engine
display_error_messages boolean display error messages on the web UI
-======================= =========== ===========================================
+proxies dict set proxies for a specific engine
+ (e.g. ``proxies : {http: socks5://proxy:port,
+ https: socks5://proxy:port}``)
+======================= =========== =============================================
overrides
diff --git a/searx/poolrequests.py b/searx/poolrequests.py
index f9a9d7719..9f0ee8736 100644
--- a/searx/poolrequests.py
+++ b/searx/poolrequests.py
@@ -95,7 +95,8 @@ def request(method, url, **kwargs):
session = SessionSinglePool()
# proxies
- kwargs['proxies'] = settings['outgoing'].get('proxies') or None
+ if kwargs.get('proxies') is None:
+ kwargs['proxies'] = settings['outgoing'].get('proxies')
# timeout
if 'timeout' in kwargs:
diff --git a/searx/search.py b/searx/search.py
index fcc838225..79896e5e1 100644
--- a/searx/search.py
+++ b/searx/search.py
@@ -70,6 +70,10 @@ def send_http_request(engine, request_params):
verify=request_params['verify']
)
+ # setting engine based proxies
+ if hasattr(engine, 'proxies'):
+ request_args['proxies'] = engine.proxies
+
# specific type of request (GET or POST)
if request_params['method'] == 'GET':
req = requests_lib.get