test: use dynamic port allocation to avoid test conflicts

Use port=0 for dynamic port allocation in test framework components
to avoid "address already in use" errors from concurrent tests or
ports stuck in TIME_WAIT state from previous test runs.

Changes:
- socks5.py: Update conf.addr after bind() to reflect actual port
- p2p.py: Retrieve actual port after create_server() when port=0
- feature_proxy.py: Use port=0 for all SOCKS5 proxy servers
- feature_anchors.py: Use port=0 for onion proxy server
This commit is contained in:
woltx committed 2026-01-09 18:43:44 -08:00
1 parent aeaa67a9ea
commit ce63d37ebe
4 files changed
+16 -11

No files matched your search

+3
View File
@@ -203,6 +203,9 @@ class Socks5Server():
self.s = socket.socket(conf.af)
self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.s.bind(conf.addr)
# When port=0, the OS assigns an available port. Update conf.addr
# to reflect the actual bound address so callers can use it.
self.conf.addr = self.s.getsockname()
self.s.listen(5)
self.running = False
self.thread = None