Resolved #1639: display sni on ClientConnection

This commit is contained in:
chhsiao90 2016-10-25 09:59:54 +08:00
parent 21f133fae9
commit 39ac29e37c
4 changed files with 10 additions and 1 deletions

View File

@ -20,6 +20,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
timestamp_start: Connection start timestamp timestamp_start: Connection start timestamp
timestamp_ssl_setup: TLS established timestamp timestamp_ssl_setup: TLS established timestamp
timestamp_end: Connection end timestamp timestamp_end: Connection end timestamp
sni: Server Name Indication sent by client during the TLS handshake
""" """
def __init__(self, client_connection, address, server): def __init__(self, client_connection, address, server):
@ -40,6 +41,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
self.timestamp_end = None self.timestamp_end = None
self.timestamp_ssl_setup = None self.timestamp_ssl_setup = None
self.protocol = None self.protocol = None
self.sni = None
def __bool__(self): def __bool__(self):
return bool(self.connection) and not self.finished return bool(self.connection) and not self.finished
@ -61,6 +63,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
timestamp_start=float, timestamp_start=float,
timestamp_ssl_setup=float, timestamp_ssl_setup=float,
timestamp_end=float, timestamp_end=float,
sni=str,
) )
def copy(self): def copy(self):
@ -86,12 +89,14 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
ssl_established=False, ssl_established=False,
timestamp_start=None, timestamp_start=None,
timestamp_end=None, timestamp_end=None,
timestamp_ssl_setup=None timestamp_ssl_setup=None,
sni=None
)) ))
def convert_to_ssl(self, *args, **kwargs): def convert_to_ssl(self, *args, **kwargs):
super().convert_to_ssl(*args, **kwargs) super().convert_to_ssl(*args, **kwargs)
self.timestamp_ssl_setup = time.time() self.timestamp_ssl_setup = time.time()
self.sni = self.connection.get_servername()
def finish(self): def finish(self):
super().finish() super().finish()

View File

@ -66,6 +66,7 @@ def convert_017_018(data):
def convert_018_019(data): def convert_018_019(data):
data["version"] = (0, 19) data["version"] = (0, 19)
data["client_conn"]["sni"] = None
return data return data

View File

@ -82,6 +82,8 @@ def flowdetails(state, flow):
parts = [ parts = [
["Address", repr(cc.address)], ["Address", repr(cc.address)],
] ]
if cc.sni:
parts.append(["Server Name Indication", cc.sni])
text.extend( text.extend(
common.format_keyvals(parts, key="key", val="text", indent=4) common.format_keyvals(parts, key="key", val="text", indent=4)

View File

@ -132,6 +132,7 @@ def tclient_conn():
timestamp_start=1, timestamp_start=1,
timestamp_ssl_setup=2, timestamp_ssl_setup=2,
timestamp_end=3, timestamp_end=3,
sni="address",
)) ))
c.reply = controller.DummyReply() c.reply = controller.DummyReply()
return c return c