From 504ef3a49a9fe79bc34a1413bb6a62018d3308e1 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 17 Jan 2021 00:40:04 +0000 Subject: [PATCH] work on removing communicator --- requirements.in | 3 +- requirements.txt | 78 +++++++++-------- src/apiservers/private/__init__.py | 22 ++--- src/blockio/__init__.py | 18 ++++ src/communicator/__init__.py | 85 +------------------ .../daemonlaunch/spawndaemonthreads.py | 55 ++++++++++++ src/safedb/__init__.py | 2 +- 7 files changed, 132 insertions(+), 131 deletions(-) diff --git a/requirements.in b/requirements.in index a4809cdf..ca6fd48a 100644 --- a/requirements.in +++ b/requirements.in @@ -14,4 +14,5 @@ psutil==5.8.0 filenuke==0.0.0 watchdog==1.0.2 ujson==4.0.1 -cffi==1.14.4 \ No newline at end of file +cffi==1.14.4 +onionrblocks==0.0.0 diff --git a/requirements.txt b/requirements.txt index 951e212a..447b8fbe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,11 +2,11 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile --generate-hashes requirements.in +# pip-compile --generate-hashes --output-file=requirements.txt requirements.in # certifi==2018.11.29 \ --hash=sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7 \ - --hash=sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033 \ + --hash=sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033 # via requests cffi==1.14.4 \ --hash=sha256:00a1ba5e2e95684448de9b89888ccd02c98d512064b4cb987d48f4b40aa0421e \ @@ -44,27 +44,29 @@ cffi==1.14.4 \ --hash=sha256:ec80dc47f54e6e9a78181ce05feb71a0353854cc26999db963695f950b5fb375 \ --hash=sha256:f032b34669220030f905152045dfa27741ce1a6db3324a5bc0b96b6c7420c87b \ --hash=sha256:f60567825f791c6f8a592f3c6e3bd93dd2934e3f9dac189308426bd76b00ef3b \ - --hash=sha256:f803eaa94c2fcda012c047e62bc7a51b0bdabda1cad7a92a522694ea2d76e49f \ - # via -r requirements.in, pynacl + --hash=sha256:f803eaa94c2fcda012c047e62bc7a51b0bdabda1cad7a92a522694ea2d76e49f + # via + # -r requirements.in + # pynacl chardet==3.0.4 \ --hash=sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae \ - --hash=sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691 \ + --hash=sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691 # via requests click==7.0 \ --hash=sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13 \ - --hash=sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7 \ + --hash=sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7 # via flask deadsimplekv==0.3.2 \ --hash=sha256:a725f4a9d1156ebb66b7535ac150006881e0365b715e34e3709214827b8b0c4c \ - --hash=sha256:df00262d26c3dcfecb710425a7413059480d8cf026216042d7cbffb8514818b2 \ + --hash=sha256:df00262d26c3dcfecb710425a7413059480d8cf026216042d7cbffb8514818b2 # via -r requirements.in filenuke==0.0.0 \ --hash=sha256:147011c0125121469cae0a8a7f4df399f470e54aa29a08f2d2c099bf0118dcee \ - --hash=sha256:c55535dcecfdb27c5f4ce664d46e115950b5429763b5db75c198053646177f8f \ + --hash=sha256:c55535dcecfdb27c5f4ce664d46e115950b5429763b5db75c198053646177f8f # via -r requirements.in flask==1.1.2 \ --hash=sha256:4efa1ae2d7c9865af48986de8aeb8504bf32c7f3d6fdc9353d34b21f4b127060 \ - --hash=sha256:8a4fdd8936eba2512e9c85df320a37e694c93945b33ef33c89946a340a238557 \ + --hash=sha256:8a4fdd8936eba2512e9c85df320a37e694c93945b33ef33c89946a340a238557 # via -r requirements.in gevent==20.12.1 \ --hash=sha256:0f9fa230c5878704b9e286ad5038bac3b70d293bf10e9efa8b2ae1d7d80e7e08 \ @@ -90,7 +92,7 @@ gevent==20.12.1 \ --hash=sha256:f020bfb34d57caa10029111be776524c378a4aac8417bc6fb1154b05e00fc220 \ --hash=sha256:f3faf1834464f1b0731aa6346cd9f41029fa9e208d6ecbce4a736c19562c86aa \ --hash=sha256:f857adbe1bf41e620d86173a53100f4ec328eba3089069a4815b3d9f4229dee8 \ - --hash=sha256:ffa1be13963db6aa55c50d2fd4a656c82f53a03a47e37aaa69e79a488123538d \ + --hash=sha256:ffa1be13963db6aa55c50d2fd4a656c82f53a03a47e37aaa69e79a488123538d # via -r requirements.in greenlet==0.4.17 \ --hash=sha256:1023d7b43ca11264ab7052cb09f5635d4afdb43df55e0854498fc63070a0b206 \ @@ -110,19 +112,19 @@ greenlet==0.4.17 \ --hash=sha256:ccd62f09f90b2730150d82f2f2ffc34d73c6ce7eac234aed04d15dc8a3023994 \ --hash=sha256:d3436110ca66fe3981031cc6aff8cc7a40d8411d173dde73ddaa5b8445385e2d \ --hash=sha256:e495096e3e2e8f7192afb6aaeba19babc4fb2bdf543d7b7fed59e00c1df7f170 \ - --hash=sha256:e66a824f44892bc4ec66c58601a413419cafa9cec895e63d8da889c8a1a4fa4a \ + --hash=sha256:e66a824f44892bc4ec66c58601a413419cafa9cec895e63d8da889c8a1a4fa4a # via gevent idna==2.7 \ --hash=sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e \ - --hash=sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16 \ + --hash=sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16 # via requests itsdangerous==1.1.0 \ --hash=sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19 \ - --hash=sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749 \ + --hash=sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749 # via flask jinja2==2.11.1 \ --hash=sha256:93187ffbc7808079673ef52771baa950426fd664d3aad1d0fa3e95644360e250 \ - --hash=sha256:b0eaf100007721b5c16c1fc1eecb87409464edc10469ddc9a22a27a99123be49 \ + --hash=sha256:b0eaf100007721b5c16c1fc1eecb87409464edc10469ddc9a22a27a99123be49 # via flask markupsafe==1.1.1 \ --hash=sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473 \ @@ -157,11 +159,15 @@ markupsafe==1.1.1 \ --hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \ --hash=sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2 \ --hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \ - --hash=sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be \ + --hash=sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be # via jinja2 niceware==0.2.1 \ --hash=sha256:0f8b192f2a1e800e068474f6e208be9c7e2857664b33a96f4045340de4e5c69c \ - --hash=sha256:cf2dc0e1567d36d067c61b32fed0f1b9c4534ed511f9eeead4ba548d03b5c9eb \ + --hash=sha256:cf2dc0e1567d36d067c61b32fed0f1b9c4534ed511f9eeead4ba548d03b5c9eb + # via -r requirements.in +onionrblocks==0.0.0 \ + --hash=sha256:0ad300c1f033b474f8c93ffc89f59ad4075073b45798f0992fdc6f27f4874db5 \ + --hash=sha256:8bab88b62e52b2c2a77589ca6e106483508f1d15c78928f343c9cf030403dc09 # via -r requirements.in psutil==5.8.0 \ --hash=sha256:0066a82f7b1b37d334e68697faba68e5ad5e858279fd6351c8ca6024e8d6ba64 \ @@ -191,10 +197,10 @@ psutil==5.8.0 \ --hash=sha256:ea313bb02e5e25224e518e4352af4bf5e062755160f77e4b1767dd5ccb65f876 \ --hash=sha256:ea372bcc129394485824ae3e3ddabe67dc0b118d262c568b4d2602a7070afdb0 \ --hash=sha256:f4634b033faf0d968bb9220dd1c793b897ab7f1189956e1aa9eae752527127d3 \ - --hash=sha256:fcc01e900c1d7bee2a37e5d6e4f9194760a93597c97fee89c4ae51701de03563 \ + --hash=sha256:fcc01e900c1d7bee2a37e5d6e4f9194760a93597c97fee89c4ae51701de03563 # via -r requirements.in pycparser==2.19 \ - --hash=sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3 \ + --hash=sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3 # via cffi pynacl==1.4.0 \ --hash=sha256:06cbb4d9b2c4bd3c8dc0d267416aaed79906e7b33f114ddbf0911969794b1cc4 \ @@ -212,30 +218,32 @@ pynacl==1.4.0 \ --hash=sha256:cd401ccbc2a249a47a3a1724c2918fcd04be1f7b54eb2a5a71ff915db0ac51c6 \ --hash=sha256:d452a6746f0a7e11121e64625109bc4468fc3100452817001dbe018bb8b08514 \ --hash=sha256:ea6841bc3a76fa4942ce00f3bda7d436fda21e2d91602b9e21b7ca9ecab8f3ff \ - --hash=sha256:f8851ab9041756003119368c1e6cd0b9c631f46d686b3904b18c0139f4419f80 \ + --hash=sha256:f8851ab9041756003119368c1e6cd0b9c631f46d686b3904b18c0139f4419f80 # via -r requirements.in pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ --hash=sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5 \ - --hash=sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0 \ + --hash=sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0 # via -r requirements.in requests==2.25.1 \ --hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \ - --hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e \ - # via -r requirements.in, streamedrequests + --hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e + # via + # -r requirements.in + # streamedrequests six==1.12.0 \ --hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c \ - --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73 \ + --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73 # via pynacl stem==1.8.0 \ - --hash=sha256:a0b48ea6224e95f22aa34c0bc3415f0eb4667ddeae3dfb5e32a6920c185568c2 \ + --hash=sha256:a0b48ea6224e95f22aa34c0bc3415f0eb4667ddeae3dfb5e32a6920c185568c2 # via -r requirements.in streamedrequests==1.0.3 \ --hash=sha256:4388ffc0ee94dda719dafc4324b8ddd108cb2231ec59871de79e2592bf4eef0a \ - --hash=sha256:ee68417a1522e75c35b1b2d5f3b6f7e76a3a1a6c0ef5e0c573d08307910079d8 \ + --hash=sha256:ee68417a1522e75c35b1b2d5f3b6f7e76a3a1a6c0ef5e0c573d08307910079d8 # via -r requirements.in toomanyobjs==1.1.0 \ - --hash=sha256:99e27468f9dad19127be9e2fb086b42acd69aed9ad7e63cef74d6e4389be0534 \ + --hash=sha256:99e27468f9dad19127be9e2fb086b42acd69aed9ad7e63cef74d6e4389be0534 # via -r requirements.in ujson==4.0.1 \ --hash=sha256:078808c385036cba73cad96f498310c61e9b5ae5ac9ea01e7c3996ece544b556 \ @@ -258,16 +266,18 @@ ujson==4.0.1 \ --hash=sha256:c354c1617b0a4378b6279d0cd511b769500cf3fa7c42e8e004cbbbb6b4c2a875 \ --hash=sha256:c604024bd853b5df6be7d933e934da8dd139e6159564db7c55b92a9937678093 \ --hash=sha256:e7ab24942b2d57920d75b817b8eead293026db003247e26f99506bdad86c61b4 \ - --hash=sha256:f8a60928737a9a47e692fcd661ef2b5d75ba22c7c930025bd95e338f2a6e15bc \ + --hash=sha256:f8a60928737a9a47e692fcd661ef2b5d75ba22c7c930025bd95e338f2a6e15bc # via -r requirements.in unpaddedbase32==0.2.0 \ --hash=sha256:4aacee75f8fd6c8cf129842ecba45ca59c11bfb13dae19d86f32b48fa3715403 \ - --hash=sha256:b7b780c31d27d55e66abf6c221216a35690ee8892c2daacff7f2528e229bd9c3 \ + --hash=sha256:b7b780c31d27d55e66abf6c221216a35690ee8892c2daacff7f2528e229bd9c3 # via -r requirements.in urllib3==1.25.11 \ --hash=sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2 \ - --hash=sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e \ - # via -r requirements.in, requests + --hash=sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e + # via + # -r requirements.in + # requests watchdog==1.0.2 \ --hash=sha256:016b01495b9c55b5d4126ed8ae75d93ea0d99377084107c33162df52887cee18 \ --hash=sha256:101532b8db506559e52a9b5d75a308729b3f68264d930670e6155c976d0e52a0 \ @@ -285,15 +295,15 @@ watchdog==1.0.2 \ --hash=sha256:e7c73edef48f4ceeebb987317a67e0080e5c9228601ff67b3c4062fa020403c7 \ --hash=sha256:ee21aeebe6b3e51e4ba64564c94cee8dbe7438b9cb60f0bb350c4fa70d1b52c2 \ --hash=sha256:f1d0e878fd69129d0d68b87cee5d9543f20d8018e82998efb79f7e412d42154a \ - --hash=sha256:f84146f7864339c8addf2c2b9903271df21d18d2c721e9a77f779493234a82b5 \ + --hash=sha256:f84146f7864339c8addf2c2b9903271df21d18d2c721e9a77f779493234a82b5 # via -r requirements.in werkzeug==0.15.5 \ --hash=sha256:87ae4e5b5366da2347eb3116c0e6c681a0e939a33b2805e2c0cbd282664932c4 \ - --hash=sha256:a13b74dd3c45f758d4ebdb224be8f1ab8ef58b3c0ffc1783a8c7d9f4f50227e6 \ + --hash=sha256:a13b74dd3c45f758d4ebdb224be8f1ab8ef58b3c0ffc1783a8c7d9f4f50227e6 # via flask zope.event==4.4 \ --hash=sha256:69c27debad9bdacd9ce9b735dad382142281ac770c4a432b533d6d65c4614bcf \ - --hash=sha256:d8e97d165fd5a0997b45f5303ae11ea3338becfe68c401dd88ffd2113fe5cae7 \ + --hash=sha256:d8e97d165fd5a0997b45f5303ae11ea3338becfe68c401dd88ffd2113fe5cae7 # via gevent zope.interface==5.1.0 \ --hash=sha256:0103cba5ed09f27d2e3de7e48bb320338592e2fabc5ce1432cf33808eb2dfd8b \ @@ -335,7 +345,7 @@ zope.interface==5.1.0 \ --hash=sha256:ef739fe89e7f43fb6494a43b1878a36273e5924869ba1d866f752c5812ae8d58 \ --hash=sha256:f40db0e02a8157d2b90857c24d89b6310f9b6c3642369852cdc3b5ac49b92afc \ --hash=sha256:f68bf937f113b88c866d090fea0bc52a098695173fc613b055a17ff0cf9683b6 \ - --hash=sha256:fb55c182a3f7b84c1a2d6de5fa7b1a05d4660d866b91dbf8d74549c57a1499e8 \ + --hash=sha256:fb55c182a3f7b84c1a2d6de5fa7b1a05d4660d866b91dbf8d74549c57a1499e8 # via gevent # WARNING: The following packages were not pinned, but pip requires them to be diff --git a/src/apiservers/private/__init__.py b/src/apiservers/private/__init__.py index 657c30b7..8c0571a4 100644 --- a/src/apiservers/private/__init__.py +++ b/src/apiservers/private/__init__.py @@ -18,18 +18,18 @@ from . import register_private_blueprints import config from .. import public """ - 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 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. +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 . +You should have received a copy of the GNU General Public License +along with this program. If not, see . """ @@ -50,7 +50,7 @@ class PrivateAPI: self.startTime = epoch.get_epoch() app = flask.Flask(__name__) - + bind_port = int(config.get('client.client.port', 59496)) self.bindPort = bind_port diff --git a/src/blockio/__init__.py b/src/blockio/__init__.py index e69de29b..72940344 100644 --- a/src/blockio/__init__.py +++ b/src/blockio/__init__.py @@ -0,0 +1,18 @@ +"""Onionr - Private P2P Communication. + +Wrap safedb for storing and fetching blocks +""" +""" +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 . +""" \ No newline at end of file diff --git a/src/communicator/__init__.py b/src/communicator/__init__.py index 9a84cc8b..43122111 100755 --- a/src/communicator/__init__.py +++ b/src/communicator/__init__.py @@ -8,19 +8,9 @@ import time import config import logger -import onionrpeers import onionrplugins as plugins -from . import onlinepeers -from . import uploadqueue -from communicatorutils import downloadblocks -from communicatorutils import lookupblocks -from communicatorutils import lookupadders -from communicatorutils import connectnewpeers from communicatorutils import uploadblocks -from communicatorutils import announcenode, deniableinserts -from communicatorutils import cooldownpeer -from communicatorutils import housekeeping -from communicatorutils import netcheck +from . import uploadqueue from onionrthreads import add_onionr_thread from onionrcommands.openwebinterface import get_url from netcontroller import NetController @@ -80,61 +70,6 @@ class OnionrCommunicatorDaemon: # extends our upload list and saves our list when Onionr exits uploadqueue.UploadQueue(self) - add_onionr_thread( - lookupblocks.lookup_blocks_from_communicator, - [self.shared_state], 25, 3) - - add_onionr_thread( - downloadblocks.download_blocks_from_communicator, - [self.shared_state], - config.get('timers.getBlocks', 10), 1) - - add_onionr_thread(onlinepeers.clear_offline_peer, [self.kv], 58) - - add_onionr_thread( - housekeeping.clean_old_blocks, [self.shared_state], 10, 1) - - # Discover new peers - add_onionr_thread( - lookupadders.lookup_new_peer_transports_with_communicator, - [shared_state], 60, 3) - - # Timer for adjusting which peers - # we actively communicate to at any given time, - # to avoid over-using peers - add_onionr_thread( - cooldownpeer.cooldown_peer, [self.shared_state], 30, 60) - - # Timer to read the upload queue and upload the entries to peers - add_onionr_thread( - uploadblocks.upload_blocks_from_communicator, - [self.shared_state], 5, 1) - - # This timer creates deniable blocks, - # in an attempt to further obfuscate block insertion metadata - if config.get('general.insert_deniable_blocks', True): - add_onionr_thread( - deniableinserts.insert_deniable_block, [], 180, 10) - - if config.get('transports.tor', True): - # Timer to check for connectivity, - # through Tor to various high-profile onion services - add_onionr_thread(netcheck.net_check, [shared_state], 500, 60) - - # Announce the public API server transport address - # to other nodes if security level allows - if config.get('general.security_level', 1) == 0 \ - and config.get('general.announce_node', True): - # Default to high security level incase config breaks - add_onionr_thread( - announcenode.announce_node, [self.shared_state], 600, 60) - else: - logger.debug('Will not announce node.') - - add_onionr_thread(onionrpeers.peer_cleanup, [], 300, 300) - - add_onionr_thread(housekeeping.clean_keys, [], 15, 1) - if config.get('general.use_bootstrap_list', True): bootstrappeers.add_bootstrap_list_to_peer_list( self.kv, [], db_only=True) @@ -169,24 +104,6 @@ class OnionrCommunicatorDaemon: logger.info( 'Goodbye. (Onionr is cleaning up, and will exit)', terminal=True) - def decrementThreadCount(self, threadName): - """Decrement amount of a thread name if more than zero. - - called when a function meant to be run in a thread ends - """ - try: - if self.threadCounts[threadName] > 0: - self.threadCounts[threadName] -= 1 - except KeyError: - pass - - def peerCleanup(self): - """This just calls onionrpeers.cleanupPeers. - - Remove dead or bad peers (offline too long, too slow)""" - onionrpeers.peer_cleanup() - self.decrementThreadCount('peerCleanup') - def getPeerProfileInstance(self, peer): """Gets a peer profile instance from the list of profiles""" for i in self.kv.get('peerProfiles'): diff --git a/src/onionrcommands/daemonlaunch/spawndaemonthreads.py b/src/onionrcommands/daemonlaunch/spawndaemonthreads.py index b186419b..09b6213d 100644 --- a/src/onionrcommands/daemonlaunch/spawndaemonthreads.py +++ b/src/onionrcommands/daemonlaunch/spawndaemonthreads.py @@ -2,6 +2,17 @@ from typing import TYPE_CHECKING from onionrthreads import add_onionr_thread from communicator.onlinepeers import get_online_peers +from communicatorutils import lookupblocks +from communicatorutils import downloadblocks +from communicator import onlinepeers +from communicatorutils import housekeeping +from communicatorutils import lookupadders +from communicatorutils import cooldownpeer +from communicatorutils import uploadblocks +from communicatorutils import announcenode, deniableinserts +from communicatorutils import netcheck +import onionrpeers +import config if TYPE_CHECKING: from deadsimplekv import DeadSimpleKV @@ -12,3 +23,47 @@ if TYPE_CHECKING: def spawn_client_threads(shared_state: 'TooMany'): kv: 'DeadSimpleKV' = shared_state.get_by_string('DeadSimpleKV') add_onionr_thread(get_online_peers, (shared_state,), 3, 1) + + add_onionr_thread( + lookupblocks.lookup_blocks_from_communicator, + [shared_state], 25, 3) + add_onionr_thread( + downloadblocks.download_blocks_from_communicator, + [shared_state], + config.get('timers.getBlocks', 10), 1) + add_onionr_thread(onlinepeers.clear_offline_peer, [kv], 58) + add_onionr_thread( + housekeeping.clean_old_blocks, [shared_state], 10, 1) + add_onionr_thread(housekeeping.clean_keys, [], 15, 1) + # Discover new peers + add_onionr_thread( + lookupadders.lookup_new_peer_transports_with_communicator, + [shared_state], 60, 3) + # Thread for adjusting which peers + # we actively communicate to at any given time, + # to avoid over-using peers + add_onionr_thread( + cooldownpeer.cooldown_peer, [shared_state], 30, 60) + # Thread to read the upload queue and upload the entries to peers + add_onionr_thread( + uploadblocks.upload_blocks_from_communicator, + [shared_state], 5, 1) + # This Thread creates deniable blocks, + # in an attempt to further obfuscate block insertion metadata + if config.get('general.insert_deniable_blocks', True): + add_onionr_thread( + deniableinserts.insert_deniable_block, [], 180, 10) + + if config.get('transports.tor', True): + # Timer to check for connectivity, + # through Tor to various high-profile onion services + add_onionr_thread(netcheck.net_check, [shared_state], 500, 60) + + # Announce the public API server transport address + # to other nodes if security level allows + if config.get('general.security_level', 1) == 0 \ + and config.get('general.announce_node', True): + # Default to high security level incase config breaks + add_onionr_thread( + announcenode.announce_node, [shared_state], 600, 60) + add_onionr_thread(onionrpeers.peer_cleanup, [], 300, 300) diff --git a/src/safedb/__init__.py b/src/safedb/__init__.py index 9e7b2157..ed23e126 100644 --- a/src/safedb/__init__.py +++ b/src/safedb/__init__.py @@ -40,7 +40,7 @@ class SafeDB: def close(self): self.db_conn.close() - def __init__(self, db_path: str, protected=True): + def __init__(self, db_path: str, protected=False): self.db_path = db_path self.db_conn = dbm.open(db_path, "c")