bootstrap blocks now inserted and detected

This commit is contained in:
Kevin Froman 2019-03-22 21:58:09 -05:00
parent 2da5e0479a
commit 85adef1660
7 changed files with 13 additions and 13 deletions

View File

@ -24,6 +24,7 @@ from dependencies import secrets
from utils import networkmerger from utils import networkmerger
import onionrexceptions, onionrpeers, onionrevents as events, onionrplugins as plugins, onionrblockapi as block import onionrexceptions, onionrpeers, onionrevents as events, onionrplugins as plugins, onionrblockapi as block
from communicatorutils import onionrdaemontools from communicatorutils import onionrdaemontools
from communicatorutils import servicecreator
import onionrservices, onionr, onionrproofs import onionrservices, onionr, onionrproofs
from communicatorutils import onionrcommunicatortimers, proxypicker from communicatorutils import onionrcommunicatortimers, proxypicker
@ -107,6 +108,7 @@ class OnionrCommunicatorDaemon:
OnionrCommunicatorTimers(self, self.uploadBlock, 10, requiresPeer=True, maxThreads=1) OnionrCommunicatorTimers(self, self.uploadBlock, 10, requiresPeer=True, maxThreads=1)
OnionrCommunicatorTimers(self, self.daemonCommands, 6, maxThreads=1) OnionrCommunicatorTimers(self, self.daemonCommands, 6, maxThreads=1)
OnionrCommunicatorTimers(self, self.detectAPICrash, 30, 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) deniableBlockTimer = OnionrCommunicatorTimers(self, self.daemonTools.insertDeniableBlock, 180, requiresPeer=True, maxThreads=1)
netCheckTimer = OnionrCommunicatorTimers(self, self.daemonTools.netCheck, 600) netCheckTimer = OnionrCommunicatorTimers(self, self.daemonTools.netCheck, 600)

View File

@ -20,7 +20,7 @@
''' '''
import threading, onionrexceptions, logger import threading, onionrexceptions, logger
class OnionrCommunicatorTimers: 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.timerFunction = timerFunction
self.frequency = frequency self.frequency = frequency
self.threadAmount = threadAmount self.threadAmount = threadAmount
@ -29,6 +29,7 @@ class OnionrCommunicatorTimers:
self.daemonInstance = daemonInstance self.daemonInstance = daemonInstance
self.maxThreads = maxThreads self.maxThreads = maxThreads
self._core = self.daemonInstance._core self._core = self.daemonInstance._core
self.args = myArgs
self.daemonInstance.timers.append(self) self.daemonInstance.timers.append(self)
self.count = 0 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__) logger.debug('%s is currently using the maximum number of threads, not starting another.' % self.timerFunction.__name__)
else: else:
self.daemonInstance.threadCounts[self.timerFunction.__name__] += 1 self.daemonInstance.threadCounts[self.timerFunction.__name__] += 1
newThread = threading.Thread(target=self.timerFunction) newThread = threading.Thread(target=self.timerFunction, args=self.args)
newThread.start() newThread.start()
else: else:
self.timerFunction() self.timerFunction()

View File

@ -2,6 +2,7 @@ import time
import stem import stem
import core import core
from . import connectionserver, bootstrapservice from . import connectionserver, bootstrapservice
class OnionrServices: class OnionrServices:
def __init__(self, onionr_core): def __init__(self, onionr_core):
assert isinstance(onionr_core, core.Core) assert isinstance(onionr_core, core.Core)

View File

@ -23,7 +23,7 @@ from flask import Flask
import core import core
from netcontroller import getOpenPort 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 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 # Connect to the Tor process for Onionr
controller.authenticate(core_inst.config.get('tor.controlpassword')) controller.authenticate(core_inst.config.get('tor.controlpassword'))
# Create the v3 onion service # 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', core_inst.insertBlock(response.service_id, header='con', sign=True, encryptType='asym',
asymPeer=peer, disableForward=True, expire=(core_inst._utils.getEpoch() + bootstrap_timeout)) asymPeer=peer, disableForward=True, expire=(core_inst._utils.getEpoch() + bootstrap_timeout))

View File

@ -22,6 +22,6 @@ class ConnectionServer:
# Connect to the Tor process for Onionr # Connect to the Tor process for Onionr
controller.authenticate(core_inst.config.get('tor.controlpassword')) controller.authenticate(core_inst.config.get('tor.controlpassword'))
# Create the v3 onion service # 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) logger.info('hosting on ' + response.service_id)
http_server.serve_forever() http_server.serve_forever()

View File

@ -182,6 +182,8 @@ class OnionrUtils:
pass pass
else: else:
self._core.updateBlockInfo(blockHash, 'expire', expireTime) self._core.updateBlockInfo(blockHash, 'expire', expireTime)
if not blockType is None:
self._core.updateBlockInfo(blockHash, 'dataType', blockType)
else: else:
pass pass
#logger.debug('Not processing metadata on encrypted block we cannot decrypt.') #logger.debug('Not processing metadata on encrypted block we cannot decrypt.')

View File

@ -55,14 +55,7 @@ def on_processblocks(api, data=None):
if blockType == 'forwardKey': if blockType == 'forwardKey':
if api.data['validSig'] == True: if api.data['validSig'] == True:
_processForwardKey(api, myBlock) _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): def on_init(api, data = None):
pluginapi = api pluginapi = api