aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2017-04-26 11:45:15 +1200
committerAldo Cortesi <aldo@nullcube.com>2017-04-26 19:56:33 +1200
commit5327756377d239f059e84de4063cfcaa592fdb3d (patch)
tree9c8de935d8e627621c98d4daf39ac25e895905e0 /examples/simple
parente32efcae49ba5857feae85b9b4651a45d9e5fcc3 (diff)
downloadmitmproxy-5327756377d239f059e84de4063cfcaa592fdb3d.tar.gz
mitmproxy-5327756377d239f059e84de4063cfcaa592fdb3d.tar.bz2
mitmproxy-5327756377d239f059e84de4063cfcaa592fdb3d.zip
Addons and addon testing
- Fix some loading sequence bugs affecting command-line script invocation - Allow addons to over-ride existing options (with a warning). We need this for reloading. - Convert har_dump to new-style arguments, fix and re-instate its test suite. - Covnert miscelaneous other exmples to new-style args.
Diffstat (limited to 'examples/simple')
-rw-r--r--examples/simple/filter_flows.py18
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()]