From 35e69786228a2d5776b4764e956f7d9dfb3e46fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 31 Jul 2018 11:57:27 +0200 Subject: [PATCH] main: Handle socket errors during the SSL handshake. --- main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index c8482da..8759f1a 100644 --- a/main.py +++ b/main.py @@ -239,8 +239,11 @@ def try_ssl_handshake(server): return False - except ssl.SSLError as error: - str_error = error.reason if error.reason else "Unknown error" + except (ssl.SSLError, socket.error) as error: + try: + str_error = error.reason if error.reason else "Unknown error" + except AttributeError: + str_error = str(error) message = ("{prefix}Error while doing SSL handshake" ": {error}").format( @@ -250,7 +253,7 @@ def try_ssl_handshake(server): server_buffer_prnt( server, ("{prefix}matrix: disconnecting from server..." - ).format(prefix=W.prefix("network"))) + ).format(prefix=W.prefix("network"))) server.disconnect() return False