diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-04-14 12:01:37 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-04-14 12:01:37 +1200 |
commit | 937a358aa9396d5a5c18bc69e89e11af5dad40a5 (patch) | |
tree | 1d52a64527f93aeb5299d59e502ab792a052f7a2 /examples/flowwriter.py | |
parent | bea0bd236a60e3e6c80027448e51b7802394304a (diff) | |
parent | cbf6cad8524b2b46a364898274871eba5dca776f (diff) | |
download | mitmproxy-937a358aa9396d5a5c18bc69e89e11af5dad40a5.tar.gz mitmproxy-937a358aa9396d5a5c18bc69e89e11af5dad40a5.tar.bz2 mitmproxy-937a358aa9396d5a5c18bc69e89e11af5dad40a5.zip |
Merge branch 'master' of ssh.github.com:mitmproxy/mitmproxy
Diffstat (limited to 'examples/flowwriter.py')
-rw-r--r-- | examples/flowwriter.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/flowwriter.py b/examples/flowwriter.py new file mode 100644 index 00000000..f411ec45 --- /dev/null +++ b/examples/flowwriter.py @@ -0,0 +1,20 @@ +import random +import sys + +from libmproxy.flow import FlowWriter + + +def start(context, argv): + if len(argv) != 2: + raise ValueError('Usage: -s "flowriter.py filename"') + + if argv[1] == "-": + f = sys.stdout + else: + f = open(argv[1], "wb") + context.flow_writer = FlowWriter(f) + + +def response(context, flow): + if random.choice([True, False]): + context.flow_writer.add(flow)
\ No newline at end of file |