Server full and duplicate handling
- will try to report "Server full" over protocol for 10 extra connections over limit, instead of simply dropping them - if connected to the same host inbound and outbound, handle as server full (prevents duplicate connections)
This commit is contained in:
parent
9b58f35b80
commit
8788f2d349
|
@ -497,6 +497,20 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
if not self.isOutbound:
|
||||||
|
# incoming from a peer we're connected to as outbound, or server full
|
||||||
|
# report the same error to counter deanonymisation
|
||||||
|
if state.Peer(self.destination.host, self.peerNode.port) in \
|
||||||
|
network.connectionpool.BMConnectionPool().inboundConnections or \
|
||||||
|
len(network.connectionpool.BMConnectionPool().inboundConnections) + \
|
||||||
|
len(network.connectionpool.BMConnectionPool().outboundConnections) > \
|
||||||
|
BMConfigParser().safeGetInt("bitmessagesettings", "maxtotalconnections") + \
|
||||||
|
BMConfigParser().safeGetInt("bitmessagesettings", "maxbootstrapconnections"):
|
||||||
|
self.append_write_buf(protocol.assembleErrorMessage(fatal=2,
|
||||||
|
errorText="Server full, please try again later."))
|
||||||
|
logger.debug ("Closed connection to %s due to server full or duplicate inbound/outbound.",
|
||||||
|
str(self.destination))
|
||||||
|
return False
|
||||||
if network.connectionpool.BMConnectionPool().isAlreadyConnected(self.nonce):
|
if network.connectionpool.BMConnectionPool().isAlreadyConnected(self.nonce):
|
||||||
self.append_write_buf(protocol.assembleErrorMessage(fatal=2,
|
self.append_write_buf(protocol.assembleErrorMessage(fatal=2,
|
||||||
errorText="I'm connected to myself. Closing connection."))
|
errorText="I'm connected to myself. Closing connection."))
|
||||||
|
|
|
@ -292,7 +292,10 @@ class TCPServer(AdvancedDispatcher):
|
||||||
if len(network.connectionpool.BMConnectionPool().inboundConnections) + \
|
if len(network.connectionpool.BMConnectionPool().inboundConnections) + \
|
||||||
len(network.connectionpool.BMConnectionPool().outboundConnections) > \
|
len(network.connectionpool.BMConnectionPool().outboundConnections) > \
|
||||||
BMConfigParser().safeGetInt("bitmessagesettings", "maxtotalconnections") + \
|
BMConfigParser().safeGetInt("bitmessagesettings", "maxtotalconnections") + \
|
||||||
BMConfigParser().safeGetInt("bitmessagesettings", "maxbootstrapconnections"):
|
BMConfigParser().safeGetInt("bitmessagesettings", "maxbootstrapconnections") + 10:
|
||||||
|
# 10 is a sort of buffer, in between it will go through the version handshake
|
||||||
|
# and return an error to the peer
|
||||||
|
logger.warning("Server full, dropping connection")
|
||||||
sock.close()
|
sock.close()
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
|
Reference in New Issue
Block a user