Browse Source

interface: minor clean-up split out _set_proxy from init

3.3.3.1
SomberNight 6 years ago
parent
commit
c93d137c5e
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 10
      electrum/interface.py

10
electrum/interface.py

@ -139,6 +139,7 @@ class Interface(PrintError):
self.cert_path = os.path.join(self.config_path, 'certs', self.host)
self.blockchain = None
self.network = network
self._set_proxy(proxy)
self.tip_header = None
self.tip = 0
@ -147,6 +148,10 @@ class Interface(PrintError):
self.fut = asyncio.get_event_loop().create_task(self.run())
self.group = SilentTaskGroup()
def diagnostic_name(self):
return self.host
def _set_proxy(self, proxy: dict):
if proxy:
username, pw = proxy.get('user'), proxy.get('password')
if not username or not pw:
@ -158,13 +163,10 @@ class Interface(PrintError):
elif proxy['mode'] == "socks5":
self.proxy = aiorpcx.socks.SOCKSProxy((proxy['host'], int(proxy['port'])), aiorpcx.socks.SOCKS5, auth)
else:
raise NotImplementedError # http proxy not available with aiorpcx
raise NotImplementedError # http proxy not available with aiorpcx
else:
self.proxy = None
def diagnostic_name(self):
return self.host
async def is_server_ca_signed(self, sslc):
try:
await self.open_session(sslc, exit_early=True)

Loading…
Cancel
Save