From 8e5152a14e9bf9fcd3b419d5132923c20622ddd7 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 2 Feb 2020 02:48:23 -0600 Subject: [PATCH] added support to wipe data directory on exit --- requirements.in | 1 + requirements.txt | 3 + src/__init__.py | 7 ++ static-data/default_config.json | 117 ++++++++++++++------------------ tests/runtime-result.txt | 2 +- 5 files changed, 63 insertions(+), 67 deletions(-) diff --git a/requirements.in b/requirements.in index a5fd4139..db6f029d 100644 --- a/requirements.in +++ b/requirements.in @@ -12,3 +12,4 @@ jinja2==2.11.1 toomanyobjs==1.1.0 niceware==0.2.1 psutil==5.6.7 +filenuke==0.0.0 diff --git a/requirements.txt b/requirements.txt index 4bcf413c..73e3ca2e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -48,6 +48,9 @@ click==7.0 \ # via flask deadsimplekv==0.2.0 \ --hash=sha256:81405408a4d23cc94ac359f9570e0ff198b67e5a93e3ae32eca85e3b62252f38 +filenuke==0.0.0 \ + --hash=sha256:147011c0125121469cae0a8a7f4df399f470e54aa29a08f2d2c099bf0118dcee \ + --hash=sha256:c55535dcecfdb27c5f4ce664d46e115950b5429763b5db75c198053646177f8f flask==1.1.1 \ --hash=sha256:13f9f196f330c7c2c5d7a5cf91af894110ca0215ac051b5844701f2bfd934d52 \ --hash=sha256:45eb5a6fd193d6cf7e0cf5d8a5b31f83d5faae0293695626f539a823e93b13f6 diff --git a/src/__init__.py b/src/__init__.py index 54f7e926..a16bd886 100755 --- a/src/__init__.py +++ b/src/__init__.py @@ -63,6 +63,8 @@ from onionrblocks.deleteplaintext import delete_plaintext_no_blacklist # noqa setup.setup_config() import config # noqa +import filenuke +from utils import identifyhome if config.get('advanced.security_auditing', True): try: @@ -84,6 +86,11 @@ def onionr_main(): if ran_as_script: onionr_main() + # Wipe Onionr data directory if security level calls for it + config.reload() + if config.get('general.security_level', 1) >= 2: + filenuke.nuke.clean_tree(identifyhome.identify_home()) + # Cleanup standard out/err because Python refuses to do it itsself try: sys.stderr.close() diff --git a/static-data/default_config.json b/static-data/default_config.json index 7b2589bb..58a67151 100755 --- a/static-data/default_config.json +++ b/static-data/default_config.json @@ -1,85 +1,70 @@ { + "allocations": { + "blockCache": 5000000, + "blockCacheTotal": 50000000, + "disk": 100000000, + "net_total": 1000000000 + }, "general": { - "dev_mode": false, "announce_node": true, + "dev_mode": false, "display_header": false, - "minimum_block_pow": 4, - "minimum_send_pow": 4, - "use_subprocess_pow_if_possible": true, - "socket_servers": false, - "security_level": 0, + "general.random_bind_ip": false, "hide_created_blocks": true, "insert_deniable_blocks": true, "max_block_age": 2678400, + "minimum_block_pow": 4, + "minimum_send_pow": 4, "public_key": "", "random_bind_ip": true, - "use_bootstrap_list": true, + "security_level": 0, + "show_notifications": true, + "socket_servers": false, "store_plaintext_blocks": true, - "show_notifications": true + "use_bootstrap_list": true, + "use_subprocess_pow_if_possible": true }, - - "transports": { - "tor": true, - "manual_disk": true - }, - - "ui": { - "theme": "dark" - }, - - "plugins": { - "enabled": { - - }, - - "disabled": { - - } - }, - "log": { - "verbosity": "default", - + "console": { + "color": true, + "output": true + }, "file": { "output": true }, - - "console": { - "output": true, - "color": true - } + "verbosity": "default" }, - - "tor": { - "v3onions": true, - "use_bridge": false, - "bridge_ip": "", - "bridge_fingerprint": "", - "use_existing_tor": false, - "existing_control_port": 0, - "existing_control_password": "", - "existing_socks_port": 0 - }, - - "allocations": { - "disk": 100000000, - "net_total": 1000000000, - "blockCache": 5000000, - "blockCacheTotal": 50000000 - }, - - "peers": { - "minimum_score": -100, - "max_stored_peers": 5000, - "max_connect": 1000 - }, - - "timers": { - "lookupBlocks": 25, - "getBlocks": 10 - }, - "onboarding": { "done": true + }, + "peers": { + "max_connect": 1000, + "max_stored_peers": 5000, + "minimum_score": -100 + }, + "plugins": { + "disabled": {}, + "enabled": {} + }, + "timers": { + "getBlocks": 10, + "lookupBlocks": 25 + }, + "tor": { + "bridge_fingerprint": "", + "bridge_ip": "", + "existing_control_password": "", + "existing_control_port": 0, + "existing_socks_port": 0, + "use_bridge": false, + "use_existing_tor": false, + "v3onions": true + }, + "transports": { + "manual_disk": true, + "tor": true + }, + "ui": { + "theme": "dark" } -} +} \ No newline at end of file diff --git a/tests/runtime-result.txt b/tests/runtime-result.txt index afcefc8b..5b70d092 100644 --- a/tests/runtime-result.txt +++ b/tests/runtime-result.txt @@ -1 +1 @@ -1580533017 \ No newline at end of file +1580633234 \ No newline at end of file