mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
streamfile: add streamfile_filter and use it instead of filtstr
This commit is contained in:
parent
6f745b90a8
commit
475a4e3eb0
@ -22,12 +22,12 @@ class StreamFile:
|
||||
|
||||
def configure(self, options, updated):
|
||||
# We're already streaming - stop the previous stream and restart
|
||||
if "filtstr" in updated:
|
||||
if options.filtstr:
|
||||
self.filt = flowfilter.parse(options.filtstr)
|
||||
if "streamfile_filter" in updated:
|
||||
if options.streamfile_filter:
|
||||
self.filt = flowfilter.parse(options.streamfile_filter)
|
||||
if not self.filt:
|
||||
raise exceptions.OptionsError(
|
||||
"Invalid filter specification: %s" % options.filtstr
|
||||
"Invalid filter specification: %s" % options.streamfile_filter
|
||||
)
|
||||
else:
|
||||
self.filt = None
|
||||
|
@ -160,6 +160,10 @@ class Options(optmanager.OptManager):
|
||||
"streamfile", Optional[str], None,
|
||||
"Write flows to file. Prefix path with + to append."
|
||||
)
|
||||
self.add_option(
|
||||
"streamfile_filter", Optional[str], None,
|
||||
"Filter which flows are written to file."
|
||||
)
|
||||
self.add_option(
|
||||
"server_replay_ignore_content", bool, False,
|
||||
"Ignore request's content while searching for a saved flow to replay."
|
||||
|
@ -15,10 +15,12 @@ def test_configure(tmpdir):
|
||||
with pytest.raises(exceptions.OptionsError):
|
||||
tctx.configure(sa, streamfile=str(tmpdir))
|
||||
with pytest.raises(Exception, match="Invalid filter"):
|
||||
tctx.configure(sa, streamfile=str(tmpdir.join("foo")), filtstr="~~")
|
||||
tctx.configure(sa, filtstr="foo")
|
||||
tctx.configure(
|
||||
sa, streamfile=str(tmpdir.join("foo")), streamfile_filter="~~"
|
||||
)
|
||||
tctx.configure(sa, streamfile_filter="foo")
|
||||
assert sa.filt
|
||||
tctx.configure(sa, filtstr=None)
|
||||
tctx.configure(sa, streamfile_filter=None)
|
||||
assert not sa.filt
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user