From a7c43cad43e18daf74beecd89bd93d53c2590a02 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 10 May 2023 16:20:23 +0100 Subject: [PATCH] Fix socks test on modern microsocks --- test/client/03-publish-socks.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/client/03-publish-socks.py b/test/client/03-publish-socks.py index 546b8711..398def87 100755 --- a/test/client/03-publish-socks.py +++ b/test/client/03-publish-socks.py @@ -9,7 +9,19 @@ def do_test(proto_ver, host): (port1, port2) = mosq_test.get_port(2) - cmd = ['microsocks', '-1', '-b', '-i', host, '-u', 'user', '-P', 'password', '-p', str(port1)] + cmd = ['microsocks', '-?'] + try: + proxy = subprocess.run(cmd, capture_output=True) + except FileNotFoundError: + print("microsocks not found, skipping test") + sys.exit(0) + + cmd = ['microsocks', '-1', '-i', host, '-u', 'user', '-P', 'password', '-p', str(port1)] + if b"bindaddr" in proxy.stderr: + cmd += ['-b', host] + else: + cmd += ['-b'] + try: proxy = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) except FileNotFoundError: