From 9ef4dd6d3572336355709cd4bf31cc06aa5df485 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Wed, 13 Jan 2021 01:58:02 +0100 Subject: [PATCH 1/2] fix: handle OSError exception on asyncio sockets --- yunodiagnoser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yunodiagnoser.py b/yunodiagnoser.py index e5f6816..49abffe 100644 --- a/yunodiagnoser.py +++ b/yunodiagnoser.py @@ -295,7 +295,7 @@ async def check_port_is_open(ip, port): try: _, writer = await asyncio.wait_for(futur, timeout=2) - except (asyncio.TimeoutError, ConnectionRefusedError): + except (asyncio.TimeoutError, ConnectionRefusedError, OSError): # OSError: [Errno 113] No route to host return False except Exception: import traceback @@ -350,7 +350,7 @@ async def check_smtp(request): try: reader, writer = await asyncio.wait_for(futur, timeout=2) - except (asyncio.TimeoutError, ConnectionRefusedError): + except (asyncio.TimeoutError, ConnectionRefusedError, OSError): # OSError: [Errno 113] No route to host return json_response({ 'status': "error_smtp_unreachable", 'content': "Could not open a connection on port 25, probably because of a firewall or port forwarding issue" From 52450c1873a00991143cee66e59fbe35599b9ac5 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Thu, 21 Jan 2021 19:44:36 +0100 Subject: [PATCH 2/2] fix: new exception --- yunodiagnoser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yunodiagnoser.py b/yunodiagnoser.py index 49abffe..e0b9dff 100644 --- a/yunodiagnoser.py +++ b/yunodiagnoser.py @@ -182,7 +182,7 @@ async def check_http_domain(ip, domain, nonce): "status": "error_http_check_timeout", "content": "Timed-out while trying to contact your server from outside. It appears to be unreachable. You should check that you're correctly forwarding port 80, that nginx is running, and that a firewall is not interfering.", } - except aiohttp.client_exceptions.ClientConnectorError as e: + except (OSError, aiohttp.client_exceptions.ClientConnectorError) as e: # OSError: [Errno 113] No route to host return { "status": "error_http_check_connection_error", "content": "Connection error: could not connect to the requested domain, it's very likely unreachable. Raw error: " + str(e),