diff --git a/onionr/core.py b/onionr/core.py index 79afe9c9..10db55c5 100755 --- a/onionr/core.py +++ b/onionr/core.py @@ -47,9 +47,6 @@ class Core: self.maxBlockSize = 10000000 # max block size in bytes self.onionrInst = None - self.queueDB = self.dataDir + 'queue.db' - self.peerDB = self.dataDir + 'peers.db' - self.blockDB = self.dataDir + 'blocks.db' self.blockDataLocation = self.dataDir + 'blocks/' self.blockDataDB = self.blockDataLocation + 'block-data.db' self.publicApiHostFile = self.dataDir + 'public-host.txt' diff --git a/onionr/filepaths/__init__.py b/onionr/filepaths/__init__.py new file mode 100644 index 00000000..06eaed52 --- /dev/null +++ b/onionr/filepaths/__init__.py @@ -0,0 +1,11 @@ +from utils import identifyhome +home = identifyhome.identify_home() +if not home.endswith('/') home += '/' + +usage_file = home + 'disk-usage.txt' +block_data_location = home + 'blocks/' +public_API_host_file = home + 'public-host.txt' +private_API_host_file = home + 'private-host.txt' +bootstrap_file_location = 'static-data/bootstrap-nodes.txt' +data_nonce_file = home + 'block-nonces.dat' +forward_keys_file = home + 'forward-keys.db' \ No newline at end of file diff --git a/onionr/onionrcommands/dopex.py b/onionr/onionrcommands/dopex.py new file mode 100644 index 00000000..76f24463 --- /dev/null +++ b/onionr/onionrcommands/dopex.py @@ -0,0 +1,3 @@ +from coredb import daemonqueue +def do_PEX(): + daemonqueue.daemon_queue_add('pex') \ No newline at end of file diff --git a/onionr/onionrcrypto/signing.py b/onionr/onionrcrypto/signing.py new file mode 100644 index 00000000..e69de29b diff --git a/onionr/onionrutils/getclientapiserver.py b/onionr/onionrutils/getclientapiserver.py index e0afe61b..f824d5e6 100644 --- a/onionr/onionrutils/getclientapiserver.py +++ b/onionr/onionrutils/getclientapiserver.py @@ -17,10 +17,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ''' -def get_client_API_server(core_inst): +import filepaths +def get_client_API_server(): retData = '' try: - with open(core_inst.privateApiHostFile, 'r') as host: + with open(filepaths.private_API_host_file, 'r') as host: hostname = host.read() except FileNotFoundError: raise FileNotFoundError diff --git a/onionr/onionrutils/localcommand.py b/onionr/onionrutils/localcommand.py index 13495a3c..f24767e5 100644 --- a/onionr/onionrutils/localcommand.py +++ b/onionr/onionrutils/localcommand.py @@ -19,14 +19,11 @@ ''' import urllib, requests, time import logger -from onionrutils import getclientapiserver -def local_command(core_inst, command, data='', silent = True, post=False, postData = {}, maxWait=20): - ''' - Send a command to the local http API server, securely. Intended for local clients, DO NOT USE for remote peers. - ''' - # TODO: URL encode parameters, just as an extra measure. May not be needed, but should be added regardless. - hostname = '' - waited = 0 +from . import getclientapiserver +hostname = '' +waited = 0 +maxWait = 3 +def get_hostname(): while hostname == '': try: hostname = getclientapiserver.get_client_API_server(core_inst) @@ -35,6 +32,16 @@ def local_command(core_inst, command, data='', silent = True, post=False, postDa waited += 1 if waited == maxWait: return False + return hostname +hostname = get_hostname() + +def local_command(core_inst, command, data='', silent = True, post=False, postData = {}, maxWait=20): + ''' + Send a command to the local http API server, securely. Intended for local clients, DO NOT USE for remote peers. + ''' + # TODO: URL encode parameters, just as an extra measure. May not be needed, but should be added regardless. + if hostname == False: + hostname = get_hostname() if data != '': data = '&data=' + urllib.parse.quote_plus(data) payload = 'http://%s/%s%s' % (hostname, command, data)