diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 5501b9358..727765428 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -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 diff --git a/libmproxy/filt.py b/libmproxy/filt.py index 3e4ebe576..937cc29d1 100644 --- a/libmproxy/filt.py +++ b/libmproxy/filt.py @@ -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, diff --git a/test/test_filt.py b/test/test_filt.py index 2421c3271..1cea34c41 100644 --- a/test/test_filt.py +++ b/test/test_filt.py @@ -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()