Merge pull request #4137 from mhils/killed

Standardize killed error message
This commit is contained in:
Maximilian Hils 2020-08-08 00:19:43 +02:00 committed by GitHub
commit 218e69ddb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 9 deletions

View File

@ -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:

View File

@ -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

View File

@ -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()

View File

@ -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(

View File

@ -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()

View File

@ -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>