mitmproxy/examples/addons/filter-flows.py

27 lines
630 B
Python
Raw Normal View History

"""
Use mitmproxy's filter pattern in scripts.
"""
2016-10-01 10:44:17 +00:00
from mitmproxy import flowfilter
2017-04-28 21:56:14 +00:00
from mitmproxy import ctx, http
2015-04-07 22:21:49 +00:00
class Filter:
def __init__(self):
self.filter: flowfilter.TFilter = None
def configure(self, updated):
self.filter = flowfilter.parse(ctx.options.flowfilter)
def load(self, l):
l.add_option(
"flowfilter", str, "", "Check that flow matches filter."
)
2017-04-28 21:56:14 +00:00
def response(self, flow: http.HTTPFlow) -> None:
if flowfilter.match(self.filter, flow):
ctx.log.info("Flow matches filter:")
ctx.log.info(flow)
2015-05-30 00:03:28 +00:00
2016-07-08 01:37:33 +00:00
addons = [Filter()]