def _core(socket, backend_host, backend_watchdog,
debug, identity, identity_key, i_am_john, cache_size):
app = unix_socket_app.UnixSocketApplication()
components = core_components_factory(app, backend_host, backend_watchdog, cache_size)
dispatcher = components.get_dispatcher()
register_core_api(app, dispatcher)
# TODO: remove me once RSA key loading and backend handling are easier
if i_am_john:
async def load_identity(app):
from parsec.core.identity import EIdentityLoad
eff = Effect(EIdentityLoad(JOHN_DOE_IDENTITY, JOHN_DOE_PRIVATE_KEY))
await asyncio_perform(dispatcher, eff)
print('Welcome back M. Doe')
app.on_startup.append(load_identity)
elif identity:
async def load_identity(app):
from parsec.core.identity import EIdentityLoad, EIdentityLogin
if identity_key:
print("Reading %s's key from `%s`" % (identity, identity_key))
password = getpass()
eff = Effect(EIdentityLoad(identity, identity_key.read(), password))
await asyncio_perform(dispatcher, eff)
else:
print("Fetching %s's key from backend privkey store." % (identity))
password = getpass()
eff = Effect(EIdentityLogin(identity, password))
await asyncio_perform(dispatcher, eff)
print('Connected as %s' % identity)
app.on_startup.append(load_identity)
if debug:
loop = asyncio.get_event_loop()
loop.set_debug(True)
else:
logger_stream.level = WARNING
print('Starting parsec core on %s (connecting to backend %s)' % (socket, backend_host))
unix_socket_app.run_app(app, path=socket)
print('Bye ;-)')
评论列表
文章目录