show web url every time onionr daemon starts

This commit is contained in:
Kevin Froman 2021-01-16 02:08:36 +00:00
parent 1042676f26
commit ad91a3222f
3 changed files with 28 additions and 15 deletions

View File

@ -141,11 +141,11 @@ class OnionrCommunicatorDaemon:
daemoneventhooks.daemon_event_handlers(shared_state) daemoneventhooks.daemon_event_handlers(shared_state)
get_url()
if not config.get('onboarding.done', True): if not config.get('onboarding.done', True):
logger.info( logger.info(
'First run detected. Run openhome to get setup.', 'First run detected. Run openhome to get setup.',
terminal=True) terminal=True)
get_url()
while not config.get('onboarding.done', True) and \ while not config.get('onboarding.done', True) and \
not self.shared_state.get_by_string( not self.shared_state.get_by_string(

View File

@ -0,0 +1,24 @@
"""Onionr - Private P2P Communication.
Open the web interface properly into a web browser, and return it
"""
import logger
from onionrutils import getclientapiserver
def get_url(config) -> str:
"""Build UI URL string and return it."""
onboarding = ""
if not config.get('onboarding.done', False):
onboarding = "onboarding/"
try:
url = getclientapiserver.get_client_API_server()
except FileNotFoundError:
url = ""
logger.error(
'Onionr seems to not be running (could not get api host)',
terminal=True)
else:
url = 'http://%s/%s#%s' % (url, onboarding, config.get('client.webpassword'))
logger.info('Onionr web interface URL: ' + url, terminal=True)
return url

View File

@ -9,6 +9,8 @@ import logger
from onionrutils import getclientapiserver from onionrutils import getclientapiserver
import config import config
from onionrutils.localcommand import local_command from onionrutils.localcommand import local_command
from .daemonlaunch import geturl
""" """
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -43,20 +45,7 @@ def _wait_for_ui_to_be_ready():
def get_url() -> str: def get_url() -> str:
"""Build UI URL string and return it.""" """Build UI URL string and return it."""
onboarding = "" geturl.get_url(config)
if not config.get('onboarding.done', False):
onboarding = "onboarding/"
try:
url = getclientapiserver.get_client_API_server()
except FileNotFoundError:
url = ""
logger.error(
'Onionr seems to not be running (could not get api host)',
terminal=True)
else:
url = 'http://%s/%s#%s' % (url, onboarding, config.get('client.webpassword'))
logger.info('Onionr web interface URL: ' + url, terminal=True)
return url
get_url.onionr_help = "Shows the Onionr " # type: ignore get_url.onionr_help = "Shows the Onionr " # type: ignore