added option to disable plaintext blocks
This commit is contained in:
parent
71c9337ab7
commit
60f0ef0fef
7 changed files with 43 additions and 25 deletions
|
@ -64,6 +64,7 @@ def insert_block(data: Union[str, bytes], header: str ='txt',
|
|||
if encryptType in ('asym', 'sym'):
|
||||
metadata['encryptType'] = encryptType
|
||||
else:
|
||||
if not config.get('general.store_plaintext_blocks', True): raise onionrexceptions.InvalidMetadata("Plaintext blocks are disabled, yet a plaintext block was being inserted")
|
||||
if not encryptType in ('', None):
|
||||
raise onionrexceptions.InvalidMetadata('encryptType must be asym or sym, or blank')
|
||||
|
||||
|
|
|
@ -39,5 +39,4 @@ def set_data(data)->str:
|
|||
else:
|
||||
raise onionrexceptions.DataExists("Data is already set for " + dataHash)
|
||||
|
||||
print(dataHash, nonce_hash)
|
||||
return dataHash
|
||||
|
|
|
@ -73,6 +73,8 @@ def validate_metadata(metadata, block_data) -> bool:
|
|||
elif i == 'encryptType':
|
||||
try:
|
||||
if not metadata[i] in ('asym', 'sym', ''): raise ValueError
|
||||
if not config.get('general.store_plaintext_blocks', True):
|
||||
break
|
||||
except ValueError:
|
||||
logger.warn('Invalid encryption mode')
|
||||
break
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue