added option to disable plaintext blocks

master
Kevin Froman 2019-09-27 20:38:47 -05:00
parent 71c9337ab7
commit 60f0ef0fef
7 changed files with 43 additions and 25 deletions

View File

@ -64,6 +64,7 @@ def insert_block(data: Union[str, bytes], header: str ='txt',
if encryptType in ('asym', 'sym'): if encryptType in ('asym', 'sym'):
metadata['encryptType'] = encryptType metadata['encryptType'] = encryptType
else: 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): if not encryptType in ('', None):
raise onionrexceptions.InvalidMetadata('encryptType must be asym or sym, or blank') raise onionrexceptions.InvalidMetadata('encryptType must be asym or sym, or blank')

View File

@ -39,5 +39,4 @@ def set_data(data)->str:
else: else:
raise onionrexceptions.DataExists("Data is already set for " + dataHash) raise onionrexceptions.DataExists("Data is already set for " + dataHash)
print(dataHash, nonce_hash)
return dataHash return dataHash

View File

@ -73,6 +73,8 @@ def validate_metadata(metadata, block_data) -> bool:
elif i == 'encryptType': elif i == 'encryptType':
try: try:
if not metadata[i] in ('asym', 'sym', ''): raise ValueError if not metadata[i] in ('asym', 'sym', ''): raise ValueError
if not config.get('general.store_plaintext_blocks', True):
break
except ValueError: except ValueError:
logger.warn('Invalid encryption mode') logger.warn('Invalid encryption mode')
break break

View File

@ -13,28 +13,8 @@
"max_block_age": 2678400, "max_block_age": 2678400,
"public_key": "", "public_key": "",
"random_bind_ip": false, "random_bind_ip": false,
"use_bootstrap_list": true "use_bootstrap_list": true,
}, "store_plaintext_blocks": true
"www": {
"public": {
"run": true,
"path": "static-data/www/public/"
},
"private": {
"run": true,
"path": "static-data/www/private/"
},
"ui": {
"run": true,
"private": true
}
},
"client": {
}, },
"plugins": { "plugins": {

View File

@ -44,7 +44,7 @@ fetch('/flow/version', {
headers: { headers: {
"token": webpass "token": webpass
}}) }})
.then((resp) => resp.text()) // Transform the data into json .then((resp) => resp.text())
.then(function(data) { .then(function(data) {
document.getElementById('circlesVersion').innerText = data document.getElementById('circlesVersion').innerText = data
}) })
@ -218,4 +218,4 @@ newPostForm.onsubmit = function(){
setTimeout(function(){getBlocks()}, 500) setTimeout(function(){getBlocks()}, 500)
}) })
return false return false
} }

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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"
})
}
})

View File

@ -21,6 +21,7 @@
<script defer src='/shared/navbar.js'></script> <script defer src='/shared/navbar.js'></script>
<script defer src="/shared/useridenticons.js"></script> <script defer src="/shared/useridenticons.js"></script>
<script defer src='/shared/misc.js'></script> <script defer src='/shared/misc.js'></script>
<script defer src="detect-plaintext-storage.js"></script>
<script defer src='sethumanreadable.js'></script> <script defer src='sethumanreadable.js'></script>
<script defer src='board.js'></script> <script defer src='board.js'></script>
<script defer src='autorefresh.js'></script> <script defer src='autorefresh.js'></script>