on master help sign in
[enh] add option to configure proxies per engine - closes #1827
4a91324Adam Tauber
docs/dev/engine_overview.rst+6−3
@@ -49,16 +49,19 @@ offline boolean engine runs offline
49settings.yml
49settings.yml
50------------
50------------
51
51
52−======================= =========== ===========================================
52+======================= =========== =============================================
53argument type information
53argument type information
54−======================= =========== ===========================================
54+======================= =========== =============================================
55name string name of search-engine
55name string name of search-engine
56engine string name of searx-engine
56engine string name of searx-engine
57 (filename without ``.py``)
57 (filename without ``.py``)
58shortcut string shortcut of search-engine
58shortcut string shortcut of search-engine
59timeout string specific timeout for search-engine
59timeout string specific timeout for search-engine
60display_error_messages boolean display error messages on the web UI
60display_error_messages boolean display error messages on the web UI
61+proxies dict set proxies for a specific engine
62+ (e.g. ``proxies : {http: socks5://proxy:port,
63+ https: socks5://proxy:port}``)
61−======================= =========== ===========================================
64+======================= =========== =============================================
62
65
63
66
64overrides
67overrides
searx/poolrequests.py+2−1
@@ -95,7 +95,8 @@ def request(method, url, **kwargs):
95 session = SessionSinglePool()
95 session = SessionSinglePool()
96
96
97 # proxies
97 # proxies
98+ if kwargs.get('proxies') is None:
98− kwargs['proxies'] = settings['outgoing'].get('proxies') or None
99+ kwargs['proxies'] = settings['outgoing'].get('proxies')
99
100
100 # timeout
101 # timeout
101 if 'timeout' in kwargs:
102 if 'timeout' in kwargs:
searx/search.py+4
@@ -70,6 +70,10 @@ def send_http_request(engine, request_params):
70 verify=request_params['verify']
70 verify=request_params['verify']
71 )
71 )
72
72
73+ # setting engine based proxies
74+ if hasattr(engine, 'proxies'):
75+ request_args['proxies'] = engine.proxies
76+
73 # specific type of request (GET or POST)
77 # specific type of request (GET or POST)
74 if request_params['method'] == 'GET':
78 if request_params['method'] == 'GET':
75 req = requests_lib.get
79 req = requests_lib.get