diff options
-rw-r--r-- | mitmproxy/models/flow.py | 20 | ||||
-rw-r--r-- | mitmproxy/models/http.py | 19 | ||||
-rw-r--r-- | mitmproxy/models/tcp.py | 21 |
3 files changed, 20 insertions, 40 deletions
diff --git a/mitmproxy/models/flow.py b/mitmproxy/models/flow.py index bdbc0929..f4a2b54b 100644 --- a/mitmproxy/models/flow.py +++ b/mitmproxy/models/flow.py @@ -8,6 +8,8 @@ from mitmproxy import stateobject from mitmproxy.models.connections import ClientConnection from mitmproxy.models.connections import ServerConnection +import six + from netlib import version from typing import Optional # noqa @@ -175,3 +177,21 @@ class Flow(stateobject.StateObject): self.intercepted = False self.reply.ack() master.handle_accept_intercept(self) + + def match(self, f): + """ + Match this flow against a compiled filter expression. Returns True + if matched, False if not. + + If f is a string, it will be compiled as a filter expression. If + the expression is invalid, ValueError is raised. + """ + if isinstance(f, six.string_types): + from .. import filt + + f = filt.parse(f) + if not f: + raise ValueError("Invalid filter expression.") + if f: + return f(self) + return True diff --git a/mitmproxy/models/http.py b/mitmproxy/models/http.py index 1fd28f00..7781e61f 100644 --- a/mitmproxy/models/http.py +++ b/mitmproxy/models/http.py @@ -2,7 +2,6 @@ from __future__ import absolute_import, print_function, division import cgi import warnings -import six from mitmproxy.models.flow import Flow from netlib import version @@ -211,24 +210,6 @@ class HTTPFlow(Flow): f.response = self.response.copy() return f - def match(self, f): - """ - Match this flow against a compiled filter expression. Returns True - if matched, False if not. - - If f is a string, it will be compiled as a filter expression. If - the expression is invalid, ValueError is raised. - """ - if isinstance(f, six.string_types): - from .. import filt - - f = filt.parse(f) - if not f: - raise ValueError("Invalid filter expression.") - if f: - return f(self) - return True - def replace(self, pattern, repl, *args, **kwargs): """ Replaces a regular expression pattern with repl in both request and diff --git a/mitmproxy/models/tcp.py b/mitmproxy/models/tcp.py index 6650141d..e33475c2 100644 --- a/mitmproxy/models/tcp.py +++ b/mitmproxy/models/tcp.py @@ -7,8 +7,6 @@ from typing import List import netlib.basetypes from mitmproxy.models.flow import Flow -import six - class TCPMessage(netlib.basetypes.Serializable): @@ -55,22 +53,3 @@ class TCPFlow(Flow): def __repr__(self): return "<TCPFlow ({} messages)>".format(len(self.messages)) - - def match(self, f): - """ - Match this flow against a compiled filter expression. Returns True - if matched, False if not. - - If f is a string, it will be compiled as a filter expression. If - the expression is invalid, ValueError is raised. - """ - if isinstance(f, six.string_types): - from .. import filt - - f = filt.parse(f) - if not f: - raise ValueError("Invalid filter expression.") - if f: - return f(self) - - return True |