321def initialize(settings_engines=None, settings_outgoing=None):
324 from searx
import settings
328 settings_engines = settings_engines
or settings[
'engines']
329 settings_outgoing = settings_outgoing
or settings[
'outgoing']
334 'enable_http':
False,
335 'verify': settings_outgoing[
'verify'],
336 'enable_http2': settings_outgoing[
'enable_http2'],
337 'max_connections': settings_outgoing[
'pool_connections'],
338 'max_keepalive_connections': settings_outgoing[
'pool_maxsize'],
339 'keepalive_expiry': settings_outgoing[
'keepalive_expiry'],
340 'local_addresses': settings_outgoing[
'source_ips'],
341 'using_tor_proxy': settings_outgoing[
'using_tor_proxy'],
342 'proxies': settings_outgoing[
'proxies'],
343 'max_redirects': settings_outgoing[
'max_redirects'],
344 'retries': settings_outgoing[
'retries'],
345 'retry_on_http_error':
None,
348 def new_network(params, logger_name=None):
349 nonlocal default_params
351 result.update(default_params)
352 result.update(params)
354 result[
'logger_name'] = logger_name
358 nonlocal settings_engines
359 for engine_spec
in settings_engines:
360 engine_name = engine_spec[
'name']
361 engine = engines.get(engine_name)
364 network = getattr(engine,
'network',
None)
365 yield engine_name, engine, network
370 NETWORKS[DEFAULT_NAME] = new_network({}, logger_name=
'default')
371 NETWORKS[
'ipv4'] = new_network({
'local_addresses':
'0.0.0.0'}, logger_name=
'ipv4')
372 NETWORKS[
'ipv6'] = new_network({
'local_addresses':
'::'}, logger_name=
'ipv6')
375 for network_name, network
in settings_outgoing[
'networks'].items():
376 NETWORKS[network_name] = new_network(network, logger_name=network_name)
379 for engine_name, engine, network
in iter_networks():
382 for attribute_name, attribute_value
in default_params.items():
383 if hasattr(engine, attribute_name):
384 network[attribute_name] = getattr(engine, attribute_name)
386 network[attribute_name] = attribute_value
387 NETWORKS[engine_name] = new_network(network, logger_name=engine_name)
388 elif isinstance(network, dict):
389 NETWORKS[engine_name] = new_network(network, logger_name=engine_name)
392 for engine_name, engine, network
in iter_networks():
393 if isinstance(network, str):
394 NETWORKS[engine_name] = NETWORKS[network]
399 if 'image_proxy' not in NETWORKS:
400 image_proxy_params = default_params.copy()
401 image_proxy_params[
'enable_http2'] =
False
402 NETWORKS[
'image_proxy'] = new_network(image_proxy_params, logger_name=
'image_proxy')
__init__(self, enable_http=True, verify=True, enable_http2=False, max_connections=None, max_keepalive_connections=None, keepalive_expiry=None, proxies=None, using_tor_proxy=False, local_addresses=None, retries=0, retry_on_http_error=None, max_redirects=30, logger_name=None)