mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Add ~http and ~tcp filters
This commit is contained in:
parent
262a420553
commit
6a2668d865
@ -81,6 +81,24 @@ class FErr(_Action):
|
||||
return True if f.error else False
|
||||
|
||||
|
||||
class FHTTP(_Action):
|
||||
code = "http"
|
||||
help = "Match HTTP flows"
|
||||
|
||||
@only(HTTPFlow)
|
||||
def __call__(self, f):
|
||||
return True
|
||||
|
||||
|
||||
class FTCP(_Action):
|
||||
code = "tcp"
|
||||
help = "Match TCP flows"
|
||||
|
||||
@only(TCPFlow)
|
||||
def __call__(self, f):
|
||||
return True
|
||||
|
||||
|
||||
class FReq(_Action):
|
||||
code = "q"
|
||||
help = "Match request with no response"
|
||||
@ -384,7 +402,9 @@ filt_unary = [
|
||||
FReq,
|
||||
FResp,
|
||||
FAsset,
|
||||
FErr
|
||||
FErr,
|
||||
FHTTP,
|
||||
FTCP,
|
||||
]
|
||||
filt_rex = [
|
||||
FHeadRequest,
|
||||
|
@ -87,6 +87,11 @@ class TestMatchingHTTPFlow:
|
||||
def q(self, q, o):
|
||||
return filt.parse(q)(o)
|
||||
|
||||
def test_http(self):
|
||||
s = self.req()
|
||||
assert self.q("~http", s)
|
||||
assert not self.q("~tcp", s)
|
||||
|
||||
def test_asset(self):
|
||||
s = self.resp()
|
||||
assert not self.q("~a", s)
|
||||
@ -258,6 +263,11 @@ class TestMatchingTCPFlow:
|
||||
def q(self, q, o):
|
||||
return filt.parse(q)(o)
|
||||
|
||||
def test_tcp(self):
|
||||
f = self.flow()
|
||||
assert self.q("~tcp", f)
|
||||
assert not self.q("~http", f)
|
||||
|
||||
def test_ferr(self):
|
||||
e = self.err()
|
||||
assert self.q("~e", e)
|
||||
|
Loading…
Reference in New Issue
Block a user