aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-03-31 09:49:07 +1300
committerAldo Cortesi <aldo@nullcube.com>2015-03-31 09:49:07 +1300
commit82997cb31173f9a82555ff7d5eb7ef9746256329 (patch)
tree27700fc9e999c5c2e598e2af867f37599b801ede /libmproxy
parent5977e844e7b78e0f58f80c3c8e0bbcf2d678d53a (diff)
downloadmitmproxy-82997cb31173f9a82555ff7d5eb7ef9746256329.tar.gz
mitmproxy-82997cb31173f9a82555ff7d5eb7ef9746256329.tar.bz2
mitmproxy-82997cb31173f9a82555ff7d5eb7ef9746256329.zip
Fix timestamps in detail view
- Fix a crash when connection timestamps don't exist yet - Fix display of response timestamps - Get rid of those colossal ternaries. I want a device that pokes people in the eye every time they try to use a ternary operator.
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/console/flowdetailview.py74
1 files changed, 64 insertions, 10 deletions
diff --git a/libmproxy/console/flowdetailview.py b/libmproxy/console/flowdetailview.py
index 99f2a262..48845a62 100644
--- a/libmproxy/console/flowdetailview.py
+++ b/libmproxy/console/flowdetailview.py
@@ -1,8 +1,17 @@
from __future__ import absolute_import
import urwid
-from . import common, signals, searchable
+from . import common, searchable
from .. import utils
+
+def maybe_timestamp(base, attr):
+ if base and getattr(base, attr):
+ return utils.format_timestamp_with_milli(getattr(base, attr))
+ else:
+ return "active"
+ pass
+
+
def flowdetails(state, flow):
text = []
@@ -81,16 +90,61 @@ def flowdetails(state, flow):
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"])
+ parts.append(
+ [
+ "Client conn. established",
+ maybe_timestamp(cc, "timestamp_start")
+ ]
+ )
+ parts.append(
+ [
+ "Server conn. initiated",
+ maybe_timestamp(sc, "timestamp_start")
+ ]
+ )
+ parts.append(
+ [
+ "Server conn. TCP handshake",
+ maybe_timestamp(sc, "timestamp_tcp_setup")
+ ]
+ )
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"])
+ parts.append(
+ [
+ "Server conn. SSL handshake",
+ maybe_timestamp(sc, "timestamp_ssl_setup")
+ ]
+ )
+ parts.append(
+ [
+ "Client conn. SSL handshake",
+ maybe_timestamp(cc, "timestamp_ssl_setup")
+ ]
+ )
+ parts.append(
+ [
+ "First request byte",
+ maybe_timestamp(req, "timestamp_start")
+ ]
+ )
+ parts.append(
+ [
+ "Request complete",
+ maybe_timestamp(req, "timestamp_end")
+ ]
+ )
+ parts.append(
+ [
+ "First response byte",
+ maybe_timestamp(resp, "timestamp_start")
+ ]
+ )
+ parts.append(
+ [
+ "Response complete",
+ maybe_timestamp(resp, "timestamp_end")
+ ]
+ )
# sort operations by timestamp
parts = sorted(parts, key=lambda p: p[1])