diff options
-rw-r--r-- | doc-src/schematics/architecture.pdf | bin | 0 -> 182446 bytes | |||
-rw-r--r-- | doc-src/schematics/architecture.vsdx | bin | 0 -> 60572 bytes | |||
-rw-r--r-- | libmproxy/cmdline.py | 3 | ||||
-rw-r--r-- | libmproxy/script.py | 25 | ||||
-rw-r--r-- | test/test_proxy.py | 20 |
5 files changed, 36 insertions, 12 deletions
diff --git a/doc-src/schematics/architecture.pdf b/doc-src/schematics/architecture.pdf Binary files differnew file mode 100644 index 00000000..77f5ad58 --- /dev/null +++ b/doc-src/schematics/architecture.pdf diff --git a/doc-src/schematics/architecture.vsdx b/doc-src/schematics/architecture.vsdx Binary files differnew file mode 100644 index 00000000..9820434a --- /dev/null +++ b/doc-src/schematics/architecture.vsdx diff --git a/libmproxy/cmdline.py b/libmproxy/cmdline.py index b9e62b71..28156a59 100644 --- a/libmproxy/cmdline.py +++ b/libmproxy/cmdline.py @@ -421,8 +421,7 @@ def common_options(parser): "Proxy Authentication", """ Specify which users are allowed to access the proxy and the method - used for authenticating them. These options are ignored if the - proxy is in transparent or reverse proxy mode. + used for authenticating them. """ ) user_specification_group = group.add_mutually_exclusive_group() diff --git a/libmproxy/script.py b/libmproxy/script.py index 706d84d5..f5fb6b41 100644 --- a/libmproxy/script.py +++ b/libmproxy/script.py @@ -108,15 +108,28 @@ class Script: return (False, None) +class ReplyProxy(object): + def __init__(self, original_reply): + self._ignore_calls = 1 + self.lock = threading.Lock() + self.original_reply = original_reply + + def __call__(self, *args, **kwargs): + with self.lock: + if self._ignore_calls > 0: + self._ignore_calls -= 1 + return + self.original_reply(*args, **kwargs) + + def __getattr__ (self, k): + return getattr(self.original_reply, k) + + def _handle_concurrent_reply(fn, o, *args, **kwargs): # Make first call to o.reply a no op - original_reply = o.reply - def restore_original_reply(): - o.reply = original_reply - if hasattr(original_reply, "q"): - restore_original_reply.q = original_reply.q - o.reply = restore_original_reply + reply_proxy = ReplyProxy(o.reply) + o.reply = reply_proxy def run(): fn(*args, **kwargs) diff --git a/test/test_proxy.py b/test/test_proxy.py index 91e4954f..2e206529 100644 --- a/test/test_proxy.py +++ b/test/test_proxy.py @@ -69,12 +69,24 @@ class TestProcessProxyOptions: def test_no_transparent(self): self.assert_err("transparent mode not supported", "-T") + @mock.patch("libmproxy.platform.resolver") - def test_transparent_reverse(self, _): - self.assert_err("mutually exclusive", "-R", "http://localhost", "-T") - self.assert_noerr("-T") - self.assert_err("Invalid server specification", "-R", "reverse") + def test_modes(self, _): self.assert_noerr("-R", "http://localhost") + self.assert_err("expected one argument", "-R") + self.assert_err("Invalid server specification", "-R", "reverse") + + self.assert_noerr("-T") + + self.assert_noerr("-U", "http://localhost") + self.assert_err("expected one argument", "-U") + self.assert_err("Invalid server specification", "-U", "upstream") + + self.assert_noerr("--destination-server", "http://localhost") + self.assert_err("expected one argument", "--destination-server") + self.assert_err("Invalid server specification", "--destination-server", "manual") + + self.assert_err("mutually exclusive", "-R", "http://localhost", "-T") def test_client_certs(self): with tutils.tmpdir() as confdir: |