test: extend the SOCKS5 Python proxy to actually connect to a destination

If requested, make the SOCKS5 Python proxy redirect each connection to a
given destination. Actually act as a real proxy, connecting the
client to a destination, except that the destination is not what the
client asked for.

This would enable us to "connect" to Tor addresses from the functional
tests.
This commit is contained in:
Vasil Dimov committed 2024-10-22 13:03:02 +02:00
1 parent ba621ffb9c
commit ebe42c00aa
2 files changed
+77

No files matched your search

@@ -167,3 +167,10 @@ def test_unix_socket():
return False
else:
return True
def format_addr_port(addr, port):
'''Return either "addr:port" or "[addr]:port" based on whether addr looks like an IPv6 address.'''
if ":" in addr:
return f"[{addr}]:{port}"
else:
return f"{addr}:{port}"