From ae2d79247195431b6f69265ae0c304eccc80b9f6 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 22 Mar 2019 21:58:09 -0500 Subject: [PATCH] bootstrap blocks now inserted and detected --- onionr/communicator.py | 2 ++ onionr/communicatorutils/onionrcommunicatortimers.py | 5 +++-- onionr/onionrservices/__init__.py | 1 + onionr/onionrservices/bootstrapservice.py | 5 +++-- onionr/onionrservices/connectionserver.py | 2 +- onionr/onionrutils.py | 2 ++ .../default-plugins/metadataprocessor/main.py | 9 +-------- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/onionr/communicator.py b/onionr/communicator.py index 37c0cbdb..e4a513d6 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -24,6 +24,7 @@ from dependencies import secrets from utils import networkmerger import onionrexceptions, onionrpeers, onionrevents as events, onionrplugins as plugins, onionrblockapi as block from communicatorutils import onionrdaemontools +from communicatorutils import servicecreator import onionrservices, onionr, onionrproofs from communicatorutils import onionrcommunicatortimers, proxypicker @@ -107,6 +108,7 @@ class OnionrCommunicatorDaemon: OnionrCommunicatorTimers(self, self.uploadBlock, 10, requiresPeer=True, maxThreads=1) OnionrCommunicatorTimers(self, self.daemonCommands, 6, maxThreads=1) OnionrCommunicatorTimers(self, self.detectAPICrash, 30, maxThreads=1) + OnionrCommunicatorTimers(self, servicecreator.service_creator, 5, maxThreads=10, myArgs=(self,)) deniableBlockTimer = OnionrCommunicatorTimers(self, self.daemonTools.insertDeniableBlock, 180, requiresPeer=True, maxThreads=1) netCheckTimer = OnionrCommunicatorTimers(self, self.daemonTools.netCheck, 600) diff --git a/onionr/communicatorutils/onionrcommunicatortimers.py b/onionr/communicatorutils/onionrcommunicatortimers.py index c15f20fc..a94a7821 100755 --- a/onionr/communicatorutils/onionrcommunicatortimers.py +++ b/onionr/communicatorutils/onionrcommunicatortimers.py @@ -20,7 +20,7 @@ ''' import threading, onionrexceptions, logger class OnionrCommunicatorTimers: - def __init__(self, daemonInstance, timerFunction, frequency, makeThread=True, threadAmount=1, maxThreads=5, requiresPeer=False): + def __init__(self, daemonInstance, timerFunction, frequency, makeThread=True, threadAmount=1, maxThreads=5, requiresPeer=False, myArgs=[]): self.timerFunction = timerFunction self.frequency = frequency self.threadAmount = threadAmount @@ -29,6 +29,7 @@ class OnionrCommunicatorTimers: self.daemonInstance = daemonInstance self.maxThreads = maxThreads self._core = self.daemonInstance._core + self.args = myArgs self.daemonInstance.timers.append(self) self.count = 0 @@ -55,7 +56,7 @@ class OnionrCommunicatorTimers: logger.debug('%s is currently using the maximum number of threads, not starting another.' % self.timerFunction.__name__) else: self.daemonInstance.threadCounts[self.timerFunction.__name__] += 1 - newThread = threading.Thread(target=self.timerFunction) + newThread = threading.Thread(target=self.timerFunction, args=self.args) newThread.start() else: self.timerFunction() diff --git a/onionr/onionrservices/__init__.py b/onionr/onionrservices/__init__.py index 5ea0ef3e..7194ea22 100644 --- a/onionr/onionrservices/__init__.py +++ b/onionr/onionrservices/__init__.py @@ -2,6 +2,7 @@ import time import stem import core from . import connectionserver, bootstrapservice + class OnionrServices: def __init__(self, onionr_core): assert isinstance(onionr_core, core.Core) diff --git a/onionr/onionrservices/bootstrapservice.py b/onionr/onionrservices/bootstrapservice.py index b0b2fb7d..5dafe0f3 100644 --- a/onionr/onionrservices/bootstrapservice.py +++ b/onionr/onionrservices/bootstrapservice.py @@ -23,7 +23,7 @@ from flask import Flask import core from netcontroller import getOpenPort -def bootstrap_client_service(peer, core_inst=None, bootstrap_timeout=120): +def bootstrap_client_service(peer, core_inst=None, bootstrap_timeout=300): ''' Bootstrap client services ''' @@ -54,7 +54,8 @@ def bootstrap_client_service(peer, core_inst=None, bootstrap_timeout=120): # Connect to the Tor process for Onionr controller.authenticate(core_inst.config.get('tor.controlpassword')) # Create the v3 onion service - response = controller.create_ephemeral_hidden_service({80: bootstrap_port}, await_publication = True, key_content = 'ED25519-V3') + #response = controller.create_ephemeral_hidden_service({80: bootstrap_port}, await_publication = True, key_content = 'ED25519-V3') + response = controller.create_ephemeral_hidden_service(80, key_type = 'NEW', await_publication = True) core_inst.insertBlock(response.service_id, header='con', sign=True, encryptType='asym', asymPeer=peer, disableForward=True, expire=(core_inst._utils.getEpoch() + bootstrap_timeout)) diff --git a/onionr/onionrservices/connectionserver.py b/onionr/onionrservices/connectionserver.py index 54ff03c3..32d2640a 100644 --- a/onionr/onionrservices/connectionserver.py +++ b/onionr/onionrservices/connectionserver.py @@ -22,6 +22,6 @@ class ConnectionServer: # Connect to the Tor process for Onionr controller.authenticate(core_inst.config.get('tor.controlpassword')) # Create the v3 onion service - response = controller.create_ephemeral_hidden_service({80: service_port}, await_publication = True, key_type='ED25519-V3') + response = controller.create_ephemeral_hidden_service({80: service_port}, await_publication = True, key_type='NEW') logger.info('hosting on ' + response.service_id) http_server.serve_forever() \ No newline at end of file diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index 082b14fb..b9ae61c4 100755 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -182,6 +182,8 @@ class OnionrUtils: pass else: self._core.updateBlockInfo(blockHash, 'expire', expireTime) + if not blockType is None: + self._core.updateBlockInfo(blockHash, 'dataType', blockType) else: pass #logger.debug('Not processing metadata on encrypted block we cannot decrypt.') diff --git a/onionr/static-data/default-plugins/metadataprocessor/main.py b/onionr/static-data/default-plugins/metadataprocessor/main.py index 54f7dc18..787b0174 100755 --- a/onionr/static-data/default-plugins/metadataprocessor/main.py +++ b/onionr/static-data/default-plugins/metadataprocessor/main.py @@ -55,14 +55,7 @@ def on_processblocks(api, data=None): if blockType == 'forwardKey': if api.data['validSig'] == True: _processForwardKey(api, myBlock) - # socket blocks - elif blockType == 'con': - if api.data['validSig'] == True and myBlock.decrypted: # we check if it is decrypted as a way of seeing if it was for us - myBlock.bcontent = utils.bytesToStr(myBlock.bcontent) - if utils.validateID('%s.onion' % (myBlock.bcontent,)): - logger.info('Detected socket advertised to us...') - core.keyStore.put('con', (myBlock.content, myBlock.signer)) - + def on_init(api, data = None): pluginapi = api