diff --git a/mitmproxy/addons/clientplayback.py b/mitmproxy/addons/clientplayback.py index 27f6ae280..fc913c23e 100644 --- a/mitmproxy/addons/clientplayback.py +++ b/mitmproxy/addons/clientplayback.py @@ -110,7 +110,7 @@ class RequestReplayThread(basethread.BaseThread): f.error = flow.Error(str(e)) self.channel.ask("error", f) except exceptions.Kill: - self.channel.tell("log", log.LogEntry("Connection killed", "info")) + self.channel.tell("log", log.LogEntry(flow.Error.KILLED_MESSAGE, "info")) except Exception as e: self.channel.tell("log", log.LogEntry(repr(e), "error")) finally: diff --git a/mitmproxy/flow.py b/mitmproxy/flow.py index 7044ac6c6..21ce0eac3 100644 --- a/mitmproxy/flow.py +++ b/mitmproxy/flow.py @@ -9,7 +9,6 @@ from mitmproxy import version class Error(stateobject.StateObject): - """ An Error. @@ -24,6 +23,8 @@ class Error(stateobject.StateObject): timestamp: Seconds since the epoch """ + KILLED_MESSAGE = "Connection killed." + def __init__(self, msg: str, timestamp=None) -> None: """ @type msg: str @@ -156,7 +157,7 @@ class Flow(stateobject.StateObject): """ Kill this request. """ - self.error = Error("Connection killed") + self.error = Error(Error.KILLED_MESSAGE) self.intercepted = False self.reply.kill(force=True) self.live = False diff --git a/mitmproxy/proxy/protocol/http2.py b/mitmproxy/proxy/protocol/http2.py index 71c30b322..2f2197e1d 100644 --- a/mitmproxy/proxy/protocol/http2.py +++ b/mitmproxy/proxy/protocol/http2.py @@ -8,7 +8,7 @@ from h2 import connection from h2 import events import queue -from mitmproxy import connections # noqa +from mitmproxy import connections, flow # noqa from mitmproxy import exceptions from mitmproxy import http from mitmproxy.proxy.protocol import base @@ -725,6 +725,6 @@ class Http2SingleStreamLayer(httpbase._HttpTransmissionLayer, basethread.BaseThr except exceptions.SetServerNotAllowedException as e: # pragma: no cover self.log("Changing the Host server for HTTP/2 connections not allowed: {}".format(e), "info") except exceptions.Kill: # pragma: no cover - self.log("Connection killed", "info") + self.log(flow.Error.KILLED_MESSAGE, "info") self.kill() diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index 3688b677e..2a534d470 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -1,7 +1,7 @@ import sys import traceback -from mitmproxy import exceptions +from mitmproxy import exceptions, flow from mitmproxy import connections from mitmproxy import controller # noqa from mitmproxy import http @@ -120,7 +120,7 @@ class ConnectionHandler: root_layer = self.channel.ask("clientconnect", root_layer) root_layer() except exceptions.Kill: - self.log("Connection killed", "info") + self.log(flow.Error.KILLED_MESSAGE, "info") except exceptions.ProtocolException as e: if isinstance(e, exceptions.ClientHandshakeException): self.log( diff --git a/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js b/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js index f3373c029..3622f3c1e 100644 --- a/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js +++ b/web/src/js/__tests__/components/FlowTable/FlowColumnsSpec.js @@ -69,7 +69,7 @@ describe('FlowColumns Components', () => { tree = pathColumn.toJSON() expect(tree).toMatchSnapshot() - tflow.error.msg = 'Connection killed' + tflow.error.msg = 'Connection killed.' tflow.intercepted = true pathColumn = renderer.create() tree = pathColumn.toJSON() diff --git a/web/src/js/components/FlowTable/FlowColumns.jsx b/web/src/js/components/FlowTable/FlowColumns.jsx index 64b8ac829..7a4e112d6 100644 --- a/web/src/js/components/FlowTable/FlowColumns.jsx +++ b/web/src/js/components/FlowTable/FlowColumns.jsx @@ -57,7 +57,7 @@ export function PathColumn({ flow }) { let err; if(flow.error){ - if (flow.error.msg === "Connection killed"){ + if (flow.error.msg === "Connection killed."){ err = } else { err =