mitmproxy/examples/flowwriter.py

17 lines
393 B
Python
Raw Normal View History

2015-04-12 01:47:58 +00:00
from libmproxy.flow import FlowWriter
import random
import sys
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)