move tor start finished message to bottom during merge from work on fixing onboarding
This commit is contained in:
commit
59a1ad1235
@ -4,7 +4,7 @@ All HTTP interfaces in the Onionr reference client use the [Flask](http://flask.
|
|||||||
|
|
||||||
## Client & Public difference
|
## Client & Public difference
|
||||||
|
|
||||||
The client API server is a locked down interface intended for authenticated local communication.
|
The client API server is a locked down interface intended for authenticated local communication.
|
||||||
|
|
||||||
The public API server is available only remotely from Tor & I2P. It is the interface in which peers use to communicate with one another.
|
The public API server is available only remotely from Tor & I2P. It is the interface in which peers use to communicate with one another.
|
||||||
|
|
||||||
@ -73,6 +73,9 @@ Please note: endpoints that simply provide static web app files are not document
|
|||||||
* /insertblock
|
* /insertblock
|
||||||
- Methods: POST
|
- Methods: POST
|
||||||
- Accepts JSON data for creating a new block. 'message' contains the block data, 'to' specifies the peer's public key to encrypt the data to, 'sign' is a boolean for signing the message.
|
- Accepts JSON data for creating a new block. 'message' contains the block data, 'to' specifies the peer's public key to encrypt the data to, 'sign' is a boolean for signing the message.
|
||||||
|
* /torready
|
||||||
|
- Methods: POST
|
||||||
|
- Returns boolean if Tor is started or not
|
||||||
|
|
||||||
# Public API
|
# Public API
|
||||||
|
|
||||||
|
@ -242,8 +242,12 @@ class OnionrCommunicatorDaemon:
|
|||||||
'First run detected. Run openhome to get setup.',
|
'First run detected. Run openhome to get setup.',
|
||||||
terminal=True)
|
terminal=True)
|
||||||
|
|
||||||
while not config.get('onboarding.done', True):
|
while not config.get('onboarding.done', True) and \
|
||||||
time.sleep(5)
|
not self.shutdown:
|
||||||
|
try:
|
||||||
|
time.sleep(2)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
self.shutdown = True
|
||||||
|
|
||||||
# Main daemon loop, mainly for calling timers,
|
# Main daemon loop, mainly for calling timers,
|
||||||
# don't do any complex operations here to avoid locking
|
# don't do any complex operations here to avoid locking
|
||||||
|
@ -7,8 +7,8 @@ import subprocess
|
|||||||
import platform
|
import platform
|
||||||
|
|
||||||
from flask import Response, Blueprint, request, send_from_directory, abort
|
from flask import Response, Blueprint, request, send_from_directory, abort
|
||||||
|
from flask import g
|
||||||
from gevent import spawn
|
from gevent import spawn
|
||||||
from gevent import sleep
|
|
||||||
import unpaddedbase32
|
import unpaddedbase32
|
||||||
|
|
||||||
from httpapi import apiutils
|
from httpapi import apiutils
|
||||||
@ -126,13 +126,17 @@ class PrivateEndpoints:
|
|||||||
|
|
||||||
@private_endpoints_bp.route('/gettorsocks')
|
@private_endpoints_bp.route('/gettorsocks')
|
||||||
def get_tor_socks():
|
def get_tor_socks():
|
||||||
return Response(str(client_api._too_many.get(NetController).socksPort))
|
return Response(str(g.too_many.get(NetController).socksPort))
|
||||||
|
|
||||||
@private_endpoints_bp.route('/setonboarding', methods=['POST'])
|
@private_endpoints_bp.route('/setonboarding', methods=['POST'])
|
||||||
def set_onboarding():
|
def set_onboarding():
|
||||||
return Response(config.onboarding.set_config_from_onboarding(request.get_json()))
|
return Response(config.onboarding.set_config_from_onboarding(request.get_json()))
|
||||||
|
|
||||||
@private_endpoints_bp.route('/os')
|
@private_endpoints_bp.route('/os')
|
||||||
def get_os_system():
|
def get_os_system():
|
||||||
return Response(platform.system().lower())
|
return Response(platform.system().lower())
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/torready')
|
||||||
|
def is_tor_ready():
|
||||||
|
"""If Tor is starting up, the web UI is not ready to be used."""
|
||||||
|
return Response(str(g.too_many.get(NetController).readyState).lower())
|
||||||
|
@ -13,7 +13,6 @@ import platform # For windows sigkill workaround
|
|||||||
|
|
||||||
from onionrtypes import BooleanSuccessState
|
from onionrtypes import BooleanSuccessState
|
||||||
import logger
|
import logger
|
||||||
import filepaths
|
|
||||||
from .. import getopenport
|
from .. import getopenport
|
||||||
from .. import watchdog
|
from .. import watchdog
|
||||||
from . import customtorrc
|
from . import customtorrc
|
||||||
@ -114,11 +113,6 @@ class NetController:
|
|||||||
logger.fatal('Got keyboard interrupt. Onionr will exit soon.', timestamp = False, terminal=True)
|
logger.fatal('Got keyboard interrupt. Onionr will exit soon.', timestamp = False, terminal=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
logger.info('Finished starting Tor.', terminal=True)
|
|
||||||
logger.info('Connecting to Onionr soon', terminal=True)
|
|
||||||
|
|
||||||
self.readyState = True
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
myID = open(self.dataDir + 'hs/hostname', 'r')
|
myID = open(self.dataDir + 'hs/hostname', 'r')
|
||||||
self.myID = myID.read().replace('\n', '')
|
self.myID = myID.read().replace('\n', '')
|
||||||
@ -131,6 +125,10 @@ class NetController:
|
|||||||
|
|
||||||
multiprocessing.Process(target=watchdog.watchdog,
|
multiprocessing.Process(target=watchdog.watchdog,
|
||||||
args=[os.getpid(), tor.pid]).start()
|
args=[os.getpid(), tor.pid]).start()
|
||||||
|
|
||||||
|
logger.info('Finished starting Tor.', terminal=True)
|
||||||
|
|
||||||
|
self.readyState = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def killTor(self):
|
def killTor(self):
|
||||||
|
@ -3,9 +3,12 @@
|
|||||||
Open the web interface properly into a web browser
|
Open the web interface properly into a web browser
|
||||||
"""
|
"""
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
import logger
|
import logger
|
||||||
from onionrutils import getclientapiserver
|
from onionrutils import getclientapiserver
|
||||||
import config
|
import config
|
||||||
|
from onionrutils.localcommand import local_command
|
||||||
"""
|
"""
|
||||||
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
|
||||||
@ -22,8 +25,27 @@ import config
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def _tell_if_ui_not_ready():
|
||||||
|
if local_command('/torready') != 'true':
|
||||||
|
logger.warn('The UI is not ready yet, waiting on Tor to start.', terminal=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _wait_for_ui_to_be_ready():
|
||||||
|
if config.get('general.offline_mode', False) or \
|
||||||
|
not config.get('transports.tor', True) or \
|
||||||
|
config.get('tor.use_existing_tor'):
|
||||||
|
return
|
||||||
|
_tell_if_ui_not_ready()
|
||||||
|
while local_command('/torready') != 'true':
|
||||||
|
sleep(0.5)
|
||||||
|
logger.info("Tor is ready, opening UI", terminal=True)
|
||||||
|
|
||||||
|
|
||||||
def get_url() -> str:
|
def get_url() -> str:
|
||||||
"""Build UI URL string and return it."""
|
"""Build UI URL string and return it."""
|
||||||
|
onboarding = ""
|
||||||
|
if not config.get('onboarding.done', False):
|
||||||
|
onboarding = "onboarding/"
|
||||||
try:
|
try:
|
||||||
url = getclientapiserver.get_client_API_server()
|
url = getclientapiserver.get_client_API_server()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
@ -32,7 +54,7 @@ def get_url() -> str:
|
|||||||
'Onionr seems to not be running (could not get api host)',
|
'Onionr seems to not be running (could not get api host)',
|
||||||
terminal=True)
|
terminal=True)
|
||||||
else:
|
else:
|
||||||
url = 'http://%s/#%s' % (url, config.get('client.webpassword'))
|
url = 'http://%s/%s#%s' % (url, onboarding, config.get('client.webpassword'))
|
||||||
logger.info('Onionr web interface URL: ' + url, terminal=True)
|
logger.info('Onionr web interface URL: ' + url, terminal=True)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
@ -50,7 +72,8 @@ def open_home():
|
|||||||
'Onionr seems to not be running (could not get api host)',
|
'Onionr seems to not be running (could not get api host)',
|
||||||
terminal=True)
|
terminal=True)
|
||||||
else:
|
else:
|
||||||
url = 'http://%s/#%s' % (url, config.get('client.webpassword'))
|
_wait_for_ui_to_be_ready()
|
||||||
|
url = get_url()
|
||||||
logger.info(
|
logger.info(
|
||||||
'If Onionr does not open automatically, use this URL: ' + url,
|
'If Onionr does not open automatically, use this URL: ' + url,
|
||||||
terminal=True)
|
terminal=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user