aboutsummaryrefslogtreecommitdiffstats
path: root/examples/filt.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-02-18 09:19:05 +1300
committerAldo Cortesi <aldo@nullcube.com>2016-02-18 09:27:08 +1300
commit92597f82ea8e4747ce1836ecd5eb2479486e8647 (patch)
tree2aa391b558d92c0122a16c155d3375d31221cde4 /examples/filt.py
parent49464de1cb159361c16a232b3d8c267b36e95483 (diff)
downloadmitmproxy-92597f82ea8e4747ce1836ecd5eb2479486e8647.tar.gz
mitmproxy-92597f82ea8e4747ce1836ecd5eb2479486e8647.tar.bz2
mitmproxy-92597f82ea8e4747ce1836ecd5eb2479486e8647.zip
Docs and examples to top level
Diffstat (limited to 'examples/filt.py')
-rw-r--r--examples/filt.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/filt.py b/examples/filt.py
new file mode 100644
index 00000000..f99b675c
--- /dev/null
+++ b/examples/filt.py
@@ -0,0 +1,16 @@
+# This scripts demonstrates how to use mitmproxy's filter pattern in inline scripts.
+# Usage: mitmdump -s "filt.py FILTER"
+
+from mitmproxy import filt
+
+
+def start(context, argv):
+ if len(argv) != 2:
+ raise ValueError("Usage: -s 'filt.py FILTER'")
+ context.filter = filt.parse(argv[1])
+
+
+def response(context, flow):
+ if flow.match(context.filter):
+ print("Flow matches filter:")
+ print(flow)