mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-12-02 12:01:17 +00:00
Add a domain match filter (~d regex)
This commit is contained in:
parent
c4426952ad
commit
d02bcade3a
@ -182,6 +182,13 @@ class FMethod(_Rex):
|
|||||||
return bool(re.search(self.expr, f.request.method, re.IGNORECASE))
|
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):
|
class FUrl(_Rex):
|
||||||
code = "u"
|
code = "u"
|
||||||
help = "URL"
|
help = "URL"
|
||||||
@ -260,6 +267,7 @@ filt_rex = [
|
|||||||
FBodResponse,
|
FBodResponse,
|
||||||
FBod,
|
FBod,
|
||||||
FMethod,
|
FMethod,
|
||||||
|
FDomain,
|
||||||
FUrl,
|
FUrl,
|
||||||
FRequestContentType,
|
FRequestContentType,
|
||||||
FResponseContentType,
|
FResponseContentType,
|
||||||
|
@ -195,6 +195,12 @@ class TestMatching:
|
|||||||
q.request.method = "oink"
|
q.request.method = "oink"
|
||||||
assert not self.q("~m get", q)
|
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):
|
def test_url(self):
|
||||||
q = self.req()
|
q = self.req()
|
||||||
s = self.resp()
|
s = self.resp()
|
||||||
|
Loading…
Reference in New Issue
Block a user