progress in removing core

This commit is contained in:
Kevin Froman 2019-07-24 13:10:37 -05:00
parent 3097407774
commit 147ae953db
5 changed files with 10 additions and 9 deletions

View File

@ -61,6 +61,7 @@ class PrivateAPI:
onionrInst.setClientAPIInst(self) onionrInst.setClientAPIInst(self)
register_private_blueprints.register_private_blueprints(self, app) register_private_blueprints.register_private_blueprints(self, app)
httpapi.load_plugin_blueprints(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 = WSGIServer((self.host, bindPort), app, log=None, handler_class=httpapi.fdsafehandler.FDSafeHandler)
self.httpServer.serve_forever() self.httpServer.serve_forever()

View File

@ -146,7 +146,7 @@ class OnionrCommunicatorDaemon:
if config.get('general.security_level', 1) == 0 and config.get('general.announce_node', True): if config.get('general.security_level', 1) == 0 and config.get('general.announce_node', True):
# Default to high security level incase config breaks # Default to high security level incase config breaks
announceTimer = OnionrCommunicatorTimers(self, announcenode.announce_node, 3600, myArgs=[self], requiresPeer=True, maxThreads=1) announceTimer = OnionrCommunicatorTimers(self, announcenode.announce_node, 3600, myArgs=[self], requiresPeer=True, maxThreads=1)
announceTimer.count = (announceTimer.frequency - 120) announceTimer.count = (announceTimer.frequency - 60)
else: else:
logger.debug('Will not announce node.') logger.debug('Will not announce node.')

View File

@ -77,7 +77,7 @@ def announce_node(daemon):
daemon.announceCache[peer] = data['random'] daemon.announceCache[peer] = data['random']
if not announceFail: if not announceFail:
logger.info('Announcing node to ' + url) 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) logger.info('Successfully introduced node to ' + peer, terminal=True)
retData = True retData = True
keydb.transportinfo.set_address_info(peer, 'introduced', 1) keydb.transportinfo.set_address_info(peer, 'introduced', 1)

View File

@ -22,7 +22,8 @@ from flask import Response
import logger import logger
from etc import onionrvalues from etc import onionrvalues
from onionrutils import stringvalidators, bytesconverter from onionrutils import stringvalidators, bytesconverter
from utils import gettransports
import onionrcrypto as crypto
def handle_announce(clientAPI, request): def handle_announce(clientAPI, request):
''' '''
accept announcement posts, validating POW accept announcement posts, validating POW
@ -32,7 +33,6 @@ def handle_announce(clientAPI, request):
powHash = '' powHash = ''
randomData = '' randomData = ''
newNode = '' newNode = ''
ourAdder = clientAPI.hsAddress.encode()
try: try:
newNode = request.form['node'].encode() newNode = request.form['node'].encode()
except KeyError: except KeyError:
@ -45,9 +45,9 @@ def handle_announce(clientAPI, request):
except KeyError: except KeyError:
logger.warn('No random data specified for upload') logger.warn('No random data specified for upload')
else: else:
nodes = newNode + clientAPI.hsAddress.encode() nodes = newNode + bytesconverter.str_to_bytes(gettransports.get()[0])
nodes = clientAPI.crypto.blake2bHash(nodes) nodes = crypto.hashers.blake2b_hash(nodes)
powHash = clientAPI.crypto.blake2bHash(randomData + nodes) powHash = crypto.hashers.blake2b_hash(randomData + nodes)
try: try:
powHash = powHash.decode() powHash = powHash.decode()
except AttributeError: except AttributeError:

View File

@ -117,7 +117,7 @@ class DataPOW:
self.puzzle = self.mainHash[0:min(self.difficulty, len(self.mainHash))] self.puzzle = self.mainHash[0:min(self.difficulty, len(self.mainHash))]
for i in range(max(1, threadCount)): 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() t.start()
def pow(self, reporting = False): def pow(self, reporting = False):
@ -211,7 +211,7 @@ class POW:
self.puzzle = self.mainHash[0:min(self.difficulty, len(self.mainHash))] self.puzzle = self.mainHash[0:min(self.difficulty, len(self.mainHash))]
for i in range(max(1, threadCount)): 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() t.start()
def pow(self, reporting = False): def pow(self, reporting = False):