forked from LBRYCommunity/lbry-sdk
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
This commit is contained in:
parent
07292363f9
commit
03769b94b8
2 changed files with 5 additions and 1 deletions
|
@ -518,7 +518,9 @@ class Node(MockKademliaHelper):
|
||||||
if originalPublisherID is None:
|
if originalPublisherID is None:
|
||||||
originalPublisherID = rpc_contact.id
|
originalPublisherID = rpc_contact.id
|
||||||
compact_ip = rpc_contact.compact_ip()
|
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")
|
raise ValueError("Invalid token")
|
||||||
if 0 <= port <= 65536:
|
if 0 <= port <= 65536:
|
||||||
compact_port = str(struct.pack('>H', port))
|
compact_port = str(struct.pack('>H', port))
|
||||||
|
|
|
@ -103,6 +103,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
self._listening = defer.Deferred(None)
|
self._listening = defer.Deferred(None)
|
||||||
self._ping_queue = PingQueue(self._node)
|
self._ping_queue = PingQueue(self._node)
|
||||||
self._protocolVersion = constants.protocolVersion
|
self._protocolVersion = constants.protocolVersion
|
||||||
|
self.started_listening_time = 0
|
||||||
|
|
||||||
def _migrate_incoming_rpc_args(self, contact, method, *args):
|
def _migrate_incoming_rpc_args(self, contact, method, *args):
|
||||||
if method == 'store' and contact.protocolVersion == 0:
|
if method == 'store' and contact.protocolVersion == 0:
|
||||||
|
@ -202,6 +203,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
if self._listening.called:
|
if self._listening.called:
|
||||||
self._listening = defer.Deferred()
|
self._listening = defer.Deferred()
|
||||||
self._listening.callback(True)
|
self._listening.callback(True)
|
||||||
|
self.started_listening_time = self._node.clock.seconds()
|
||||||
return self._ping_queue.start()
|
return self._ping_queue.start()
|
||||||
|
|
||||||
def datagramReceived(self, datagram, address):
|
def datagramReceived(self, datagram, address):
|
||||||
|
|
Loading…
Reference in a new issue