Commit 428bb128 authored by Alexandre's avatar Alexandre

Store connection state

parent aabc9550
......@@ -683,7 +683,8 @@ for ip in ip_set:
if opts.ifile is not None:
input.close()
conn.end()
if conn.state == 'CONN_OK':
conn.end()
if ok:
if opts.check or opts.pipelining:
......
......@@ -52,6 +52,7 @@ class Connection:
self.forceIPv4 = forceIPv4
self.forceIPv6 = forceIPv6
self.connect_to = connect_to
self.state = 'CONN_OK'
def __str__(self):
return self.server
......@@ -174,15 +175,20 @@ class ConnectionDOT(Connection):
self.session.connect((addr))
self.session.do_handshake()
except homer.exceptions.TimeoutConnectionError:
self.state = 'CONN_TIMEOUT'
raise homer.ConnectionDOTException("Timeout")
except OSError:
self.state = 'CONN_FAILED'
raise homer.ConnectionDOTException("Cannot connect")
except OpenSSL.SSL.SysCallError as e:
self.state = e.args[1]
raise homer.ConnectionDOTException("OpenSSL error: %s" % e.args[1])
except OpenSSL.SSL.ZeroReturnError:
# see #18
self.state = 'CONN_CLOSED'
raise homer.ConnectionDOTException("Error: The SSL connection has been closed (try with --nosni to avoid sending SNI ?)")
except OpenSSL.SSL.Error as e:
self.state = 'CONN_ERROR'
raise homer.ConnectionDOTException("OpenSSL error: %s" % ', '.join(err[0][2] for err in e.args))
# RFC 7858, section 4.2 and appendix A
......@@ -429,6 +435,7 @@ class ConnectionDOH(Connection):
try:
handle.perform()
except pycurl.error as e:
self.state = e.args[1]
raise homer.DOHException(e.args[1])
def receive(self, handle):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment