mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Add a domain match filter (~d regex)
This commit is contained in:
parent
c4426952ad
commit
d02bcade3a
@ -992,6 +992,6 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
f = flow.FlowMaster.handle_response(self, r)
|
||||
if f:
|
||||
self.process_flow(f, r)
|
||||
if self.stream:
|
||||
self.stream.add(f)
|
||||
if self.stream:
|
||||
self.stream.add(f)
|
||||
return f
|
||||
|
@ -182,6 +182,13 @@ class FMethod(_Rex):
|
||||
return bool(re.search(self.expr, f.request.method, re.IGNORECASE))
|
||||
|
||||
|
||||
class FDomain(_Rex):
|
||||
code = "d"
|
||||
help = "Domain"
|
||||
def __call__(self, f):
|
||||
return bool(re.search(self.expr, f.request.host, re.IGNORECASE))
|
||||
|
||||
|
||||
class FUrl(_Rex):
|
||||
code = "u"
|
||||
help = "URL"
|
||||
@ -260,6 +267,7 @@ filt_rex = [
|
||||
FBodResponse,
|
||||
FBod,
|
||||
FMethod,
|
||||
FDomain,
|
||||
FUrl,
|
||||
FRequestContentType,
|
||||
FResponseContentType,
|
||||
|
@ -195,6 +195,12 @@ class TestMatching:
|
||||
q.request.method = "oink"
|
||||
assert not self.q("~m get", q)
|
||||
|
||||
def test_domain(self):
|
||||
q = self.req()
|
||||
s = self.resp()
|
||||
assert self.q("~d host", q)
|
||||
assert not self.q("~d none", q)
|
||||
|
||||
def test_url(self):
|
||||
q = self.req()
|
||||
s = self.resp()
|
||||
|
Loading…
Reference in New Issue
Block a user