mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Merge pull request #1664 from chhsiao90/sni-display-#1639
Resolved #1639: display sni on ClientConnection
This commit is contained in:
commit
145c2892f7
@ -20,6 +20,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
timestamp_start: Connection start timestamp
|
||||
timestamp_ssl_setup: TLS established timestamp
|
||||
timestamp_end: Connection end timestamp
|
||||
sni: Server Name Indication sent by client during the TLS handshake
|
||||
"""
|
||||
|
||||
def __init__(self, client_connection, address, server):
|
||||
@ -40,6 +41,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
self.timestamp_end = None
|
||||
self.timestamp_ssl_setup = None
|
||||
self.protocol = None
|
||||
self.sni = None
|
||||
|
||||
def __bool__(self):
|
||||
return bool(self.connection) and not self.finished
|
||||
@ -61,6 +63,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
timestamp_start=float,
|
||||
timestamp_ssl_setup=float,
|
||||
timestamp_end=float,
|
||||
sni=str,
|
||||
)
|
||||
|
||||
def copy(self):
|
||||
@ -86,12 +89,14 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
ssl_established=False,
|
||||
timestamp_start=None,
|
||||
timestamp_end=None,
|
||||
timestamp_ssl_setup=None
|
||||
timestamp_ssl_setup=None,
|
||||
sni=None
|
||||
))
|
||||
|
||||
def convert_to_ssl(self, *args, **kwargs):
|
||||
super().convert_to_ssl(*args, **kwargs)
|
||||
self.timestamp_ssl_setup = time.time()
|
||||
self.sni = self.connection.get_servername()
|
||||
|
||||
def finish(self):
|
||||
super().finish()
|
||||
|
@ -66,6 +66,7 @@ def convert_017_018(data):
|
||||
|
||||
def convert_018_019(data):
|
||||
data["version"] = (0, 19)
|
||||
data["client_conn"]["sni"] = None
|
||||
return data
|
||||
|
||||
|
||||
|
@ -82,6 +82,8 @@ def flowdetails(state, flow):
|
||||
parts = [
|
||||
["Address", repr(cc.address)],
|
||||
]
|
||||
if cc.sni:
|
||||
parts.append(["Server Name Indication", cc.sni])
|
||||
|
||||
text.extend(
|
||||
common.format_keyvals(parts, key="key", val="text", indent=4)
|
||||
|
@ -132,6 +132,7 @@ def tclient_conn():
|
||||
timestamp_start=1,
|
||||
timestamp_ssl_setup=2,
|
||||
timestamp_end=3,
|
||||
sni="address",
|
||||
))
|
||||
c.reply = controller.DummyReply()
|
||||
return c
|
||||
|
Loading…
Reference in New Issue
Block a user