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): def getConnectionByAddr(self, addr):
if addr in self.inboundConnections: if addr in self.inboundConnections:
return self.inboundConnections[addr] return self.inboundConnections[addr]
try:
if addr.host in self.inboundConnections: if addr.host in self.inboundConnections:
return self.inboundConnections[addr.host] return self.inboundConnections[addr.host]
except AttributeError:
pass
if addr in self.outboundConnections: if addr in self.outboundConnections:
return self.outboundConnections[addr] return self.outboundConnections[addr]
try:
if addr.host in self.udpSockets: if addr.host in self.udpSockets:
return self.udpSockets[addr.host] return self.udpSockets[addr.host]
except AttributeError:
pass
raise KeyError raise KeyError
def isAlreadyConnected(self, nodeid): def isAlreadyConnected(self, nodeid):