diff --git a/src/Connection/Connection.py b/src/Connection/Connection.py index 0fe24a66..456c36f0 100644 --- a/src/Connection/Connection.py +++ b/src/Connection/Connection.py @@ -20,7 +20,7 @@ class Connection(object): "sock", "sock_wrapped", "ip", "port", "cert_pin", "target_onion", "id", "protocol", "type", "server", "unpacker", "req_id", "handshake", "crypt", "connected", "event_connected", "closed", "start_time", "last_recv_time", "last_message_time", "last_send_time", "last_sent_time", "incomplete_buff_recv", "bytes_recv", "bytes_sent", "cpu_time", "send_lock", - "last_ping_delay", "last_req_time", "last_cmd", "bad_actions", "sites", "name", "updateName", "waiting_requests", "waiting_streams" + "last_ping_delay", "last_req_time", "last_cmd_sent", "last_cmd_recv", "bad_actions", "sites", "name", "updateName", "waiting_requests", "waiting_streams" ) def __init__(self, server, ip, port, sock=None, target_onion=None): @@ -58,7 +58,8 @@ class Connection(object): self.bytes_sent = 0 self.last_ping_delay = None self.last_req_time = 0 - self.last_cmd = None + self.last_cmd_sent = None + self.last_cmd_recv = None self.bad_actions = 0 self.sites = 0 self.cpu_time = 0.0 @@ -299,6 +300,7 @@ class Connection(object): cmd = None self.last_message_time = time.time() + self.last_cmd_recv = cmd if cmd == "response": # New style response if message["to"] in self.waiting_requests: if self.last_send_time and len(self.waiting_requests) == 1: @@ -422,7 +424,7 @@ class Connection(object): return False self.last_req_time = time.time() - self.last_cmd = cmd + self.last_cmd_sent = cmd self.req_id += 1 data = {"cmd": cmd, "req_id": self.req_id, "params": params} event = gevent.event.AsyncResult() # Create new event for response diff --git a/src/Connection/ConnectionServer.py b/src/Connection/ConnectionServer.py index f34c69dc..db921f8c 100644 --- a/src/Connection/ConnectionServer.py +++ b/src/Connection/ConnectionServer.py @@ -184,7 +184,7 @@ class ConnectionServer: del connection.unpacker connection.unpacker = None - elif connection.last_cmd == "announce" and idle > 20: # Bootstrapper connection close after 20 sec + elif connection.last_cmd_sent == "announce" and idle > 20: # Bootstrapper connection close after 20 sec connection.close("[Cleanup] Tracker connection: %s" % idle) if idle > 60 * 60: @@ -208,7 +208,7 @@ class ConnectionServer: elif idle > 10 and connection.waiting_requests and time.time() - connection.last_send_time > 10: # Sent command and no response in 10 sec connection.close( - "[Cleanup] Command %s timeout: %.3fs" % (connection.last_cmd, time.time() - connection.last_send_time) + "[Cleanup] Command %s timeout: %.3fs" % (connection.last_cmd_sent, time.time() - connection.last_send_time) ) elif idle < 60 and connection.bad_actions > 40: