UDP Socket dict address fix

- fixes #1008
This commit is contained in:
Peter Šurda 2017-06-11 14:11:39 +02:00
parent cba749088a
commit a3a55e53c4
Signed by: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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