mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +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):
|
def configure(self, options, updated):
|
||||||
# We're already streaming - stop the previous stream and restart
|
# We're already streaming - stop the previous stream and restart
|
||||||
if "filtstr" in updated:
|
if "streamfile_filter" in updated:
|
||||||
if options.filtstr:
|
if options.streamfile_filter:
|
||||||
self.filt = flowfilter.parse(options.filtstr)
|
self.filt = flowfilter.parse(options.streamfile_filter)
|
||||||
if not self.filt:
|
if not self.filt:
|
||||||
raise exceptions.OptionsError(
|
raise exceptions.OptionsError(
|
||||||
"Invalid filter specification: %s" % options.filtstr
|
"Invalid filter specification: %s" % options.streamfile_filter
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.filt = None
|
self.filt = None
|
||||||
|
@ -160,6 +160,10 @@ class Options(optmanager.OptManager):
|
|||||||
"streamfile", Optional[str], None,
|
"streamfile", Optional[str], None,
|
||||||
"Write flows to file. Prefix path with + to append."
|
"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(
|
self.add_option(
|
||||||
"server_replay_ignore_content", bool, False,
|
"server_replay_ignore_content", bool, False,
|
||||||
"Ignore request's content while searching for a saved flow to replay."
|
"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):
|
with pytest.raises(exceptions.OptionsError):
|
||||||
tctx.configure(sa, streamfile=str(tmpdir))
|
tctx.configure(sa, streamfile=str(tmpdir))
|
||||||
with pytest.raises(Exception, match="Invalid filter"):
|
with pytest.raises(Exception, match="Invalid filter"):
|
||||||
tctx.configure(sa, streamfile=str(tmpdir.join("foo")), filtstr="~~")
|
tctx.configure(
|
||||||
tctx.configure(sa, filtstr="foo")
|
sa, streamfile=str(tmpdir.join("foo")), streamfile_filter="~~"
|
||||||
|
)
|
||||||
|
tctx.configure(sa, streamfile_filter="foo")
|
||||||
assert sa.filt
|
assert sa.filt
|
||||||
tctx.configure(sa, filtstr=None)
|
tctx.configure(sa, streamfile_filter=None)
|
||||||
assert not sa.filt
|
assert not sa.filt
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user