diff --git a/rootfs/standard/usr/share/mynode_apps/lndg/lndg.json b/rootfs/standard/usr/share/mynode_apps/lndg/lndg.json index 39eeda78..fb89de67 100644 --- a/rootfs/standard/usr/share/mynode_apps/lndg/lndg.json +++ b/rootfs/standard/usr/share/mynode_apps/lndg/lndg.json @@ -12,7 +12,7 @@ "hide_status_icon": false, "app_tile_default_status_text": "Lightning Tool", "app_tile_running_status_text": "Running", - "app_tile_button_onclick": "open_app_in_new_tab({HTTP_PORT})", + "app_tile_button_onclick": "open_app_in_new_tab({HTTP_PORT}, {HTTPS_PORT}, false, '{APP_TOR_ADDRESS}')", "can_uninstall": true, "can_enable_disable": true, "show_on_application_page": true, diff --git a/rootfs/standard/var/pynode/application_info.py b/rootfs/standard/var/pynode/application_info.py index fa36a0cf..ab1fa207 100644 --- a/rootfs/standard/var/pynode/application_info.py +++ b/rootfs/standard/var/pynode/application_info.py @@ -109,6 +109,7 @@ def replace_app_info_variables(app_data, text): text = text.replace("{HTTP_PORT}", app_data["http_port"]) if app_data["https_port"] != None: text = text.replace("{HTTPS_PORT}", app_data["https_port"]) + text = text.replace("{APP_TOR_ADDRESS}", get_onion_url_for_service(app_data["short_name"])) return text def initialize_application_defaults(app): diff --git a/rootfs/standard/var/pynode/device_info.py b/rootfs/standard/var/pynode/device_info.py index e220b6f7..d49cb06e 100644 --- a/rootfs/standard/var/pynode/device_info.py +++ b/rootfs/standard/var/pynode/device_info.py @@ -1248,6 +1248,16 @@ def get_onion_url_sphinxrelay(): pass return "error" +def get_onion_url_for_service(short_name): + if is_community_edition(): return "not_available" + try: + if os.path.isfile("/var/lib/tor/mynode_{}/hostname".format(short_name)): + with open("/var/lib/tor/mynode_{}/hostname".format(short_name)) as f: + return f.read().strip() + except: + pass + return "error" + def get_onion_info_btc_v2(): info = {} info["url"] = "unknown" diff --git a/rootfs/standard/var/www/mynode/templates/includes/apps.html b/rootfs/standard/var/www/mynode/templates/includes/apps.html index 7aeaeaa5..24b8f69b 100644 --- a/rootfs/standard/var/www/mynode/templates/includes/apps.html +++ b/rootfs/standard/var/www/mynode/templates/includes/apps.html @@ -22,7 +22,7 @@ {% if not is_installing_docker_images or ( is_installing_docker_images and not app.requires_docker_image_installation ) %} {% if app.is_enabled or not app.can_enable_disable %} {{app.app_tile_button_text}} {% endif %} diff --git a/rootfs/standard/var/www/mynode/templates/main.html b/rootfs/standard/var/www/mynode/templates/main.html index 32a54ff1..7813ac53 100644 --- a/rootfs/standard/var/www/mynode/templates/main.html +++ b/rootfs/standard/var/www/mynode/templates/main.html @@ -252,7 +252,7 @@ port_string="" if (is_using_tor() && custom_tor_address != "NA") { - hostname="{{custom_tor_address}}" + hostname=custom_tor_address // Use "default" port - either 80 or 443 for HTTP/HTTPS unless overriden if (protocol == "http:" && tor_http_port != "80") { port_string=":"+tor_http_port @@ -260,6 +260,12 @@ if (protocol == "https:" && tor_https_port != "443") { port_string=":"+tor_https_port } + + // If app is HTTP only + if (tor_https_port == "NA") { + protocol = "http:" + port_string = ":"+tor_http_port + } } else { if (protocol == "http:" && http_port != "80") { port_string=":"+http_port @@ -267,14 +273,11 @@ if (protocol == "https:" && https_port != "443") { port_string=":"+https_port } - } - // If app is HTTP only - if (https_port == "NA") { - protocol = "http:" - port_string = ":"+http_port - if (is_using_tor() && custom_tor_address == "NA") { - port_string=":"+tor_http_port + // If app is HTTP only + if (https_port == "NA") { + protocol = "http:" + port_string = ":"+http_port } } diff --git a/rootfs/standard/var/www/mynode/tor.py b/rootfs/standard/var/www/mynode/tor.py index de9c35dd..4a5787d6 100644 --- a/rootfs/standard/var/www/mynode/tor.py +++ b/rootfs/standard/var/www/mynode/tor.py @@ -2,6 +2,7 @@ from flask import Blueprint, render_template, session, abort, Markup, request, r from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException from pprint import pprint, pformat from device_info import * +from application_info import * from user_management import check_logged_in import os import json @@ -33,6 +34,19 @@ def create_v3_service(name, url, port, show_link, guide, force_https=False): service["guide"] = guide return service +def add_dynamic_app_v3_services(v3_services): + show_link = True + guide = "" + app_names = get_dynamic_app_names() + for short_name in app_names: + app = get_application(short_name) + if app["is_installed"]: + onion_url = get_onion_url_for_service(short_name) + if "http_port" in app and app["http_port"] != None: + v3_services.append(create_v3_service(app["name"] + " (HTTP)", onion_url, "80", show_link, guide, force_https=False)) + if "https_port" in app and app["https_port"] != None: + v3_services.append(create_v3_service(app["name"] + " (HTTPS)", onion_url, "443", show_link, guide, force_https=True)) + ### Page functions @mynode_tor.route("/tor") def page_tor(): @@ -77,6 +91,8 @@ def page_tor(): v3_services.append(create_v3_service("Electrum Server", electrs_onion_url, "50001", False, "https://mynodebtc.github.io/tor/electrum.html")) v3_services.append(create_v3_service("Electrum Server", electrs_onion_url, "50002", False, "https://mynodebtc.github.io/tor/electrum.html")) v3_services.append(create_v3_service("Sphinx Relay", sphinxrelay_onion_url, "53001", True, "")) + + add_dynamic_app_v3_services(v3_services) # App links rpc_password = get_bitcoin_rpc_password()