diff options
| author | Aldo Cortesi <aldo@corte.si> | 2017-04-27 07:40:14 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-27 07:40:14 +1200 |
| commit | 2a46f3851a468263b53298b643f92a36b713128e (patch) | |
| tree | b4b9495d84a16245182ed93f427dbaa276f3c7c5 /examples/simple | |
| parent | ab07b79138a79fd7b09a3d4d0b8da8ab07c342d8 (diff) | |
| parent | 5327756377d239f059e84de4063cfcaa592fdb3d (diff) | |
| download | mitmproxy-2a46f3851a468263b53298b643f92a36b713128e.tar.gz mitmproxy-2a46f3851a468263b53298b643f92a36b713128e.tar.bz2 mitmproxy-2a46f3851a468263b53298b643f92a36b713128e.zip | |
Merge pull request #2265 from cortesi/addons
Addons and addon testing
Diffstat (limited to 'examples/simple')
| -rw-r--r-- | examples/simple/filter_flows.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/simple/filter_flows.py b/examples/simple/filter_flows.py index 896fa54a..fd49425a 100644 --- a/examples/simple/filter_flows.py +++ b/examples/simple/filter_flows.py @@ -1,15 +1,21 @@ """ This scripts demonstrates how to use mitmproxy's filter pattern in scripts. -Usage: - mitmdump -s "flowfilter.py FILTER" """ -import sys from mitmproxy import flowfilter +from mitmproxy import ctx class Filter: - def __init__(self, spec): - self.filter = flowfilter.parse(spec) + def __init__(self): + self.filter = None + + def configure(self, updated): + self.filter = flowfilter.parse(ctx.options.flowfilter) + + def load(self, l): + l.add_option( + "flowfilter", str, "", "Check that flow matches filter." + ) def response(self, flow): if flowfilter.match(self.filter, flow): @@ -17,4 +23,4 @@ class Filter: print(flow) -addons = [Filter(sys.argv[1])] +addons = [Filter()] |
