From 74aff39b28fe368c94f473c7972feaa75683a18a Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 8 Apr 2015 00:21:49 +0200 Subject: add example which uses filt --- examples/filt.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/filt.py (limited to 'examples/filt.py') 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 -- cgit v1.2.3 From bea0bd236a60e3e6c80027448e51b7802394304a Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 14 Apr 2015 11:58:10 +1200 Subject: Housekeeping and cleanups - No output to stdout on load in examples - they muck up the test suite. - Use the odict module directly, rather than aliasing it. The small convenience this gives to scripters is not worth it. - Move the cookie tests from the flow test module to the protocol_http test module. --- examples/filt.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'examples/filt.py') diff --git a/examples/filt.py b/examples/filt.py index dc241046..cce2a48a 100644 --- a/examples/filt.py +++ b/examples/filt.py @@ -4,7 +4,6 @@ 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]) @@ -12,4 +11,4 @@ def start(context, argv): def response(context, flow): if flow.match(context.filter): print("Flow matches filter:") - print(flow) \ No newline at end of file + print(flow) -- cgit v1.2.3 From a05a70d8168a07c92b2a3ecbbb1958d85532efe3 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 30 May 2015 12:03:28 +1200 Subject: Add coding style check, reformat. --- examples/filt.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'examples/filt.py') diff --git a/examples/filt.py b/examples/filt.py index cce2a48a..d2daf9a2 100644 --- a/examples/filt.py +++ b/examples/filt.py @@ -3,12 +3,14 @@ from libmproxy import filt + def start(context, argv): - if len(argv) != 2: - raise ValueError("Usage: -s 'filt.py FILTER'") - context.filter = filt.parse(argv[1]) + 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) + if flow.match(context.filter): + print("Flow matches filter:") + print(flow) -- cgit v1.2.3