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:
|
else:
|
||||||
lastseen = int(lastseen)
|
lastseen = int(lastseen)
|
||||||
try:
|
try:
|
||||||
knownNodes[stream][peer]['lastseen'] = lastseen
|
info = knownNodes[stream].get(peer)
|
||||||
except KeyError:
|
if lastseen > info['lastseen']:
|
||||||
|
info['lastseen'] = lastseen
|
||||||
|
except (KeyError, TypeError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not is_self:
|
||||||
|
if len(knownNodes[stream]) > BMConfigParser().safeGetInt(
|
||||||
|
"knownnodes", "maxnodes"):
|
||||||
|
return
|
||||||
|
|
||||||
knownNodes[stream][peer] = {
|
knownNodes[stream][peer] = {
|
||||||
'lastseen': lastseen,
|
'lastseen': lastseen,
|
||||||
'rating': rating or 1 if is_self else 0,
|
'rating': rating or 1 if is_self else 0,
|
||||||
'self': is_self,
|
'self': is_self,
|
||||||
}
|
}
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def createDefaultKnownNodes():
|
def createDefaultKnownNodes():
|
||||||
|
|
|
@ -447,22 +447,17 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
and port > 0
|
and port > 0
|
||||||
):
|
):
|
||||||
peer = Peer(decodedIP, port)
|
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:
|
with knownnodes.knownNodesLock:
|
||||||
|
# isnew =
|
||||||
knownnodes.addKnownNode(stream, peer, seenTime)
|
knownnodes.addKnownNode(stream, peer, seenTime)
|
||||||
|
|
||||||
# since we don't track peers outside of knownnodes,
|
# since we don't track peers outside of knownnodes,
|
||||||
# only spread if in knownnodes to prevent flood
|
# only spread if in knownnodes to prevent flood
|
||||||
# DISABLED TO WORKAROUND FLOOD/LEAK
|
# DISABLED TO WORKAROUND FLOOD/LEAK
|
||||||
# addrQueue.put((stream, peer, seenTime,
|
# if isnew:
|
||||||
# self.destination))
|
# addrQueue.put((
|
||||||
|
# stream, peer, seenTime, self.destination))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def bm_command_portcheck(self):
|
def bm_command_portcheck(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user