mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
move flow.match to flowfilter.match
This commit is contained in:
parent
ba84248910
commit
5f8b8bf35e
@ -36,6 +36,7 @@ from __future__ import absolute_import, print_function, division
|
||||
import re
|
||||
import sys
|
||||
import functools
|
||||
import six
|
||||
|
||||
from mitmproxy.models.http import HTTPFlow
|
||||
from mitmproxy.models.tcp import TCPFlow
|
||||
@ -501,16 +502,15 @@ def parse(s):
|
||||
return None
|
||||
|
||||
|
||||
def match(self, flow, flt):
|
||||
def match(flow, flt):
|
||||
"""
|
||||
Match a flow against a compiled filter expression.
|
||||
Matches a flow against a compiled filter expression.
|
||||
Returns True if matched, False if not.
|
||||
|
||||
If flt is a string, it will be compiled as a filter expression.
|
||||
If the expression is invalid, ValueError is raised.
|
||||
"""
|
||||
if isinstance(flt, six.string_types):
|
||||
|
||||
flt = parse(flt)
|
||||
if not flt:
|
||||
raise ValueError("Invalid filter expression.")
|
||||
|
@ -189,20 +189,9 @@ class Flow(stateobject.StateObject):
|
||||
self.reply.commit()
|
||||
master.handle_accept_intercept(self)
|
||||
|
||||
def match(self, flt):
|
||||
"""
|
||||
Matches a flow against a compiled filter expression.
|
||||
Returns True if matched, False if not.
|
||||
def match(self, f):
|
||||
import warnings
|
||||
warnings.warn(".match() is deprecated, please use flowfilter.match(some_flow, some_filter) instead.", DeprecationWarning)
|
||||
|
||||
If flt is a string, it will be compiled as a filter expression.
|
||||
If the expression is invalid, ValueError is raised.
|
||||
"""
|
||||
if isinstance(flt, six.string_types):
|
||||
from ..flowfilter import parse
|
||||
|
||||
flt = parse(flt)
|
||||
if not flt:
|
||||
raise ValueError("Invalid filter expression.")
|
||||
if flt:
|
||||
return flt(self)
|
||||
return True
|
||||
from mitmproxy import flowfilter
|
||||
return flowfilter.match(self, f)
|
||||
|
Loading…
Reference in New Issue
Block a user