improved expiry
This commit is contained in:
parent
d3c5fe3a5a
commit
726bbe61ac
@ -149,6 +149,11 @@ class OnionrCommunicatorDaemon:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
logger.info('Goodbye.')
|
logger.info('Goodbye.')
|
||||||
|
try:
|
||||||
|
self.service_greenlets
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
for server in self.service_greenlets:
|
for server in self.service_greenlets:
|
||||||
server.stop()
|
server.stop()
|
||||||
self._core._utils.localCommand('shutdown') # shutdown the api
|
self._core._utils.localCommand('shutdown') # shutdown the api
|
||||||
|
@ -22,3 +22,4 @@ class OnionrValues:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.passwordLength = 20
|
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
|
@ -25,7 +25,7 @@ import onionrexceptions
|
|||||||
from onionr import API_VERSION
|
from onionr import API_VERSION
|
||||||
import onionrevents
|
import onionrevents
|
||||||
import storagecounter
|
import storagecounter
|
||||||
from etc import pgpwords
|
from etc import pgpwords, onionrvalues
|
||||||
from onionrusers import onionrusers
|
from onionrusers import onionrusers
|
||||||
if sys.version_info < (3, 6):
|
if sys.version_info < (3, 6):
|
||||||
try:
|
try:
|
||||||
@ -179,8 +179,8 @@ class OnionrUtils:
|
|||||||
expireTime = myBlock.getHeader('expire')
|
expireTime = myBlock.getHeader('expire')
|
||||||
assert len(str(int(expireTime))) < 20 # test that expire time is an integer of sane length (for epoch)
|
assert len(str(int(expireTime))) < 20 # test that expire time is an integer of sane length (for epoch)
|
||||||
except (AssertionError, ValueError, TypeError) as e:
|
except (AssertionError, ValueError, TypeError) as e:
|
||||||
pass
|
expireTime = onionrvalues.OnionrValues().default_expire
|
||||||
else:
|
finally:
|
||||||
self._core.updateBlockInfo(blockHash, 'expire', expireTime)
|
self._core.updateBlockInfo(blockHash, 'expire', expireTime)
|
||||||
if not blockType is None:
|
if not blockType is None:
|
||||||
self._core.updateBlockInfo(blockHash, 'dataType', blockType)
|
self._core.updateBlockInfo(blockHash, 'dataType', blockType)
|
||||||
@ -253,7 +253,7 @@ class OnionrUtils:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Validate metadata dict for invalid keys to sizes that are too large
|
# 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:
|
if type(metadata) is dict:
|
||||||
for i in metadata:
|
for i in metadata:
|
||||||
try:
|
try:
|
||||||
@ -285,7 +285,7 @@ class OnionrUtils:
|
|||||||
try:
|
try:
|
||||||
assert int(metadata[i]) > self.getEpoch()
|
assert int(metadata[i]) > self.getEpoch()
|
||||||
except AssertionError:
|
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
|
break
|
||||||
elif i == 'encryptType':
|
elif i == 'encryptType':
|
||||||
try:
|
try:
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
huei7fugyuesltkf3yzj27an36skz2f2u55g7ganyaq6yjhauwicwfyd.onion
|
@ -19,7 +19,7 @@
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
# Imports some useful libraries
|
# Imports some useful libraries
|
||||||
import locale
|
import locale, sys, os
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user