bootstrap blocks now inserted and detected
This commit is contained in:
parent
3212768dc7
commit
ae2d792471
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
|
@ -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()
|
@ -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.')
|
||||
|
@ -55,13 +55,6 @@ 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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user