diff --git a/src/__init__.py b/src/__init__.py index 84cf10a2..54f7e926 100755 --- a/src/__init__.py +++ b/src/__init__.py @@ -58,6 +58,7 @@ createdirs.create_dirs() import bigbrother # noqa from onionrcommands import parser # noqa from onionrplugins import onionrevents as events # noqa +from onionrblocks.deleteplaintext import delete_plaintext_no_blacklist # noqa setup.setup_config() @@ -69,6 +70,9 @@ if config.get('advanced.security_auditing', True): except onionrexceptions.PythonVersion: pass +if not config.get('general.store_plaintext_blocks', True): + delete_plaintext_no_blacklist() + setup.setup_default_plugins() diff --git a/src/config/__init__.py b/src/config/__init__.py index 02140186..8f2ede60 100755 --- a/src/config/__init__.py +++ b/src/config/__init__.py @@ -48,10 +48,6 @@ def get(key, default = None, save = False): def set(key, value = None, savefile = False): """Sets the key in configuration to `value`""" - from . import observers - config_set_observers = { - 'general.store_plaintext_blocks': [observers.delete_plaintext] - } global _config @@ -65,11 +61,6 @@ def set(key, value = None, savefile = False): if (not item in data) or (not type(data[item]) == dict): data[item] = dict() data = data[item] - try: - for observer in config_set_observers[whole_key]: - observer(value) - except KeyError: - pass if value is None: del data[last] diff --git a/src/config/observers/__init__.py b/src/config/observers/__init__.py deleted file mode 100644 index dbf4e04d..00000000 --- a/src/config/observers/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import plaintextdelete -delete_plaintext = plaintextdelete.delete_plaintext diff --git a/src/config/observers/plaintextdelete.py b/src/config/observers/plaintextdelete.py deleted file mode 100644 index f3b384c8..00000000 --- a/src/config/observers/plaintextdelete.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Onionr - Private P2P Communication. - -Delete plaintext blocks, used when plaintext is disabled in config -""" -from onionrblocks import onionrblockapi -from coredb import blockmetadb -from onionrstorage.removeblock import remove_block -import onionrstorage -""" - 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 . -""" - - -def delete_plaintext(dont_delete: bool): - """Delete, but do not blacklist, plaintext blocks.""" - if dont_delete: - return - - block_list = blockmetadb.get_block_list() - - for block in block_list: - block = onionrblockapi.Block(hash=block) - if not block.isEncrypted: - remove_block(block.hash) - onionrstorage.deleteBlock(block.hash)