mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 10:16:27 +00:00
24cf8da27e
The primary motivation here (and for all the other moving around) is to present a clean "front of house" to library users, and to migrate primary objects to the top of the module hierarchy.
23 lines
464 B
Python
23 lines
464 B
Python
import random
|
|
import sys
|
|
from mitmproxy 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])
|