mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-07-05 11:40:07 +02:00
test: SOCKS5 proxy: expect that connection may be reset during handshake
The client (e.g. `bitcoind`) may open a connection to the proxy and close it in the middle of the SOCKS5 handshake if it is restarted for example. Log these as debug messages instead of full blown Python exception error messages with backtraces.
This commit is contained in:
@@ -138,7 +138,12 @@ class Socks5Connection():
|
||||
|
||||
def handle(self):
|
||||
"""Handle socks5 request according to RFC1928."""
|
||||
log_exception_prefix = "Socks5Connection.handle(): "
|
||||
try:
|
||||
log_exception_prefix = ("Socks5Connection.handle("
|
||||
f"client={format_sock(self.conn, local=False)}, "
|
||||
f"proxy={format_sock(self.conn, local=True)}): ")
|
||||
|
||||
# Verify socks version
|
||||
ver = recvall(self.conn, 1)[0]
|
||||
if ver != 0x05:
|
||||
@@ -212,9 +217,12 @@ class Socks5Connection():
|
||||
else:
|
||||
logger.debug(f"Can't serve the connection to {requested_to}: no destinations factory")
|
||||
|
||||
# Fall through to disconnect
|
||||
# Disconnect happens in the "finally" block below.
|
||||
|
||||
except (BrokenPipeError, ConnectionResetError) as e:
|
||||
logger.debug(f"{log_exception_prefix}abnormal connection close: {str(e)}")
|
||||
except Exception as e:
|
||||
logger.exception(f"socks5 request handling failed (running {self.serv.is_running()})")
|
||||
logger.exception(f"{log_exception_prefix}exception: {str(e)} (running {self.serv.is_running()})")
|
||||
if self.serv.is_running():
|
||||
self.serv.queue.put(e)
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user