From 60f0ef0fef1612eb5065ee60b7dbf838b55f59d5 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 27 Sep 2019 20:38:47 -0500 Subject: [PATCH] added option to disable plaintext blocks --- onionr/onionrblocks/insert.py | 1 + onionr/onionrstorage/setdata.py | 1 - onionr/onionrutils/validatemetadata.py | 2 ++ static-data/default_config.json | 24 ++----------- static-data/www/board/board.js | 4 +-- .../www/board/detect-plaintext-storage.js | 35 +++++++++++++++++++ static-data/www/board/index.html | 1 + 7 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 static-data/www/board/detect-plaintext-storage.js diff --git a/onionr/onionrblocks/insert.py b/onionr/onionrblocks/insert.py index 80561988..f836c28a 100644 --- a/onionr/onionrblocks/insert.py +++ b/onionr/onionrblocks/insert.py @@ -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') diff --git a/onionr/onionrstorage/setdata.py b/onionr/onionrstorage/setdata.py index 0ac5d21b..5c949b96 100644 --- a/onionr/onionrstorage/setdata.py +++ b/onionr/onionrstorage/setdata.py @@ -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 diff --git a/onionr/onionrutils/validatemetadata.py b/onionr/onionrutils/validatemetadata.py index f4496076..916b3416 100644 --- a/onionr/onionrutils/validatemetadata.py +++ b/onionr/onionrutils/validatemetadata.py @@ -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 diff --git a/static-data/default_config.json b/static-data/default_config.json index fb1ea790..31dda36c 100755 --- a/static-data/default_config.json +++ b/static-data/default_config.json @@ -13,28 +13,8 @@ "max_block_age": 2678400, "public_key": "", "random_bind_ip": false, - "use_bootstrap_list": true - }, - - "www": { - "public": { - "run": true, - "path": "static-data/www/public/" - }, - - "private": { - "run": true, - "path": "static-data/www/private/" - }, - - "ui": { - "run": true, - "private": true - } - }, - - "client": { - + "use_bootstrap_list": true, + "store_plaintext_blocks": true }, "plugins": { diff --git a/static-data/www/board/board.js b/static-data/www/board/board.js index c445e2fa..971fc3f3 100755 --- a/static-data/www/board/board.js +++ b/static-data/www/board/board.js @@ -44,7 +44,7 @@ fetch('/flow/version', { headers: { "token": webpass }}) -.then((resp) => resp.text()) // Transform the data into json +.then((resp) => resp.text()) .then(function(data) { document.getElementById('circlesVersion').innerText = data }) @@ -218,4 +218,4 @@ newPostForm.onsubmit = function(){ setTimeout(function(){getBlocks()}, 500) }) return false -} \ No newline at end of file +} diff --git a/static-data/www/board/detect-plaintext-storage.js b/static-data/www/board/detect-plaintext-storage.js new file mode 100644 index 00000000..de16f57f --- /dev/null +++ b/static-data/www/board/detect-plaintext-storage.js @@ -0,0 +1,35 @@ +/* + Onionr - Private P2P Communication + + detect for Circles if plaintext insert/storage is enabled + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +plaintext_enabled = null + +fetch('/config/get/general.store_plaintext_blocks', { + method: 'GET', + headers: { + "token": webpass + }}) +.then((resp) => resp.text()) +.then(function(data) { + plaintext_enabled = true + if (data == "false"){ + plaintext_enabled = false + PNotify.error({ + text: "Plaintext storage is disabled. You will not be able to see new posts or make posts yourself" + }) + } +}) diff --git a/static-data/www/board/index.html b/static-data/www/board/index.html index beb47def..961fe615 100755 --- a/static-data/www/board/index.html +++ b/static-data/www/board/index.html @@ -21,6 +21,7 @@ +