diff options
author | Aldo Cortesi <aldo@corte.si> | 2017-03-19 13:08:26 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2017-03-19 13:08:26 +1300 |
commit | 475a4e3eb03e2a704f078e1bb7f11fd199b0bb52 (patch) | |
tree | 6f922e156f476637b709c8f1cf97ba0b0063ed6a | |
parent | 6f745b90a836e6eb5e78a670bb94a0125626ff20 (diff) | |
download | mitmproxy-475a4e3eb03e2a704f078e1bb7f11fd199b0bb52.tar.gz mitmproxy-475a4e3eb03e2a704f078e1bb7f11fd199b0bb52.tar.bz2 mitmproxy-475a4e3eb03e2a704f078e1bb7f11fd199b0bb52.zip |
streamfile: add streamfile_filter and use it instead of filtstr
-rw-r--r-- | mitmproxy/addons/streamfile.py | 8 | ||||
-rw-r--r-- | mitmproxy/options.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_streamfile.py | 8 |
3 files changed, 13 insertions, 7 deletions
diff --git a/mitmproxy/addons/streamfile.py b/mitmproxy/addons/streamfile.py index 624297f2..183d2036 100644 --- a/mitmproxy/addons/streamfile.py +++ b/mitmproxy/addons/streamfile.py @@ -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 diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 31d0b693..9acdbc29 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -161,6 +161,10 @@ class Options(optmanager.OptManager): "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." ) diff --git a/test/mitmproxy/addons/test_streamfile.py b/test/mitmproxy/addons/test_streamfile.py index 3f78521c..bcb27c79 100644 --- a/test/mitmproxy/addons/test_streamfile.py +++ b/test/mitmproxy/addons/test_streamfile.py @@ -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 |