From 147ae953db32f8a3354bf796d01114c8ee48ffee Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 24 Jul 2019 13:10:37 -0500 Subject: [PATCH] progress in removing core --- onionr/apiservers/private/__init__.py | 1 + onionr/communicator/__init__.py | 2 +- onionr/communicatorutils/announcenode.py | 2 +- onionr/httpapi/miscpublicapi/announce.py | 10 +++++----- onionr/onionrproofs.py | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/onionr/apiservers/private/__init__.py b/onionr/apiservers/private/__init__.py index 7c696373..d65b194c 100644 --- a/onionr/apiservers/private/__init__.py +++ b/onionr/apiservers/private/__init__.py @@ -61,6 +61,7 @@ class PrivateAPI: onionrInst.setClientAPIInst(self) register_private_blueprints.register_private_blueprints(self, app) httpapi.load_plugin_blueprints(app) + self.onionrInst = onionrInst self.httpServer = WSGIServer((self.host, bindPort), app, log=None, handler_class=httpapi.fdsafehandler.FDSafeHandler) self.httpServer.serve_forever() diff --git a/onionr/communicator/__init__.py b/onionr/communicator/__init__.py index 1a0e83ee..8ca03a19 100755 --- a/onionr/communicator/__init__.py +++ b/onionr/communicator/__init__.py @@ -146,7 +146,7 @@ class OnionrCommunicatorDaemon: if config.get('general.security_level', 1) == 0 and config.get('general.announce_node', True): # Default to high security level incase config breaks announceTimer = OnionrCommunicatorTimers(self, announcenode.announce_node, 3600, myArgs=[self], requiresPeer=True, maxThreads=1) - announceTimer.count = (announceTimer.frequency - 120) + announceTimer.count = (announceTimer.frequency - 60) else: logger.debug('Will not announce node.') diff --git a/onionr/communicatorutils/announcenode.py b/onionr/communicatorutils/announcenode.py index b8e07357..eaabaa80 100755 --- a/onionr/communicatorutils/announcenode.py +++ b/onionr/communicatorutils/announcenode.py @@ -77,7 +77,7 @@ def announce_node(daemon): daemon.announceCache[peer] = data['random'] if not announceFail: logger.info('Announcing node to ' + url) - if basicrequests.do_post_request(url, data) == 'Success': + if basicrequests.do_post_request(daemon.onionrInst, url, data) == 'Success': logger.info('Successfully introduced node to ' + peer, terminal=True) retData = True keydb.transportinfo.set_address_info(peer, 'introduced', 1) diff --git a/onionr/httpapi/miscpublicapi/announce.py b/onionr/httpapi/miscpublicapi/announce.py index 89b9fbb3..8009704a 100755 --- a/onionr/httpapi/miscpublicapi/announce.py +++ b/onionr/httpapi/miscpublicapi/announce.py @@ -22,7 +22,8 @@ from flask import Response import logger from etc import onionrvalues from onionrutils import stringvalidators, bytesconverter - +from utils import gettransports +import onionrcrypto as crypto def handle_announce(clientAPI, request): ''' accept announcement posts, validating POW @@ -32,7 +33,6 @@ def handle_announce(clientAPI, request): powHash = '' randomData = '' newNode = '' - ourAdder = clientAPI.hsAddress.encode() try: newNode = request.form['node'].encode() except KeyError: @@ -45,9 +45,9 @@ def handle_announce(clientAPI, request): except KeyError: logger.warn('No random data specified for upload') else: - nodes = newNode + clientAPI.hsAddress.encode() - nodes = clientAPI.crypto.blake2bHash(nodes) - powHash = clientAPI.crypto.blake2bHash(randomData + nodes) + nodes = newNode + bytesconverter.str_to_bytes(gettransports.get()[0]) + nodes = crypto.hashers.blake2b_hash(nodes) + powHash = crypto.hashers.blake2b_hash(randomData + nodes) try: powHash = powHash.decode() except AttributeError: diff --git a/onionr/onionrproofs.py b/onionr/onionrproofs.py index 3b31b7c4..fb6cafda 100755 --- a/onionr/onionrproofs.py +++ b/onionr/onionrproofs.py @@ -117,7 +117,7 @@ class DataPOW: self.puzzle = self.mainHash[0:min(self.difficulty, len(self.mainHash))] for i in range(max(1, threadCount)): - t = threading.Thread(name = 'thread%s' % i, target = self.pow, args = (True)) + t = threading.Thread(name = 'thread%s' % i, target = self.pow, args = (True,)) t.start() def pow(self, reporting = False): @@ -211,7 +211,7 @@ class POW: self.puzzle = self.mainHash[0:min(self.difficulty, len(self.mainHash))] for i in range(max(1, threadCount)): - t = threading.Thread(name = 'thread%s' % i, target = self.pow, args = (True)) + t = threading.Thread(name = 'thread%s' % i, target = self.pow, args = (True,)) t.start() def pow(self, reporting = False):