mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-02 00:05:27 +00:00
flow_detail option to /addons/dumper
This commit is contained in:
parent
4fe83be63c
commit
93c49c47ae
@ -31,6 +31,18 @@ class Dumper:
|
||||
self.filter = None # type: flowfilter.TFilter
|
||||
self.outfp = outfile # type: typing.io.TextIO
|
||||
|
||||
def load(self, loader):
|
||||
loader.add_option(
|
||||
"flow_detail", int, 1,
|
||||
"""
|
||||
The display detail level for flows in mitmdump: 0 (almost quiet) to 3 (very verbose).
|
||||
0: shortened request URL, response status code, WebSocket and TCP message notifications.
|
||||
1: full request URL with response status code
|
||||
2: 1 + HTTP headers
|
||||
3: 2 + full response content, content of WebSocket and TCP messages.
|
||||
"""
|
||||
)
|
||||
|
||||
def configure(self, updated):
|
||||
if "view_filter" in updated:
|
||||
if ctx.options.view_filter:
|
||||
|
@ -58,7 +58,6 @@ class Options(optmanager.OptManager):
|
||||
# because they're used by more than one addon, or because they're
|
||||
# embedded in the core code somehow.
|
||||
default_contentview = None # type: str
|
||||
flow_detail = None # type: int
|
||||
intercept = None # type: Optional[str]
|
||||
intercept_active = None # type: bool
|
||||
proxyauth = None # type: Optional[str]
|
||||
@ -267,16 +266,4 @@ class Options(optmanager.OptManager):
|
||||
"Limit which flows are displayed."
|
||||
)
|
||||
|
||||
# Dump options
|
||||
self.add_option(
|
||||
"flow_detail", int, 1,
|
||||
"""
|
||||
The display detail level for flows in mitmdump: 0 (almost quiet) to 3 (very verbose).
|
||||
0: shortened request URL, response status code, WebSocket and TCP message notifications.
|
||||
1: full request URL with response status code
|
||||
2: 1 + HTTP headers
|
||||
3: 2 + full response content, content of WebSocket and TCP messages.
|
||||
"""
|
||||
)
|
||||
|
||||
self.update(**kwargs)
|
||||
|
@ -14,7 +14,7 @@ from mitmproxy import http
|
||||
|
||||
def test_configure():
|
||||
d = dumper.Dumper()
|
||||
with taddons.context() as ctx:
|
||||
with taddons.context(d) as ctx:
|
||||
ctx.configure(d, view_filter="~b foo")
|
||||
assert d.filter
|
||||
|
||||
@ -33,7 +33,7 @@ def test_configure():
|
||||
def test_simple():
|
||||
sio = io.StringIO()
|
||||
d = dumper.Dumper(sio)
|
||||
with taddons.context() as ctx:
|
||||
with taddons.context(d) as ctx:
|
||||
ctx.configure(d, flow_detail=0)
|
||||
d.response(tflow.tflow(resp=True))
|
||||
assert not sio.getvalue()
|
||||
@ -101,7 +101,7 @@ def test_echo_body():
|
||||
|
||||
sio = io.StringIO()
|
||||
d = dumper.Dumper(sio)
|
||||
with taddons.context() as ctx:
|
||||
with taddons.context(d) as ctx:
|
||||
ctx.configure(d, flow_detail=3)
|
||||
d._echo_message(f.response)
|
||||
t = sio.getvalue()
|
||||
@ -111,7 +111,7 @@ def test_echo_body():
|
||||
def test_echo_request_line():
|
||||
sio = io.StringIO()
|
||||
d = dumper.Dumper(sio)
|
||||
with taddons.context() as ctx:
|
||||
with taddons.context(d) as ctx:
|
||||
ctx.configure(d, flow_detail=3, showhost=True)
|
||||
f = tflow.tflow(client_conn=None, server_conn=True, resp=True)
|
||||
f.request.is_replay = True
|
||||
@ -146,7 +146,7 @@ class TestContentView:
|
||||
view_auto.side_effect = exceptions.ContentViewException("")
|
||||
sio = io.StringIO()
|
||||
d = dumper.Dumper(sio)
|
||||
with taddons.context() as ctx:
|
||||
with taddons.context(d) as ctx:
|
||||
ctx.configure(d, flow_detail=4, verbosity='debug')
|
||||
d.response(tflow.tflow())
|
||||
assert ctx.master.has_log("content viewer failed")
|
||||
@ -155,7 +155,7 @@ class TestContentView:
|
||||
def test_tcp():
|
||||
sio = io.StringIO()
|
||||
d = dumper.Dumper(sio)
|
||||
with taddons.context() as ctx:
|
||||
with taddons.context(d) as ctx:
|
||||
ctx.configure(d, flow_detail=3, showhost=True)
|
||||
f = tflow.ttcpflow()
|
||||
d.tcp_message(f)
|
||||
@ -170,7 +170,7 @@ def test_tcp():
|
||||
def test_websocket():
|
||||
sio = io.StringIO()
|
||||
d = dumper.Dumper(sio)
|
||||
with taddons.context() as ctx:
|
||||
with taddons.context(d) as ctx:
|
||||
ctx.configure(d, flow_detail=3, showhost=True)
|
||||
f = tflow.twebsocketflow()
|
||||
d.websocket_message(f)
|
||||
|
@ -11,7 +11,7 @@ from .. import tservers
|
||||
|
||||
class TestDumpMaster(tservers.MasterTest):
|
||||
def mkmaster(self, flt, **opts):
|
||||
o = options.Options(view_filter=flt, verbosity='error', flow_detail=0, **opts)
|
||||
o = options.Options(view_filter=flt, verbosity='error', **opts)
|
||||
m = dump.DumpMaster(o, with_termlog=False, with_dumper=False)
|
||||
return m
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user