|
@ -167,6 +167,15 @@ class RequestTimedOut(GracefulDisconnect): |
|
|
|
|
|
|
|
|
class ErrorParsingSSLCert(Exception): pass |
|
|
class ErrorParsingSSLCert(Exception): pass |
|
|
class ErrorGettingSSLCertFromServer(Exception): pass |
|
|
class ErrorGettingSSLCertFromServer(Exception): pass |
|
|
|
|
|
class ConnectError(Exception): pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _Connector(aiorpcx.Connector): |
|
|
|
|
|
async def create_connection(self): |
|
|
|
|
|
try: |
|
|
|
|
|
return await super().create_connection() |
|
|
|
|
|
except OSError as e: |
|
|
|
|
|
raise ConnectError(e) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deserialize_server(server_str: str) -> Tuple[str, str, str]: |
|
|
def deserialize_server(server_str: str) -> Tuple[str, str, str]: |
|
@ -333,8 +342,7 @@ class Interface(Logger): |
|
|
return |
|
|
return |
|
|
try: |
|
|
try: |
|
|
await self.open_session(ssl_context) |
|
|
await self.open_session(ssl_context) |
|
|
except (asyncio.CancelledError, ConnectionError, socket.gaierror, aiorpcx.socks.SOCKSError) as e: |
|
|
except (asyncio.CancelledError, ConnectError, aiorpcx.socks.SOCKSError) as e: |
|
|
# note: catching OSError would be too broad here... don't want to catch file system exceptions |
|
|
|
|
|
self.logger.info(f'disconnecting due to: {repr(e)}') |
|
|
self.logger.info(f'disconnecting due to: {repr(e)}') |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
@ -419,7 +427,7 @@ class Interface(Logger): |
|
|
return self.network.default_server == self.server |
|
|
return self.network.default_server == self.server |
|
|
|
|
|
|
|
|
async def open_session(self, sslc, exit_early=False): |
|
|
async def open_session(self, sslc, exit_early=False): |
|
|
async with aiorpcx.Connector(NotificationSession, |
|
|
async with _Connector(NotificationSession, |
|
|
host=self.host, port=self.port, |
|
|
host=self.host, port=self.port, |
|
|
ssl=sslc, proxy=self.proxy) as session: |
|
|
ssl=sslc, proxy=self.proxy) as session: |
|
|
self.session = session # type: NotificationSession |
|
|
self.session = session # type: NotificationSession |
|
|