aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_filt.py
diff options
context:
space:
mode:
authorisra17 <isra017@gmail.com>2015-07-13 17:07:39 -0400
committerisra17 <isra017@gmail.com>2015-07-13 18:11:14 -0400
commit471e196e085f4161cb0667e0b70a940cb1de67d2 (patch)
tree5a22df5930a452df4585323b2e7750eb1530a53a /test/test_filt.py
parent2af2e60f1f2eea4e887bda69aea19a82f951a78f (diff)
downloadmitmproxy-471e196e085f4161cb0667e0b70a940cb1de67d2.tar.gz
mitmproxy-471e196e085f4161cb0667e0b70a940cb1de67d2.tar.bz2
mitmproxy-471e196e085f4161cb0667e0b70a940cb1de67d2.zip
Add ~src ~dst REGEX filters
This filter allow to match on the request source and destination address in the form of `<IP>:<Port>`. Also fixed the parsing grammar to add a `WordEnd` after each filter name. That way, `~src` doesn't match `~s` instead and keep the behavior consistent with `~hq` != `~h`.
Diffstat (limited to 'test/test_filt.py')
-rw-r--r--test/test_filt.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/test_filt.py b/test/test_filt.py
index 3ad17dfe..bcdf6e4c 100644
--- a/test/test_filt.py
+++ b/test/test_filt.py
@@ -241,6 +241,23 @@ class TestMatching:
assert self.q("~c 200", s)
assert not self.q("~c 201", s)
+ def test_src(self):
+ q = self.req()
+ assert self.q("~src address", q)
+ assert not self.q("~src foobar", q)
+ assert self.q("~src :22", q)
+ assert not self.q("~src :99", q)
+ assert self.q("~src address:22", q)
+
+ def test_dst(self):
+ q = self.req()
+ q.server_conn = tutils.tserver_conn()
+ assert self.q("~dst address", q)
+ assert not self.q("~dst foobar", q)
+ assert self.q("~dst :22", q)
+ assert not self.q("~dst :99", q)
+ assert self.q("~dst address:22", q)
+
def test_and(self):
s = self.resp()
assert self.q("~c 200 & ~h head", s)