KISS startup delete plaintext blocks based on config, no blacklist
parent
f78809fa2a
commit
29421d678e
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
from . import plaintextdelete
|
||||
delete_plaintext = plaintextdelete.delete_plaintext
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
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)
|
Loading…
Reference in New Issue