Peer discovery fixes

- incoming packets weren't correctly processed
This commit is contained in:
Peter Šurda 2017-08-06 23:05:54 +02:00
parent d9e4f2ceb8
commit 0324958e92
Signed by: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
3 changed files with 5 additions and 5 deletions

View File

@ -8,7 +8,7 @@ import state
def getDiscoveredPeer(stream):
try:
peer = random.choice(state.discoveredPeers.keys())
return random.choice(state.discoveredPeers.keys())
except (IndexError, KeyError):
raise ValueError

View File

@ -61,8 +61,8 @@ class BMConnectionPool(object):
return self.inboundConnections[addr.host]
if addr in self.outboundConnections:
return self.outboundConnections[addr]
if addr in self.udpSockets:
return self.udpSockets[addr]
if addr.host in self.udpSockets:
return self.udpSockets[addr.host]
raise KeyError
def isAlreadyConnected(self, nodeid):

View File

@ -100,7 +100,7 @@ class UDPSocket(BMProto):
return True
logger.debug("received peer discovery from %s:%i (port %i):", self.destination.host, self.destination.port, remoteport)
if self.local:
state.discoveredPeers[state.Peer(self.destination.host, remoteport)] = time.time
state.discoveredPeers[state.Peer(self.destination.host, remoteport)] = time.time()
return True
def bm_command_portcheck(self):
@ -143,7 +143,7 @@ class UDPSocket(BMProto):
# overwrite the old buffer to avoid mixing data and so that self.local works correctly
self.read_buf = recdata
self.bm_proto_reset()
receiveDataQueue.put(self.destination)
receiveDataQueue.put(self.listening)
def handle_write(self):
try: