mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-25 21:04:56 +08:00
add flowwriter example
This commit is contained in:
17
examples/flowwriter.py
Normal file
17
examples/flowwriter.py
Normal file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user