diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py index a0c952418..472670f03 100644 --- a/mitmproxy/addons/view.py +++ b/mitmproxy/addons/view.py @@ -23,7 +23,7 @@ from mitmproxy import ctx from mitmproxy import io from mitmproxy import http from mitmproxy import tcp -from mitmproxy.utils import human +from mitmproxy.utils import compat, human # The underlying sorted list implementation expects the sort key to be stable @@ -460,8 +460,12 @@ class View(collections.abc.Sequence): req = http.HTTPRequest.make(method.upper(), url) except ValueError as e: raise exceptions.CommandError("Invalid URL: %s" % e) - c = connections.ClientConnection.make_dummy(("", 0)) - s = connections.ServerConnection.make_dummy((req.host, req.port)) + if compat.new_proxy_core: # pragma: no cover + c = compat.Client(("", 0), ("", 0), req.timestamp_start - 0.0001) + s = compat.Server((req.host, req.port)) + else: # pragma: no cover + c = connections.ClientConnection.make_dummy(("", 0)) + s = connections.ServerConnection.make_dummy((req.host, req.port)) f = http.HTTPFlow(c, s) f.request = req f.request.headers["Host"] = req.host diff --git a/mitmproxy/tools/console/flowdetailview.py b/mitmproxy/tools/console/flowdetailview.py index fb2494e8b..d89078010 100644 --- a/mitmproxy/tools/console/flowdetailview.py +++ b/mitmproxy/tools/console/flowdetailview.py @@ -12,7 +12,12 @@ def maybe_timestamp(base, attr): if base is not None and getattr(base, attr): return human.format_timestamp_with_milli(getattr(base, attr)) else: - return "active" + # in mitmdump we serialize before a connection is closed. + # loading those flows at a later point shouldn't display "active". + # We also use a ndash (and not a regular dash) so that it is sorted + # after other timestamps. We may need to revisit that in the future if it turns out + # to render ugly in consoles. + return "–" def flowdetails(state, flow: mitmproxy.flow.Flow):