mitmproxy/examples/flowwriter.py
Aldo Cortesi 4ba7ce50c6 Add .start for addons and scripts
Also improve error messages, fix various unit tests
2016-07-15 14:52:34 +12:00

23 lines
416 B
Python

import random
import sys
from mitmproxy.flow import FlowWriter
state = {}
def start():
if len(sys.argv) != 2:
raise ValueError('Usage: -s "flowriter.py filename"')
if sys.argv[1] == "-":
f = sys.stdout
else:
f = open(sys.argv[1], "wb")
state["flow_writer"] = FlowWriter(f)
def response(flow):
if random.choice([True, False]):
state["flow_writer"].add(flow)