def open_connection(host, port, **kwargs): # 因为 aiohttp 组件原因,暂无法支持检测https代理, 因此弃用http/https代理,统一使用socks5代理 try: if conf['proxy']['proxy'].lower() == 'true': proxy_url = conf['proxy']['proxy_url'] return aiohttp_socks.open_connection(socks_url=proxy_url, host=host, port=port, **kwargs) except KeyError as e: logger.error("Load tentacle config error: %s, please check the config in tentacle.conf." %e ) return asyncio.open_connection(host=host, port=port, **kwargs)
def connector_f(host=None, port=None, proxy=None): if proxy: return aiohttp_socks.open_connection(socks_url=proxy, host=host, port=port) return asyncio.open_connection(host=host, port=port)