Small incoming connection optimization
This commit is contained in:
parent
f21fdb23b6
commit
238cb25bb4
1 changed files with 13 additions and 13 deletions
|
@ -111,19 +111,19 @@ class ConnectionServer:
|
||||||
raise Exception("Connection event return error")
|
raise Exception("Connection event return error")
|
||||||
return connection
|
return connection
|
||||||
|
|
||||||
# Recover from connection pool
|
# Recover from connection pool
|
||||||
for connection in self.connections:
|
for connection in self.connections:
|
||||||
if connection.ip == ip:
|
if connection.ip == ip:
|
||||||
if peer_id and connection.handshake.get("peer_id") != peer_id: # Does not match
|
if peer_id and connection.handshake.get("peer_id") != peer_id: # Does not match
|
||||||
continue
|
continue
|
||||||
if ip.endswith(".onion") and self.tor_manager.start_onions and connection.site_lock != site.address:
|
if ip.endswith(".onion") and self.tor_manager.start_onions and connection.site_lock != site.address:
|
||||||
# For different site
|
# For different site
|
||||||
continue
|
continue
|
||||||
if not connection.connected and create:
|
if not connection.connected and create:
|
||||||
succ = connection.event_connected.get() # Wait for connection
|
succ = connection.event_connected.get() # Wait for connection
|
||||||
if not succ:
|
if not succ:
|
||||||
raise Exception("Connection event return error")
|
raise Exception("Connection event return error")
|
||||||
return connection
|
return connection
|
||||||
|
|
||||||
# No connection found
|
# No connection found
|
||||||
if create: # Allow to create new connection if not found
|
if create: # Allow to create new connection if not found
|
||||||
|
|
Loading…
Reference in a new issue