aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-03-04 23:07:04 +0100
committerMaximilian Hils <git@maximilianhils.com>2015-03-04 23:07:04 +0100
commit4c95c68041a9647211c159939787eedd3ed542ed (patch)
tree614bf2d9ac735d275d227ed26e6698088f5aece0
parentf45f3dd4f1e0f494c59a1af9e35a9ce38ff83ed2 (diff)
parent8f7ba4ab45ea44a46353451c053e351324faa8d2 (diff)
downloadmitmproxy-4c95c68041a9647211c159939787eedd3ed542ed.tar.gz
mitmproxy-4c95c68041a9647211c159939787eedd3ed542ed.tar.bz2
mitmproxy-4c95c68041a9647211c159939787eedd3ed542ed.zip
Merge branch 'master' of github.com:mitmproxy/mitmproxy
-rw-r--r--libmproxy/console/flowdetailview.py38
-rw-r--r--libmproxy/utils.py13
-rw-r--r--test/test_utils.py2
3 files changed, 40 insertions, 13 deletions
diff --git a/libmproxy/console/flowdetailview.py b/libmproxy/console/flowdetailview.py
index 51ae8da6..4164c416 100644
--- a/libmproxy/console/flowdetailview.py
+++ b/libmproxy/console/flowdetailview.py
@@ -35,17 +35,20 @@ class FlowDetailsView(urwid.ListBox):
title = urwid.AttrWrap(title, "heading")
text.append(title)
- if self.flow.server_conn:
+ cc = self.flow.client_conn
+ sc = self.flow.server_conn
+ req = self.flow.request
+ resp = self.flow.response
+
+ if sc:
text.append(urwid.Text([("head", "Server Connection:")]))
- sc = self.flow.server_conn
parts = [
["Address", "%s:%s" % sc.address()],
- ["Start time", utils.format_timestamp(sc.timestamp_start)],
- ["End time", utils.format_timestamp(sc.timestamp_end) if sc.timestamp_end else "active"],
]
+
text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))
- c = self.flow.server_conn.cert
+ c = sc.cert
if c:
text.append(urwid.Text([("head", "Server Certificate:")]))
parts = [
@@ -79,15 +82,32 @@ class FlowDetailsView(urwid.ListBox):
)
text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))
- if self.flow.client_conn:
+ if cc:
text.append(urwid.Text([("head", "Client Connection:")]))
- cc = self.flow.client_conn
+
parts = [
["Address", "%s:%s" % cc.address()],
- ["Start time", utils.format_timestamp(cc.timestamp_start)],
# ["Requests", "%s"%cc.requestcount],
- ["End time", utils.format_timestamp(cc.timestamp_end) if cc.timestamp_end else "active"],
]
+
text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))
+ parts = []
+
+ parts.append(["Client conn. established", utils.format_timestamp_with_milli(cc.timestamp_start) if (cc and cc.timestamp_start) else "active"])
+ parts.append(["Server conn. initiated", utils.format_timestamp_with_milli(sc.timestamp_start) if sc else "active" ])
+ parts.append(["Server conn. TCP handshake", utils.format_timestamp_with_milli(sc.timestamp_tcp_setup) if (sc and sc.timestamp_tcp_setup) else "active"])
+ if sc.ssl_established:
+ parts.append(["Server conn. SSL handshake", utils.format_timestamp_with_milli(sc.timestamp_ssl_setup) if sc.timestamp_ssl_setup else "active"])
+ parts.append(["Client conn. SSL handshake", utils.format_timestamp_with_milli(cc.timestamp_ssl_setup) if (cc and cc.timestamp_ssl_setup) else "active"])
+ parts.append(["First request byte", utils.format_timestamp_with_milli(req.timestamp_start)])
+ parts.append(["Request complete", utils.format_timestamp_with_milli(req.timestamp_end) if req.timestamp_end else "active"])
+ parts.append(["First response byte", utils.format_timestamp_with_milli(resp.timestamp_start) if resp else "active"])
+ parts.append(["Response complete", utils.format_timestamp_with_milli(resp.timestamp_end) if (resp and resp.timestamp_end) else "active"])
+
+ # sort operations by timestamp
+ parts = sorted(parts, key=lambda p: p[1])
+
+ text.append(urwid.Text([("head", "Timing:")]))
+ text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))
return text
diff --git a/libmproxy/utils.py b/libmproxy/utils.py
index 76e99c34..51f2dc26 100644
--- a/libmproxy/utils.py
+++ b/libmproxy/utils.py
@@ -16,6 +16,11 @@ def format_timestamp(s):
return d.strftime("%Y-%m-%d %H:%M:%S")
+def format_timestamp_with_milli(s):
+ d = datetime.datetime.fromtimestamp(s)
+ return d.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
+
+
def isBin(s):
"""
Does this string have any non-ASCII characters?
@@ -81,15 +86,15 @@ def pretty_size(size):
def pretty_duration(secs):
formatters = [
- (100, "{:.0f}s"),
- (10, "{:2.1f}s"),
- (1, "{:1.2f}s"),
+ (100, "{:.0f}s"),
+ (10, "{:2.1f}s"),
+ (1, "{:1.2f}s"),
]
for limit, formatter in formatters:
if secs >= limit:
return formatter.format(secs)
- #less than 1 sec
+ #less than 1 sec
return "{:.0f}ms".format(secs*1000)
class Data:
diff --git a/test/test_utils.py b/test/test_utils.py
index 45bfb4f7..78d1c072 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -8,6 +8,8 @@ utils.CERT_SLEEP_TIME = 0
def test_format_timestamp():
assert utils.format_timestamp(utils.timestamp())
+def test_format_timestamp_with_milli():
+ assert utils.format_timestamp_with_milli(utils.timestamp())
def test_isBin():
assert not utils.isBin("testing\n\r")