From c9851b9f41da4db4365ef080b1533ab845992bd1 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Tue, 2 Jan 2018 22:23:03 +0100 Subject: [PATCH] Connection lookups invalid data handling - shouldn't throw an exception if argument is a string rather than Peer --- src/network/connectionpool.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/network/connectionpool.py b/src/network/connectionpool.py index 3b817e65..44534a76 100644 --- a/src/network/connectionpool.py +++ b/src/network/connectionpool.py @@ -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):