mitmproxy/examples/addons/filter-flows.py

29 lines
636 B
Python
Raw Normal View History

"""
Use mitmproxy's filter pattern in scripts.
"""
from __future__ import annotations
2022-11-29 13:28:41 +00:00
import logging
from mitmproxy import flowfilter
2022-11-29 13:28:41 +00:00
from mitmproxy import http
2015-04-07 22:21:49 +00:00
class Filter:
filter: flowfilter.TFilter
def configure(self, updated):
if "flowfilter" in updated:
self.filter = flowfilter.parse(".")
def load(self, l):
2022-04-26 11:53:35 +00:00
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):
logging.info("Flow matches filter:")
logging.info(flow)
2015-05-30 00:03:28 +00:00
2016-07-08 01:37:33 +00:00
addons = [Filter()]