mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Split dumper_filter off from view_filter
These don't even do the same thing.
This commit is contained in:
parent
2fb85553cc
commit
e5cdc20eb8
@ -47,14 +47,18 @@ class Dumper:
|
||||
"The default content view mode.",
|
||||
choices = [i.name.lower() for i in contentviews.views]
|
||||
)
|
||||
loader.add_option(
|
||||
"dumper_filter", typing.Optional[str], None,
|
||||
"Limit which flows are dumped."
|
||||
)
|
||||
|
||||
def configure(self, updated):
|
||||
if "view_filter" in updated:
|
||||
if ctx.options.view_filter:
|
||||
self.filter = flowfilter.parse(ctx.options.view_filter)
|
||||
if "dumper_filter" in updated:
|
||||
if ctx.options.dumper_filter:
|
||||
self.filter = flowfilter.parse(ctx.options.dumper_filter)
|
||||
if not self.filter:
|
||||
raise exceptions.OptionsError(
|
||||
"Invalid filter expression: %s" % ctx.options.view_filter
|
||||
"Invalid filter expression: %s" % ctx.options.dumper_filter
|
||||
)
|
||||
else:
|
||||
self.filter = None
|
||||
|
@ -146,6 +146,10 @@ class View(collections.Sequence):
|
||||
self.settings = Settings(self)
|
||||
|
||||
def load(self, loader):
|
||||
loader.add_option(
|
||||
"view_filter", typing.Optional[str], None,
|
||||
"Limit the view to matching flows."
|
||||
)
|
||||
loader.add_option(
|
||||
"view_order", str, "time",
|
||||
"Flow sort order.",
|
||||
|
@ -41,11 +41,6 @@ class Options(optmanager.OptManager):
|
||||
upstream_cert = None # type: bool
|
||||
websocket = None # type: bool
|
||||
|
||||
# FIXME: Options that must be migrated to addons, but are complicated
|
||||
# because they're used by more than one addon, or because they're
|
||||
# embedded in the core code somehow.
|
||||
view_filter = None # type: Optional[str]
|
||||
|
||||
def __init__(self, **kwargs) -> None:
|
||||
super().__init__()
|
||||
self.add_option(
|
||||
@ -212,9 +207,4 @@ class Options(optmanager.OptManager):
|
||||
"""
|
||||
)
|
||||
|
||||
self.add_option(
|
||||
"view_filter", Optional[str], None,
|
||||
"Limit which flows are displayed."
|
||||
)
|
||||
|
||||
self.update(**kwargs)
|
||||
|
@ -15,7 +15,7 @@ from mitmproxy import http
|
||||
def test_configure():
|
||||
d = dumper.Dumper()
|
||||
with taddons.context(d) as ctx:
|
||||
ctx.configure(d, view_filter="~b foo")
|
||||
ctx.configure(d, dumper_filter="~b foo")
|
||||
assert d.filter
|
||||
|
||||
f = tflow.tflow(resp=True)
|
||||
@ -23,10 +23,10 @@ def test_configure():
|
||||
f.response.content = b"foo"
|
||||
assert d.match(f)
|
||||
|
||||
ctx.configure(d, view_filter=None)
|
||||
ctx.configure(d, dumper_filter=None)
|
||||
assert not d.filter
|
||||
with pytest.raises(exceptions.OptionsError):
|
||||
ctx.configure(d, view_filter="~~")
|
||||
ctx.configure(d, dumper_filter="~~")
|
||||
assert not d.filter
|
||||
|
||||
|
||||
|
@ -10,13 +10,13 @@ from .. import tservers
|
||||
|
||||
|
||||
class TestDumpMaster(tservers.MasterTest):
|
||||
def mkmaster(self, flt, **opts):
|
||||
o = options.Options(view_filter=flt, **opts)
|
||||
def mkmaster(self, **opts):
|
||||
o = options.Options(**opts)
|
||||
m = dump.DumpMaster(o, with_termlog=False, with_dumper=False)
|
||||
return m
|
||||
|
||||
def test_has_error(self):
|
||||
m = self.mkmaster(None)
|
||||
m = self.mkmaster()
|
||||
ent = log.LogEntry("foo", "error")
|
||||
ent.reply = controller.DummyReply()
|
||||
m.addons.trigger("log", ent)
|
||||
|
Loading…
Reference in New Issue
Block a user