Merge pull request #4690 from spesmilo/aiorpcx-fx
asyncio: port exchange_rate and labels to aiohttp
This commit is contained in:
@@ -38,6 +38,8 @@ import asyncio
|
||||
|
||||
from .i18n import _
|
||||
|
||||
import aiohttp
|
||||
from aiohttp_socks import SocksConnector, SocksVer
|
||||
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import queue
|
||||
@@ -956,3 +958,17 @@ VerifiedTxInfo = NamedTuple("VerifiedTxInfo", [("height", int),
|
||||
("timestamp", int),
|
||||
("txpos", int),
|
||||
("header_hash", str)])
|
||||
|
||||
def make_aiohttp_session(proxy):
|
||||
if proxy:
|
||||
connector = SocksConnector(
|
||||
socks_ver=SocksVer.SOCKS5 if proxy['mode'] == 'socks5' else SocksVer.SOCKS4,
|
||||
host=proxy['host'],
|
||||
port=int(proxy['port']),
|
||||
username=proxy.get('user', None),
|
||||
password=proxy.get('password', None),
|
||||
rdns=True
|
||||
)
|
||||
return aiohttp.ClientSession(headers={'User-Agent' : 'Electrum'}, timeout=aiohttp.ClientTimeout(total=10), connector=connector)
|
||||
else:
|
||||
return aiohttp.ClientSession(headers={'User-Agent' : 'Electrum'}, timeout=aiohttp.ClientTimeout(total=10))
|
||||
|
||||
Reference in New Issue
Block a user