direct connections closer to working
This commit is contained in:
parent
ae2d792471
commit
d1737216e4
@ -108,7 +108,12 @@ 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,))
|
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)
|
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)
|
||||||
@ -127,11 +132,6 @@ class OnionrCommunicatorDaemon:
|
|||||||
blockCleanupTimer.count = (blockCleanupTimer.frequency - 5)
|
blockCleanupTimer.count = (blockCleanupTimer.frequency - 5)
|
||||||
#forwardSecrecyTimer.count = (forwardSecrecyTimer.frequency - 990)
|
#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
|
# Main daemon loop, mainly for calling timers, don't do any complex operations here to avoid locking
|
||||||
try:
|
try:
|
||||||
while not self.shutdown:
|
while not self.shutdown:
|
||||||
|
17
onionr/communicatorutils/servicecreator.py
Normal file
17
onionr/communicatorutils/servicecreator.py
Normal 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')
|
@ -17,9 +17,8 @@ class OnionrServices:
|
|||||||
BOOTSTRAP_TRIES = 10
|
BOOTSTRAP_TRIES = 10
|
||||||
TRY_WAIT = 3
|
TRY_WAIT = 3
|
||||||
for x in range(BOOTSTRAP_TRIES):
|
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)
|
connectionserver.ConnectionServer(peer, address, core_inst=self._core)
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
time.sleep(TRY_WAIT)
|
time.sleep(TRY_WAIT)
|
||||||
else:
|
else:
|
||||||
|
@ -55,8 +55,7 @@ def bootstrap_client_service(peer, core_inst=None, bootstrap_timeout=300):
|
|||||||
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)
|
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',
|
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))
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"display_header" : false,
|
"display_header" : false,
|
||||||
"minimum_block_pow": 4,
|
"minimum_block_pow": 4,
|
||||||
"minimum_send_pow": 4,
|
"minimum_send_pow": 4,
|
||||||
"socket_servers": false,
|
"socket_servers": true,
|
||||||
"security_level": 0,
|
"security_level": 0,
|
||||||
"max_block_age": 2678400,
|
"max_block_age": 2678400,
|
||||||
"bypass_tor_check": false,
|
"bypass_tor_check": false,
|
||||||
|
Loading…
Reference in New Issue
Block a user