Show and use tor addresses for dynamic apps
This commit is contained in:
parent
6fa7bac182
commit
28c7e72088
|
@ -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,
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 %}
|
||||
<a class="ui-button ui-widget ui-corner-all mynode_button"
|
||||
{% if app.app_tile_button_onclick != "" %} onclick="{{app.app_tile_button_onclick}}" {% endif %}
|
||||
{% if app.app_tile_button_onclick != "" %} onclick="{{app.app_tile_button_onclick|safe}}" {% endif %}
|
||||
href="{{app.app_tile_button_href}}"
|
||||
id="{{app.short_name}}">{{app.app_tile_button_text}}</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user