aboutsummaryrefslogtreecommitdiffstats
path: root/examples/filt.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-04-08 12:00:17 +1200
committerAldo Cortesi <aldo@nullcube.com>2015-04-08 12:00:17 +1200
commitb1d2da19f952ee677ec9c86d13ac2f28db824275 (patch)
treea0f918f377226535791fa092631c494f6611642e /examples/filt.py
parentfb0a5d8f6383e689ccfbb498b0b3501dbdf712e2 (diff)
parent0aa2fca25aa5511c89653d876a39eec6e812e184 (diff)
downloadmitmproxy-b1d2da19f952ee677ec9c86d13ac2f28db824275.tar.gz
mitmproxy-b1d2da19f952ee677ec9c86d13ac2f28db824275.tar.bz2
mitmproxy-b1d2da19f952ee677ec9c86d13ac2f28db824275.zip
Merge branch 'master' of ssh.github.com:mitmproxy/mitmproxy
Diffstat (limited to 'examples/filt.py')
-rw-r--r--examples/filt.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/filt.py b/examples/filt.py
new file mode 100644
index 00000000..dc241046
--- /dev/null
+++ b/examples/filt.py
@@ -0,0 +1,15 @@
+# This scripts demonstrates how to use mitmproxy's filter pattern in inline scripts.
+# Usage: mitmdump -s "filt.py FILTER"
+
+from libmproxy import filt
+
+def start(context, argv):
+ print 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) \ No newline at end of file