mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
08895e9ba6
- restructure examples (fix #4031) - remove example dependencies from setup.py, we do not need special dependencies for our supported addons. - unify how we generate docs from code - improve example docs
27 lines
630 B
Python
27 lines
630 B
Python
"""
|
|
Use mitmproxy's filter pattern in scripts.
|
|
"""
|
|
from mitmproxy import flowfilter
|
|
from mitmproxy import ctx, http
|
|
|
|
|
|
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."
|
|
)
|
|
|
|
def response(self, flow: http.HTTPFlow) -> None:
|
|
if flowfilter.match(self.filter, flow):
|
|
ctx.log.info("Flow matches filter:")
|
|
ctx.log.info(flow)
|
|
|
|
|
|
addons = [Filter()]
|