mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +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))
|
||||
|
||||
|
||||
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