mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
test: make reusable SOCKS5 server starting
Extract the part of `p2p_private_broadcast.py` that configures and
starts the SOCKS5 server into a reusable function and put it into
`test_framework/socks5.py`.
Use bind port 0 to let the OS pick an available port instead of
hackishly assuming that `p2p_port(N)` is available where N is more
than the number of the nodes the test uses.
Github-Pull: #35410
Rebased-From: 2ffa81fac4
This commit is contained in:
@@ -327,3 +327,15 @@ class Socks5Server():
|
||||
logger.debug(f"Stop(): Handler {i} thread joined")
|
||||
else:
|
||||
logger.warning(f"Stop(): Handler thread {i} didn't finish after force close")
|
||||
|
||||
def start_socks5_server(destinations_factory):
|
||||
config = Socks5Configuration()
|
||||
config.addr = ("127.0.0.1", 0) # Use port=0 to let the OS pick one. The actual port is later in server.conf.addr[1].
|
||||
config.unauth = True
|
||||
config.auth = True
|
||||
config.destinations_factory = destinations_factory
|
||||
|
||||
server = Socks5Server(config)
|
||||
server.start()
|
||||
|
||||
return server
|
||||
|
||||
Reference in New Issue
Block a user