Do not update addrQueue if not added node to own knownnodes
and more checks in knownnodes.addKnownNode moved from bmproto.
This commit is contained in:
parent
0dd49761d0
commit
d9ddbe8d24
|
@ -105,17 +105,25 @@ def addKnownNode(stream, peer, lastseen=None, is_self=False):
|
|||
else:
|
||||
lastseen = int(lastseen)
|
||||
try:
|
||||
knownNodes[stream][peer]['lastseen'] = lastseen
|
||||
except KeyError:
|
||||
info = knownNodes[stream].get(peer)
|
||||
if lastseen > info['lastseen']:
|
||||
info['lastseen'] = lastseen
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
else:
|
||||
return
|
||||
|
||||
if not is_self:
|
||||
if len(knownNodes[stream]) > BMConfigParser().safeGetInt(
|
||||
"knownnodes", "maxnodes"):
|
||||
return
|
||||
|
||||
knownNodes[stream][peer] = {
|
||||
'lastseen': lastseen,
|
||||
'rating': rating or 1 if is_self else 0,
|
||||
'self': is_self,
|
||||
}
|
||||
return True
|
||||
|
||||
|
||||
def createDefaultKnownNodes():
|
||||
|
|
|
@ -447,22 +447,17 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
|||
and port > 0
|
||||
):
|
||||
peer = Peer(decodedIP, port)
|
||||
try:
|
||||
if knownnodes.knownNodes[stream][peer]["lastseen"] > \
|
||||
seenTime:
|
||||
continue
|
||||
except KeyError:
|
||||
pass
|
||||
if len(knownnodes.knownNodes[stream]) < \
|
||||
BMConfigParser().safeGetInt("knownnodes", "maxnodes"):
|
||||
with knownnodes.knownNodesLock:
|
||||
knownnodes.addKnownNode(stream, peer, seenTime)
|
||||
|
||||
# since we don't track peers outside of knownnodes,
|
||||
# only spread if in knownnodes to prevent flood
|
||||
# DISABLED TO WORKAROUND FLOOD/LEAK
|
||||
# addrQueue.put((stream, peer, seenTime,
|
||||
# self.destination))
|
||||
with knownnodes.knownNodesLock:
|
||||
# isnew =
|
||||
knownnodes.addKnownNode(stream, peer, seenTime)
|
||||
|
||||
# since we don't track peers outside of knownnodes,
|
||||
# only spread if in knownnodes to prevent flood
|
||||
# DISABLED TO WORKAROUND FLOOD/LEAK
|
||||
# if isnew:
|
||||
# addrQueue.put((
|
||||
# stream, peer, seenTime, self.destination))
|
||||
return True
|
||||
|
||||
def bm_command_portcheck(self):
|
||||
|
|
Reference in New Issue
Block a user