aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorMatthew Zipkin <pinheadmz@gmail.com>2023-06-23 11:00:05 -0400
committerMatthew Zipkin <pinheadmz@gmail.com>2023-07-10 10:07:45 -0400
commitb4bee4bbf45785fbbb355194ccb23c70acd19d27 (patch)
treea9a4012c42848c1548343e2b987e16718b5a0e86 /test/functional/test_framework
parent5aaf988ccca210228c5a41ea0a18b0c85a85cf71 (diff)
test: add keep_alive option to socks5 proxy in test_framework
The Socks5 server we use in the test framework would disconnect by default immediately after the handshake and sometimes would not register as a connected peer by bitcoind.
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r--test/functional/test_framework/socks5.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/test/functional/test_framework/socks5.py b/test/functional/test_framework/socks5.py
index 799b1c74b8..0ca06a7396 100644
--- a/test/functional/test_framework/socks5.py
+++ b/test/functional/test_framework/socks5.py
@@ -40,6 +40,7 @@ class Socks5Configuration():
self.af = socket.AF_INET # Bind address family
self.unauth = False # Support unauthenticated
self.auth = False # Support authentication
+ self.keep_alive = False # Do not automatically close connections
class Socks5Command():
"""Information about an incoming socks5 command."""
@@ -115,13 +116,14 @@ class Socks5Connection():
cmdin = Socks5Command(cmd, atyp, addr, port, username, password)
self.serv.queue.put(cmdin)
- logger.info('Proxy: %s', cmdin)
+ logger.debug('Proxy: %s', cmdin)
# Fall through to disconnect
except Exception as e:
logger.exception("socks5 request handling failed.")
self.serv.queue.put(e)
finally:
- self.conn.close()
+ if not self.serv.keep_alive:
+ self.conn.close()
class Socks5Server():
def __init__(self, conf):
@@ -133,6 +135,7 @@ class Socks5Server():
self.running = False
self.thread = None
self.queue = queue.Queue() # report connections and exceptions to client
+ self.keep_alive = conf.keep_alive
def run(self):
while self.running:
@@ -157,4 +160,3 @@ class Socks5Server():
s.connect(self.conf.addr)
s.close()
self.thread.join()
-