add flowwriter example

This commit is contained in:
Maximilian Hils 2015-04-12 03:47:58 +02:00
parent 923503260e
commit c0a318566a
2 changed files with 18 additions and 1 deletions

17
examples/flowwriter.py Normal file
View 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)

View File

@ -11,7 +11,7 @@ def test_load_scripts():
tmaster = tservers.TestMaster(config.ProxyConfig())
for f in scripts:
if "har_extractor" in f:
if "har_extractor" in f or "flowwriter" in f:
f += " -"
if "iframe_injector" in f:
f += " foo" # one argument required