Connection lookups invalid data handling

- shouldn't throw an exception if argument is a string rather than Peer
This commit is contained in:
Peter Šurda 2018-01-02 22:23:03 +01:00
parent f74f82e54f
commit c9851b9f41
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -65,12 +65,18 @@ class BMConnectionPool(object):
def getConnectionByAddr(self, addr):
if addr in self.inboundConnections:
return self.inboundConnections[addr]
if addr.host in self.inboundConnections:
return self.inboundConnections[addr.host]
try:
if addr.host in self.inboundConnections:
return self.inboundConnections[addr.host]
except AttributeError:
pass
if addr in self.outboundConnections:
return self.outboundConnections[addr]
if addr.host in self.udpSockets:
return self.udpSockets[addr.host]
try:
if addr.host in self.udpSockets:
return self.udpSockets[addr.host]
except AttributeError:
pass
raise KeyError
def isAlreadyConnected(self, nodeid):