From 03769b94b841072881cdb8e8e62fa9f662388678 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 29 Jun 2018 12:00:52 -0400 Subject: [PATCH] accept invalid store tokens for the first expire-time after startup this is to better handle nodes storing to us after we've restarted our node --- lbrynet/dht/node.py | 4 +++- lbrynet/dht/protocol.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lbrynet/dht/node.py b/lbrynet/dht/node.py index 39e8291b0..a3681b604 100644 --- a/lbrynet/dht/node.py +++ b/lbrynet/dht/node.py @@ -518,7 +518,9 @@ class Node(MockKademliaHelper): if originalPublisherID is None: originalPublisherID = rpc_contact.id compact_ip = rpc_contact.compact_ip() - if not self.verify_token(token, compact_ip): + if self.clock.seconds() - self._protocol.started_listening_time < constants.tokenSecretChangeInterval: + pass + elif not self.verify_token(token, compact_ip): raise ValueError("Invalid token") if 0 <= port <= 65536: compact_port = str(struct.pack('>H', port)) diff --git a/lbrynet/dht/protocol.py b/lbrynet/dht/protocol.py index 73b81bc2c..40407d191 100644 --- a/lbrynet/dht/protocol.py +++ b/lbrynet/dht/protocol.py @@ -103,6 +103,7 @@ class KademliaProtocol(protocol.DatagramProtocol): self._listening = defer.Deferred(None) self._ping_queue = PingQueue(self._node) self._protocolVersion = constants.protocolVersion + self.started_listening_time = 0 def _migrate_incoming_rpc_args(self, contact, method, *args): if method == 'store' and contact.protocolVersion == 0: @@ -202,6 +203,7 @@ class KademliaProtocol(protocol.DatagramProtocol): if self._listening.called: self._listening = defer.Deferred() self._listening.callback(True) + self.started_listening_time = self._node.clock.seconds() return self._ping_queue.start() def datagramReceived(self, datagram, address):