Lines Matching +refs:close +refs:connection

118         for connection in self.connections[:]:
119 connection.close("Close all connections")
123 sock.close()
141 sock.close()
146 connection = Connection(self, ip, port, sock)
147 self.connections.append(connection)
149 self.ips[ip] = connection
150 connection.handleIncomingConnection(sock)
169 connection = self.ips[key]
170 if not peer_id or connection.handshake.get("peer_id") == peer_id: # Filter by peer_id
171 if not connection.connected and create:
172 succ = connection.event_connected.get() # Wait for connection
175 return connection
178 for connection in self.connections:
179 if connection.ip == ip:
180 if peer_id and connection.handshake.get("peer_id") != peer_id: # Does not match
182 ….onion") and self.tor_manager.start_onions and ip.replace(".onion", "") != connection.target_onion:
185 if not connection.connected and create:
186 succ = connection.event_connected.get() # Wait for connection
189 return connection
201connection = Connection(self, ip, port, target_onion=site_onion, is_tracker_connection=is_tracker_…
203connection = Connection(self, ip, port, is_tracker_connection=is_tracker_connection)
205 self.ips[key] = connection
206 self.connections.append(connection)
207 connection.log("Connecting... (site: %s)" % site)
208 succ = connection.connect()
210 connection.close("Connection event return error")
214 connection.close("%s Connect error: %s" % (ip, Debug.formatException(err)))
220 return connection
224 def removeConnection(self, connection): argument
226 if self.ips.get(connection.ip) == connection:
227 del self.ips[connection.ip]
229 if connection.target_onion:
230 if self.ips.get(connection.ip + connection.target_onion) == connection:
231 del self.ips[connection.ip + connection.target_onion]
233 … if connection.cert_pin and self.ips.get(connection.ip + "#" + connection.cert_pin) == connection:
234 del self.ips[connection.ip + "#" + connection.cert_pin]
236 if connection in self.connections:
237 self.connections.remove(connection)
247 for connection in self.connections[:]: # Make a copy
248 if connection.ip.endswith(".onion") or config.tor == "always":
253 …idle = time.time() - max(connection.last_recv_time, connection.start_time, connection.last_message…
254 … if connection.last_message_time > last_message_time and not connection.is_private_ip:
256 last_message_time = connection.last_message_time
258 if connection.unpacker and idle > 30:
260 del connection.unpacker
261 connection.unpacker = None
263 …elif connection.last_cmd_sent == "announce" and idle > 20: # Bootstrapper connection close after …
264 connection.close("[Cleanup] Tracker connection, idle: %.3fs" % idle)
268 connection.close("[Cleanup] After wakeup, idle: %.3fs" % idle)
270 elif idle > 20 * 60 and connection.last_send_time < time.time() - 10:
272 if not connection.ping():
273 connection.close("[Cleanup] Ping timeout")
275 elif idle > 10 * timeout_multipler and connection.incomplete_buff_recv > 0:
277 connection.close("[Cleanup] Connection buff stalled")
279 … elif idle > 10 * timeout_multipler and connection.protocol == "?": # No connection after 10 sec
280 connection.close(
284 …elif idle > 10 * timeout_multipler and connection.waiting_requests and time.time() - connection.la…
286 connection.close(
287 …"[Cleanup] Command %s timeout: %.3fs" % (connection.last_cmd_sent, time.time() - connection.last_s…
290 elif idle < 60 and connection.bad_actions > 40:
291 connection.close(
292 "[Cleanup] Too many bad actions: %s" % connection.bad_actions
295 elif idle > 5 * 60 and connection.sites == 0:
296 connection.close(
302 connection.bad_actions = 0
329 self.connections.sort(key=lambda connection: connection.sites)
331 for connection in self.connections:
332 …idle = time.time() - max(connection.last_recv_time, connection.start_time, connection.last_message…
334 connection.close("Connection limit reached")
353connection.handshake.get("time") - connection.handshake_time + connection.last_ping_delay
354 for connection in self.connections
355 if connection.handshake.get("time") and connection.last_ping_delay