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()