Peer discovery fixes
- incoming packets weren't correctly processed
This commit is contained in:
parent
d9e4f2ceb8
commit
0324958e92
|
@ -8,7 +8,7 @@ import state
|
||||||
|
|
||||||
def getDiscoveredPeer(stream):
|
def getDiscoveredPeer(stream):
|
||||||
try:
|
try:
|
||||||
peer = random.choice(state.discoveredPeers.keys())
|
return random.choice(state.discoveredPeers.keys())
|
||||||
except (IndexError, KeyError):
|
except (IndexError, KeyError):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ class BMConnectionPool(object):
|
||||||
return self.inboundConnections[addr.host]
|
return self.inboundConnections[addr.host]
|
||||||
if addr in self.outboundConnections:
|
if addr in self.outboundConnections:
|
||||||
return self.outboundConnections[addr]
|
return self.outboundConnections[addr]
|
||||||
if addr in self.udpSockets:
|
if addr.host in self.udpSockets:
|
||||||
return self.udpSockets[addr]
|
return self.udpSockets[addr.host]
|
||||||
raise KeyError
|
raise KeyError
|
||||||
|
|
||||||
def isAlreadyConnected(self, nodeid):
|
def isAlreadyConnected(self, nodeid):
|
||||||
|
|
|
@ -100,7 +100,7 @@ class UDPSocket(BMProto):
|
||||||
return True
|
return True
|
||||||
logger.debug("received peer discovery from %s:%i (port %i):", self.destination.host, self.destination.port, remoteport)
|
logger.debug("received peer discovery from %s:%i (port %i):", self.destination.host, self.destination.port, remoteport)
|
||||||
if self.local:
|
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
|
return True
|
||||||
|
|
||||||
def bm_command_portcheck(self):
|
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
|
# overwrite the old buffer to avoid mixing data and so that self.local works correctly
|
||||||
self.read_buf = recdata
|
self.read_buf = recdata
|
||||||
self.bm_proto_reset()
|
self.bm_proto_reset()
|
||||||
receiveDataQueue.put(self.destination)
|
receiveDataQueue.put(self.listening)
|
||||||
|
|
||||||
def handle_write(self):
|
def handle_write(self):
|
||||||
try:
|
try:
|
||||||
|
|
Reference in New Issue
Block a user