improved expiry

This commit is contained in:
Kevin Froman 2019-03-27 13:55:43 -05:00
parent d3c5fe3a5a
commit 726bbe61ac
5 changed files with 16 additions and 9 deletions

View File

@ -149,8 +149,13 @@ class OnionrCommunicatorDaemon:
pass
logger.info('Goodbye.')
for server in self.service_greenlets:
server.stop()
try:
self.service_greenlets
except AttributeError:
pass
else:
for server in self.service_greenlets:
server.stop()
self._core._utils.localCommand('shutdown') # shutdown the api
time.sleep(0.5)

View File

@ -21,4 +21,5 @@
class OnionrValues:
def __init__(self):
self.passwordLength = 20
self.blockMetadataLengths = {'meta': 1000, 'sig': 200, 'signer': 200, 'time': 10, 'powRandomToken': 1000, 'encryptType': 4, 'expire': 14} #TODO properly refine values to minimum needed
self.blockMetadataLengths = {'meta': 1000, 'sig': 200, 'signer': 200, 'time': 10, 'powRandomToken': 1000, 'encryptType': 4, 'expire': 14} #TODO properly refine values to minimum needed
self.default_expire = 2678400

View File

@ -25,7 +25,7 @@ import onionrexceptions
from onionr import API_VERSION
import onionrevents
import storagecounter
from etc import pgpwords
from etc import pgpwords, onionrvalues
from onionrusers import onionrusers
if sys.version_info < (3, 6):
try:
@ -179,8 +179,8 @@ class OnionrUtils:
expireTime = myBlock.getHeader('expire')
assert len(str(int(expireTime))) < 20 # test that expire time is an integer of sane length (for epoch)
except (AssertionError, ValueError, TypeError) as e:
pass
else:
expireTime = onionrvalues.OnionrValues().default_expire
finally:
self._core.updateBlockInfo(blockHash, 'expire', expireTime)
if not blockType is None:
self._core.updateBlockInfo(blockHash, 'dataType', blockType)
@ -253,7 +253,7 @@ class OnionrUtils:
pass
# Validate metadata dict for invalid keys to sizes that are too large
maxAge = config.get("general.max_block_age", 2678400)
maxAge = config.get("general.max_block_age", onionrvalues.OnionrValues().default_expire)
if type(metadata) is dict:
for i in metadata:
try:
@ -285,7 +285,7 @@ class OnionrUtils:
try:
assert int(metadata[i]) > self.getEpoch()
except AssertionError:
logger.warn('Block is expired: %s greater than %s' % (metadata[i], self.getEpoch()))
logger.warn('Block is expired: %s less than %s' % (metadata[i], self.getEpoch()))
break
elif i == 'encryptType':
try:

View File

@ -0,0 +1 @@
huei7fugyuesltkf3yzj27an36skz2f2u55g7ganyaq6yjhauwicwfyd.onion

View File

@ -19,7 +19,7 @@
'''
# Imports some useful libraries
import locale
import locale, sys, os
locale.setlocale(locale.LC_ALL, '')