diff --git a/kdcproxy/__init__.py b/kdcproxy/__init__.py index 1493b30..32aa3e1 100644 --- a/kdcproxy/__init__.py +++ b/kdcproxy/__init__.py @@ -74,6 +74,7 @@ def __init__(self): def __await_reply(self, pr, rsocks, wsocks, timeout): extra = 0 read_buffers = {} + reactivations = {} while (timeout + extra) > time.time(): if not wsocks and not rsocks: break @@ -92,6 +93,9 @@ def __await_reply(self, pr, rsocks, wsocks, timeout): pass for sock in w: + (react_n, react_t) = reactivations.get(sock, (-1, 0.0)) + if react_t > time.time(): + continue try: if self.sock_type(sock) == socket.SOCK_DGRAM: # If we proxy over UDP, remove the 4-byte length @@ -101,8 +105,12 @@ def __await_reply(self, pr, rsocks, wsocks, timeout): sock.sendall(pr.request) extra = 10 # New connections get 10 extra seconds except Exception as e: - logging.warning("Conection broken while writing (%s)", e) + logging.warning("Connection broken while writing (%s)", e) + reactivations[sock] = (react_n + 1, + time.time() + 2.0**(react_n+1) / 10) continue + if sock in reactivations: + del reactivations[sock] rsocks.append(sock) wsocks.remove(sock)