From 40b95722331a9234bfc5ed1f2c1b6c1ed818f17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Mon, 21 Mar 2022 15:08:39 +0100 Subject: [PATCH] fixed tunnel to log bad handshake as hex --- tunnel-server/src/udstunnel.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tunnel-server/src/udstunnel.py b/tunnel-server/src/udstunnel.py index 8d233b37c..d6497ac80 100755 --- a/tunnel-server/src/udstunnel.py +++ b/tunnel-server/src/udstunnel.py @@ -103,22 +103,24 @@ async def tunnel_proc_async( ) -> None: def get_socket(pipe: 'Connection') -> typing.Tuple[typing.Optional[socket.SocketType], typing.Any]: try: + data: bytes = b'' while True: msg: message.Message = pipe.recv() if msg.command == message.Command.TUNNEL and msg.connection: # Connection done, check for handshake source, address = msg.connection + source.settimeout(3.0) try: # First, ensure handshake (simple handshake) and command - data: bytes = source.recv(len(consts.HANDSHAKE_V1)) + data = source.recv(len(consts.HANDSHAKE_V1)) if data != consts.HANDSHAKE_V1: raise Exception() # Invalid handshake except Exception: if consts.DEBUG: logger.exception('HANDSHAKE') - logger.error('HANDSHAKE from %s', address) + logger.error('HANDSHAKE from %s (%s)', address, data.hex()) # Close Source and continue source.close() continue