progress in removing core
This commit is contained in:
		
							parent
							
								
									3097407774
								
							
						
					
					
						commit
						147ae953db
					
				
					 5 changed files with 10 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.')
 | 
			
		||||
        
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue