mitmproxy/examples/flowwriter.py
Aldo Cortesi 5a68d21e8c Remove flow module entirely, move contents to top level
mitmproxy.flow.io -> mitmproxy.io
mitmproxy.flow.export -> mitmproxy.export
2016-10-19 15:08:35 +13:00

23 lines
464 B
Python

import random
import sys
from mimtproxy import io
class Writer:
def __init__(self, path):
if path == "-":
f = sys.stdout
else:
f = open(path, "wb")
self.w = io.FlowWriter(f)
def response(self, flow):
if random.choice([True, False]):
self.w.add(flow)
def start():
if len(sys.argv) != 2:
raise ValueError('Usage: -s "flowriter.py filename"')
return Writer(sys.argv[1])