From e186c7a85d7a3933876dc29a6a9309eeca4db478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Fri, 15 Oct 2021 13:06:56 +0300 Subject: [PATCH] Add 1 min timeout for no new data transferred --- untls_proxy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/untls_proxy.py b/untls_proxy.py index ff7ee64..4f7963b 100755 --- a/untls_proxy.py +++ b/untls_proxy.py @@ -376,18 +376,20 @@ def proxy(sock, host): del request_data - # TODO: Timeout # TODO: Un-https links + # TODO: Keep sending request body, if any print('', file=sys.stderr) + sock.settimeout(60) + remote_sock.settimeout(60) while True: try: data = remote_sock.recv(1024) - except ConnectionResetError: + except (ConnectionResetError, socket.timeout): return if data == b'': break try: sock.sendall(data) - except (ConnectionResetError, BrokenPipeError): + except (ConnectionResetError, BrokenPipeError, socket.timeout): break remote_sock.close()