direct connections closer to working

This commit is contained in:
Kevin Froman 2019-03-23 21:56:46 -05:00
parent 85adef1660
commit b9beef3cce
5 changed files with 26 additions and 11 deletions

View File

@ -108,7 +108,12 @@ 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,))
if config.get('general.socket_servers', False):
self.services = onionrservices.OnionrServices(self._core)
self.active_services = []
OnionrCommunicatorTimers(self, servicecreator.service_creator, 5, maxThreads=10, myArgs=(self,))
else:
self.services = None
deniableBlockTimer = OnionrCommunicatorTimers(self, self.daemonTools.insertDeniableBlock, 180, requiresPeer=True, maxThreads=1)
netCheckTimer = OnionrCommunicatorTimers(self, self.daemonTools.netCheck, 600)
@ -127,11 +132,6 @@ class OnionrCommunicatorDaemon:
blockCleanupTimer.count = (blockCleanupTimer.frequency - 5)
#forwardSecrecyTimer.count = (forwardSecrecyTimer.frequency - 990)
if config.get('general.socket_servers'):
self.services = onionrservices.OnionrServices(self._core)
else:
self.services = None
# Main daemon loop, mainly for calling timers, don't do any complex operations here to avoid locking
try:
while not self.shutdown:

View File

@ -0,0 +1,17 @@
import communicator, onionrblockapi
def service_creator(daemon):
assert isinstance(daemon, communicator.OnionrCommunicatorDaemon)
core = daemon._core
utils = core._utils
# Find socket connection blocks
con_blocks = core.getBlocksByType('con')
for b in con_blocks:
if not b in daemon.active_services:
bl = onionrblockapi.Block(b, core=core, decrypt=True)
bs = utils.bytesToStr(bl.bcontent) + '.onion'
if utils.validatePubKey(bl.signer) and utils.validateID(bs):
daemon.active_services.append(b)
daemon.services.create_server(bl.signer, bs)
daemon.decrementThreadCount('service_creator')

View File

@ -17,9 +17,8 @@ class OnionrServices:
BOOTSTRAP_TRIES = 10
TRY_WAIT = 3
for x in range(BOOTSTRAP_TRIES):
if self._core._utils.doGetRequest('http://' + address + '/ping') == 'pong!':
if self._core._utils.doGetRequest('http://' + address + '/ping', port=self._core.config.get('tor.socksport')) == 'pong!':
connectionserver.ConnectionServer(peer, address, core_inst=self._core)
return True
else:
time.sleep(TRY_WAIT)
else:

View File

@ -55,8 +55,7 @@ def bootstrap_client_service(peer, core_inst=None, bootstrap_timeout=300):
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, key_type = 'NEW', await_publication = True)
response = controller.create_ephemeral_hidden_service({80: bootstrap_port}, 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))

View File

@ -4,7 +4,7 @@
"display_header" : false,
"minimum_block_pow": 4,
"minimum_send_pow": 4,
"socket_servers": false,
"socket_servers": true,
"security_level": 0,
"max_block_age": 2678400,
"bypass_tor_check": false,