reduced config reloads by a lot
This commit is contained in:
parent
7cb5f212ec
commit
c07901ec06
@ -35,7 +35,6 @@ OnionrCommunicatorTimers = onionrcommunicatortimers.OnionrCommunicatorTimers
|
|||||||
config.reload()
|
config.reload()
|
||||||
class OnionrCommunicatorDaemon:
|
class OnionrCommunicatorDaemon:
|
||||||
def __init__(self, onionrInst, proxyPort, developmentMode=config.get('general.dev_mode', False)):
|
def __init__(self, onionrInst, proxyPort, developmentMode=config.get('general.dev_mode', False)):
|
||||||
config.reload()
|
|
||||||
onionrInst.communicatorInst = self
|
onionrInst.communicatorInst = self
|
||||||
# configure logger and stuff
|
# configure logger and stuff
|
||||||
onionr.Onionr.setupConfig('data/', self = self)
|
onionr.Onionr.setupConfig('data/', self = self)
|
||||||
|
@ -115,7 +115,6 @@ def reload():
|
|||||||
'''
|
'''
|
||||||
Reloads the configuration data in memory from the file
|
Reloads the configuration data in memory from the file
|
||||||
'''
|
'''
|
||||||
|
|
||||||
check()
|
check()
|
||||||
try:
|
try:
|
||||||
with open(get_config_file(), 'r', encoding="utf8") as configfile:
|
with open(get_config_file(), 'r', encoding="utf8") as configfile:
|
||||||
|
@ -21,7 +21,7 @@ import subprocess, os, sys, time, signal, base64, socket
|
|||||||
from shutil import which
|
from shutil import which
|
||||||
import logger, config
|
import logger, config
|
||||||
from onionrblockapi import Block
|
from onionrblockapi import Block
|
||||||
|
config.reload()
|
||||||
def getOpenPort():
|
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/
|
# 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
|
# changes from source: import moved to top of file, bind specifically to localhost
|
||||||
@ -65,10 +65,6 @@ class NetController:
|
|||||||
else:
|
else:
|
||||||
self.torBinary = 'tor'
|
self.torBinary = 'tor'
|
||||||
|
|
||||||
config.reload()
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def generateTorrc(self):
|
def generateTorrc(self):
|
||||||
'''
|
'''
|
||||||
Generate a torrc file for our tor instance
|
Generate a torrc file for our tor instance
|
||||||
|
@ -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
|
This file handles maintenence of a blacklist database, for blocks and peers
|
||||||
'''
|
'''
|
||||||
|
@ -22,10 +22,10 @@ import nacl.signing, nacl.encoding, nacl.public, nacl.hash, nacl.pwhash, nacl.ut
|
|||||||
import logger, onionrproofs
|
import logger, onionrproofs
|
||||||
import onionrexceptions, keymanager, core
|
import onionrexceptions, keymanager, core
|
||||||
import config
|
import config
|
||||||
|
config.reload()
|
||||||
|
|
||||||
class OnionrCrypto:
|
class OnionrCrypto:
|
||||||
def __init__(self, coreInstance):
|
def __init__(self, coreInstance):
|
||||||
config.reload()
|
|
||||||
self._core = coreInstance
|
self._core = coreInstance
|
||||||
self._keyFile = self._core.dataDir + 'keys.txt'
|
self._keyFile = self._core.dataDir + 'keys.txt'
|
||||||
self.pubKey = None
|
self.pubKey = None
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
'''
|
'''
|
||||||
Onionr - P2P Microblogging Platform & Social network
|
Onionr - Private P2P Communication
|
||||||
|
|
||||||
This file deals with configuration management.
|
This file deals with configuration management.
|
||||||
'''
|
'''
|
||||||
|
@ -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
|
This file contains both the PeerProfiles class for network profiling of Onionr nodes
|
||||||
'''
|
'''
|
||||||
@ -19,6 +19,7 @@
|
|||||||
'''
|
'''
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import core, config, logger
|
import core, config, logger
|
||||||
|
config.reload()
|
||||||
class PeerProfiles:
|
class PeerProfiles:
|
||||||
'''
|
'''
|
||||||
PeerProfiles
|
PeerProfiles
|
||||||
@ -91,7 +92,6 @@ def peerCleanup(coreInst):
|
|||||||
raise TypeError('coreInst must be instance of core.Core')
|
raise TypeError('coreInst must be instance of core.Core')
|
||||||
|
|
||||||
logger.info('Cleaning peers...')
|
logger.info('Cleaning peers...')
|
||||||
config.reload()
|
|
||||||
|
|
||||||
adders = getScoreSortedPeerList(coreInst)
|
adders = getScoreSortedPeerList(coreInst)
|
||||||
adders.reverse()
|
adders.reverse()
|
||||||
|
@ -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
|
This file deals with the object that is passed with each event
|
||||||
'''
|
'''
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
'''
|
'''
|
||||||
Onionr - P2P Microblogging Platform & Social network
|
Onionr - Private P2P Communication
|
||||||
|
|
||||||
This file deals with management of modules/plugins.
|
This file deals with management of modules/plugins.
|
||||||
'''
|
'''
|
||||||
@ -27,6 +27,7 @@ if not dataDir.endswith('/'):
|
|||||||
|
|
||||||
_pluginsfolder = dataDir + 'plugins/'
|
_pluginsfolder = dataDir + 'plugins/'
|
||||||
_instances = dict()
|
_instances = dict()
|
||||||
|
config.reload()
|
||||||
|
|
||||||
def reload(onionr = None, stop_event = True):
|
def reload(onionr = None, stop_event = True):
|
||||||
'''
|
'''
|
||||||
@ -211,8 +212,6 @@ def get_enabled_plugins():
|
|||||||
|
|
||||||
check()
|
check()
|
||||||
|
|
||||||
config.reload()
|
|
||||||
|
|
||||||
return list(config.get('plugins.enabled', list()))
|
return list(config.get('plugins.enabled', list()))
|
||||||
|
|
||||||
def is_enabled(name):
|
def is_enabled(name):
|
||||||
@ -253,8 +252,6 @@ def check():
|
|||||||
Checks to make sure files exist
|
Checks to make sure files exist
|
||||||
'''
|
'''
|
||||||
|
|
||||||
config.reload()
|
|
||||||
|
|
||||||
if not config.is_set('plugins'):
|
if not config.is_set('plugins'):
|
||||||
logger.debug('Generating plugin configuration data...')
|
logger.debug('Generating plugin configuration data...')
|
||||||
config.set('plugins', {'enabled': []}, True)
|
config.set('plugins', {'enabled': []}, True)
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
import multiprocessing, nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, sys, json
|
import multiprocessing, nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, sys, json
|
||||||
import core, onionrutils, config, logger, onionrblockapi
|
import core, onionrutils, config, logger, onionrblockapi
|
||||||
|
|
||||||
|
config.reload()
|
||||||
|
|
||||||
def getDifficultyModifier(coreOrUtilsInst=None):
|
def getDifficultyModifier(coreOrUtilsInst=None):
|
||||||
'''Accepts a core or utils instance returns
|
'''Accepts a core or utils instance returns
|
||||||
the difficulty modifier for block storage based
|
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
|
Return bool for a hash string to see if it meets pow difficulty defined in config
|
||||||
'''
|
'''
|
||||||
config.reload()
|
|
||||||
hashDifficulty = getHashDifficulty(h)
|
hashDifficulty = getHashDifficulty(h)
|
||||||
try:
|
try:
|
||||||
expected = int(config.get('general.minimum_block_pow'))
|
expected = int(config.get('general.minimum_block_pow'))
|
||||||
@ -100,7 +101,6 @@ class DataPOW:
|
|||||||
self.data = data
|
self.data = data
|
||||||
self.threadCount = threadCount
|
self.threadCount = threadCount
|
||||||
self.rounds = 0
|
self.rounds = 0
|
||||||
config.reload()
|
|
||||||
|
|
||||||
if forceDifficulty == 0:
|
if forceDifficulty == 0:
|
||||||
dataLen = sys.getsizeof(data)
|
dataLen = sys.getsizeof(data)
|
||||||
|
@ -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
|
This file handles block storage, providing an abstraction for storing blocks between file system and database
|
||||||
'''
|
'''
|
||||||
|
@ -34,7 +34,7 @@ if sys.version_info < (3, 6):
|
|||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
logger.fatal('On Python 3 versions prior to 3.6.x, you need the sha3 module')
|
logger.fatal('On Python 3 versions prior to 3.6.x, you need the sha3 module')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
config.reload()
|
||||||
class OnionrUtils:
|
class OnionrUtils:
|
||||||
'''
|
'''
|
||||||
Various useful functions for validating things, etc functions, connectivity
|
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.avoidDupe = [] # list used to prevent duplicate requests per peer for certain actions
|
||||||
self.peerProcessing = {} # dict of current peer actions: peer, actionList
|
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
|
self.storageCounter = storagecounter.StorageCounter(self._core) # used to keep track of how much data onionr is using on disk
|
||||||
config.reload() # onionr config
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def getTimeBypassToken(self):
|
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.
|
Send a command to the local http API server, securely. Intended for local clients, DO NOT USE for remote peers.
|
||||||
'''
|
'''
|
||||||
config.reload()
|
|
||||||
self.getTimeBypassToken()
|
self.getTimeBypassToken()
|
||||||
# TODO: URL encode parameters, just as an extra measure. May not be needed, but should be added regardless.
|
# TODO: URL encode parameters, just as an extra measure. May not be needed, but should be added regardless.
|
||||||
hostname = ''
|
hostname = ''
|
||||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
'''
|
||||||
import os, json
|
import os, json
|
||||||
import config, logger
|
import config, logger
|
||||||
|
|
||||||
@ -7,7 +26,6 @@ def setup_config(dataDir, o_inst = None):
|
|||||||
os.mkdir(dataDir)
|
os.mkdir(dataDir)
|
||||||
config.reload()
|
config.reload()
|
||||||
|
|
||||||
|
|
||||||
if not os.path.exists(config._configfile):
|
if not os.path.exists(config._configfile):
|
||||||
if os.path.exists('static-data/default_config.json'):
|
if os.path.exists('static-data/default_config.json'):
|
||||||
# this is the default config, it will be overwritten if a config file already exists. Else, it saves it
|
# this is the default config, it will be overwritten if a config file already exists. Else, it saves it
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
'''
|
'''
|
||||||
Onionr - P2P Microblogging Platform & Social network.
|
Onionr - Private P2P Communication
|
||||||
|
|
||||||
Keeps track of how much disk space we're using
|
Keeps track of how much disk space we're using
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user