diff --git a/onionr/communicator.py b/onionr/communicator.py index 52ea546a..a75cd998 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -35,7 +35,6 @@ OnionrCommunicatorTimers = onionrcommunicatortimers.OnionrCommunicatorTimers config.reload() class OnionrCommunicatorDaemon: def __init__(self, onionrInst, proxyPort, developmentMode=config.get('general.dev_mode', False)): - config.reload() onionrInst.communicatorInst = self # configure logger and stuff onionr.Onionr.setupConfig('data/', self = self) diff --git a/onionr/config.py b/onionr/config.py index 6cb75050..47373f8b 100755 --- a/onionr/config.py +++ b/onionr/config.py @@ -115,7 +115,6 @@ def reload(): ''' Reloads the configuration data in memory from the file ''' - check() try: with open(get_config_file(), 'r', encoding="utf8") as configfile: diff --git a/onionr/netcontroller.py b/onionr/netcontroller.py index 5f12115b..b1b1792b 100755 --- a/onionr/netcontroller.py +++ b/onionr/netcontroller.py @@ -21,7 +21,7 @@ import subprocess, os, sys, time, signal, base64, socket from shutil import which import logger, config from onionrblockapi import Block - +config.reload() def getOpenPort(): # taken from (but modified) https://stackoverflow.com/a/2838309 by https://stackoverflow.com/users/133374/albert ccy-by-sa-3 https://creativecommons.org/licenses/by-sa/3.0/ # changes from source: import moved to top of file, bind specifically to localhost @@ -65,10 +65,6 @@ class NetController: else: self.torBinary = 'tor' - config.reload() - - return - def generateTorrc(self): ''' Generate a torrc file for our tor instance diff --git a/onionr/onionrblacklist.py b/onionr/onionrblacklist.py index 63ecbb6b..9c4e99d7 100755 --- a/onionr/onionrblacklist.py +++ b/onionr/onionrblacklist.py @@ -1,5 +1,5 @@ ''' - Onionr - P2P Anonymous Storage Network + Onionr - Private P2P Communication This file handles maintenence of a blacklist database, for blocks and peers ''' diff --git a/onionr/onionrcrypto.py b/onionr/onionrcrypto.py index bab96092..75fe2138 100755 --- a/onionr/onionrcrypto.py +++ b/onionr/onionrcrypto.py @@ -22,10 +22,10 @@ import nacl.signing, nacl.encoding, nacl.public, nacl.hash, nacl.pwhash, nacl.ut import logger, onionrproofs import onionrexceptions, keymanager, core import config +config.reload() class OnionrCrypto: def __init__(self, coreInstance): - config.reload() self._core = coreInstance self._keyFile = self._core.dataDir + 'keys.txt' self.pubKey = None diff --git a/onionr/onionrevents.py b/onionr/onionrevents.py index c6ebcc40..beaeca01 100755 --- a/onionr/onionrevents.py +++ b/onionr/onionrevents.py @@ -1,5 +1,5 @@ ''' - Onionr - P2P Microblogging Platform & Social network + Onionr - Private P2P Communication This file deals with configuration management. ''' diff --git a/onionr/onionrpeers.py b/onionr/onionrpeers.py index aa0887f6..8bf76289 100755 --- a/onionr/onionrpeers.py +++ b/onionr/onionrpeers.py @@ -1,5 +1,5 @@ ''' - Onionr - P2P Anonymous Storage Network + Onionr - Private P2P Communication This file contains both the PeerProfiles class for network profiling of Onionr nodes ''' @@ -19,6 +19,7 @@ ''' import sqlite3 import core, config, logger +config.reload() class PeerProfiles: ''' PeerProfiles @@ -91,7 +92,6 @@ def peerCleanup(coreInst): raise TypeError('coreInst must be instance of core.Core') logger.info('Cleaning peers...') - config.reload() adders = getScoreSortedPeerList(coreInst) adders.reverse() diff --git a/onionr/onionrpluginapi.py b/onionr/onionrpluginapi.py index 0120dad7..78c8a008 100755 --- a/onionr/onionrpluginapi.py +++ b/onionr/onionrpluginapi.py @@ -1,5 +1,5 @@ ''' - Onionr - P2P Microblogging Platform & Social network + Onionr - Private P2P Communication This file deals with the object that is passed with each event ''' diff --git a/onionr/onionrplugins.py b/onionr/onionrplugins.py index c334ea09..9698f5d1 100755 --- a/onionr/onionrplugins.py +++ b/onionr/onionrplugins.py @@ -1,5 +1,5 @@ ''' - Onionr - P2P Microblogging Platform & Social network + Onionr - Private P2P Communication This file deals with management of modules/plugins. ''' @@ -27,6 +27,7 @@ if not dataDir.endswith('/'): _pluginsfolder = dataDir + 'plugins/' _instances = dict() +config.reload() def reload(onionr = None, stop_event = True): ''' @@ -211,8 +212,6 @@ def get_enabled_plugins(): check() - config.reload() - return list(config.get('plugins.enabled', list())) def is_enabled(name): @@ -253,8 +252,6 @@ def check(): Checks to make sure files exist ''' - config.reload() - if not config.is_set('plugins'): logger.debug('Generating plugin configuration data...') config.set('plugins', {'enabled': []}, True) diff --git a/onionr/onionrproofs.py b/onionr/onionrproofs.py index 10d08c66..5ff32964 100755 --- a/onionr/onionrproofs.py +++ b/onionr/onionrproofs.py @@ -20,6 +20,8 @@ import multiprocessing, nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, sys, json import core, onionrutils, config, logger, onionrblockapi +config.reload() + def getDifficultyModifier(coreOrUtilsInst=None): '''Accepts a core or utils instance returns the difficulty modifier for block storage based @@ -82,7 +84,6 @@ def hashMeetsDifficulty(h): ''' Return bool for a hash string to see if it meets pow difficulty defined in config ''' - config.reload() hashDifficulty = getHashDifficulty(h) try: expected = int(config.get('general.minimum_block_pow')) @@ -100,7 +101,6 @@ class DataPOW: self.data = data self.threadCount = threadCount self.rounds = 0 - config.reload() if forceDifficulty == 0: dataLen = sys.getsizeof(data) diff --git a/onionr/onionrstorage.py b/onionr/onionrstorage.py index 65fe6757..5f44c4f3 100644 --- a/onionr/onionrstorage.py +++ b/onionr/onionrstorage.py @@ -1,5 +1,5 @@ ''' - Onionr - P2P Anonymous Storage Network + Onionr - Private P2P Communication This file handles block storage, providing an abstraction for storing blocks between file system and database ''' diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index d857b6bf..c5546d09 100755 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -34,7 +34,7 @@ if sys.version_info < (3, 6): except ModuleNotFoundError: logger.fatal('On Python 3 versions prior to 3.6.x, you need the sha3 module') sys.exit(1) - +config.reload() class OnionrUtils: ''' Various useful functions for validating things, etc functions, connectivity @@ -47,7 +47,6 @@ class OnionrUtils: self.avoidDupe = [] # list used to prevent duplicate requests per peer for certain actions self.peerProcessing = {} # dict of current peer actions: peer, actionList self.storageCounter = storagecounter.StorageCounter(self._core) # used to keep track of how much data onionr is using on disk - config.reload() # onionr config return def getTimeBypassToken(self): @@ -85,7 +84,6 @@ class OnionrUtils: ''' Send a command to the local http API server, securely. Intended for local clients, DO NOT USE for remote peers. ''' - config.reload() self.getTimeBypassToken() # TODO: URL encode parameters, just as an extra measure. May not be needed, but should be added regardless. hostname = '' diff --git a/onionr/setupconfig.py b/onionr/setupconfig.py index e439845a..e0752f74 100644 --- a/onionr/setupconfig.py +++ b/onionr/setupconfig.py @@ -1,3 +1,22 @@ +''' + Onionr - Private P2P Communication + + Initialize Onionr configuration +''' +''' + 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 . +''' import os, json import config, logger @@ -6,7 +25,6 @@ def setup_config(dataDir, o_inst = None): if not data_exists: os.mkdir(dataDir) config.reload() - if not os.path.exists(config._configfile): if os.path.exists('static-data/default_config.json'): diff --git a/onionr/storagecounter.py b/onionr/storagecounter.py index 76ebe16b..9dbb8827 100755 --- a/onionr/storagecounter.py +++ b/onionr/storagecounter.py @@ -1,5 +1,5 @@ ''' - Onionr - P2P Microblogging Platform & Social network. + Onionr - Private P2P Communication Keeps track of how much disk space we're using '''