Skip to content

Commit

Permalink
Merge pull request mitmproxy#4137 from mhils/killed
Browse files Browse the repository at this point in the history
Standardize killed error message
  • Loading branch information
mhils authored Aug 7, 2020
2 parents b6ca9a6 + 9d5e59b commit 218e69d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mitmproxy/addons/clientplayback.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def replay(self, f): # pragma: no cover
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:
Expand Down
5 changes: 3 additions & 2 deletions mitmproxy/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


class Error(stateobject.StateObject):

"""
An Error.
Expand All @@ -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
Expand Down Expand Up @@ -156,7 +157,7 @@ def kill(self):
"""
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
Expand Down
4 changes: 2 additions & 2 deletions mitmproxy/proxy/protocol/http2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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
Expand Down Expand Up @@ -725,6 +725,6 @@ def run(self):
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()
4 changes: 2 additions & 2 deletions mitmproxy/proxy/server.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -120,7 +120,7 @@ def handle(self):
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(<Columns.PathColumn flow={tflow}/>)
tree = pathColumn.toJSON()
Expand Down
2 changes: 1 addition & 1 deletion web/src/js/components/FlowTable/FlowColumns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <i className="fa fa-fw fa-times pull-right"></i>
} else {
err = <i className="fa fa-fw fa-exclamation pull-right"></i>
Expand Down

0 comments on commit 218e69d

Please sign in to comment.