2019-03-24 02:56:46 +00:00
|
|
|
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):
|
2019-04-02 16:50:09 +00:00
|
|
|
signer = utils.bytesToStr(bl.signer)
|
2019-03-24 02:56:46 +00:00
|
|
|
daemon.active_services.append(b)
|
2019-04-02 16:50:09 +00:00
|
|
|
daemon.active_services.append(signer)
|
|
|
|
daemon.services.create_server(signer, bs)
|
2019-03-24 02:56:46 +00:00
|
|
|
|
|
|
|
daemon.decrementThreadCount('service_creator')
|