diff --git a/src/network/connectionpool.py b/src/network/connectionpool.py index 1517f4d7..41fb97be 100644 --- a/src/network/connectionpool.py +++ b/src/network/connectionpool.py @@ -69,7 +69,7 @@ class BMConnectionPool(object): def removeConnection(self, connection): if isinstance(connection, network.udp.UDPSocket): - del self.udpSockets[connection.destination.host] + del self.udpSockets[connection.listening.host] if isinstance(connection, network.tcp.TCPServer): del self.listeningSockets[state.Peer(connection.destination.host, connection.destination.port)] elif connection.isOutbound: @@ -109,7 +109,7 @@ class BMConnectionPool(object): udpSocket = network.udp.UDPSocket(host=host) else: udpSocket = network.udp.UDPSocket(host=bind) - self.udpSockets[udpSocket.destination.host] = udpSocket + self.udpSockets[udpSocket.listening.host] = udpSocket def loop(self): # defaults to empty loop if outbound connections are maxed diff --git a/src/network/udp.py b/src/network/udp.py index 241bf9d7..9eccbf67 100644 --- a/src/network/udp.py +++ b/src/network/udp.py @@ -65,6 +65,7 @@ class UDPSocket(BMProto): self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) except AttributeError: pass + self.listening = state.Peer(self.socket.getsockname()[0], self.socket.getsockname()[1]) self.destination = state.Peer(self.socket.getsockname()[0], self.socket.getsockname()[1]) ObjectTracker.__init__(self) self.connecting = False