From a3a55e53c4e4c4e1b3bf2125b781e01e76a0786b Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sun, 11 Jun 2017 14:11:39 +0200 Subject: [PATCH] UDP Socket dict address fix - fixes #1008 --- src/network/connectionpool.py | 4 ++-- src/network/udp.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) 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