mirror of
https://github.com/mynodebtc/mynode.git
synced 2024-12-25 14:08:07 +00:00
Add Link and QR Code for Tor Services
This commit is contained in:
parent
3dca8232e6
commit
14b37cf92e
|
@ -119,7 +119,7 @@ echo "" > /etc/nginx/sites-available/default
|
|||
dpkg --configure -a
|
||||
|
||||
# Install any pip software
|
||||
pip2 install tzupdate virtualenv pysocks redis --no-cache-dir
|
||||
pip2 install tzupdate virtualenv pysocks redis qrcode image --no-cache-dir
|
||||
|
||||
|
||||
# Update Python3 to 3.7.X
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
from flask import Blueprint, render_template, redirect, jsonify, request
|
||||
from flask import Blueprint, render_template, redirect, jsonify, request, send_file
|
||||
from flask import current_app as app
|
||||
from user_management import check_logged_in
|
||||
from bitcoin_info import *
|
||||
|
@ -10,6 +10,8 @@ from dojo import get_dojo_status
|
|||
from whirlpool import get_whirlpool_status
|
||||
from thread_functions import *
|
||||
from systemctl_info import *
|
||||
import qrcode
|
||||
import cStringIO
|
||||
import json
|
||||
import subprocess
|
||||
import re
|
||||
|
@ -138,3 +140,14 @@ def api_homepage_needs_refresh():
|
|||
data["needs_refresh"] = "yes"
|
||||
|
||||
return jsonify(data)
|
||||
|
||||
@mynode_api.route("/api/get_qr_code_image")
|
||||
def api_get_qr_code_image():
|
||||
img_buf = cStringIO.StringIO()
|
||||
url = "ERROR"
|
||||
if request.args.get("url"):
|
||||
url = request.args.get("url")
|
||||
img = generate_qr_code(url)
|
||||
img.save(img_buf)
|
||||
img_buf.seek(0)
|
||||
return send_file(img_buf, mimetype='image/png')
|
|
@ -15,6 +15,7 @@ import subprocess
|
|||
import random
|
||||
import string
|
||||
import redis
|
||||
import qrcode
|
||||
|
||||
# Globals
|
||||
local_ip = "unknown"
|
||||
|
@ -1142,8 +1143,24 @@ def get_firewall_rules():
|
|||
rules = "ERROR"
|
||||
return rules
|
||||
|
||||
|
||||
#==================================
|
||||
# BTC RPC Explorer Functions
|
||||
#==================================
|
||||
def get_btcrpcexplorer_sso_token():
|
||||
return get_file_contents("/opt/mynode/btc-rpc-explorer/token")
|
||||
|
||||
|
||||
#==================================
|
||||
# QR Code Functions
|
||||
#==================================
|
||||
def generate_qr_code(url):
|
||||
qr = qrcode.QRCode(version=1,
|
||||
error_correction=qrcode.constants.ERROR_CORRECT_H,
|
||||
box_size=5,
|
||||
border=1)
|
||||
|
||||
qr.add_data(url)
|
||||
qr.make(fit=True)
|
||||
img = qr.make_image()
|
||||
return img
|
BIN
rootfs/standard/var/www/mynode/static/images/qr_code.png
Normal file
BIN
rootfs/standard/var/www/mynode/static/images/qr_code.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
|
@ -44,6 +44,10 @@
|
|||
height: 400,
|
||||
correctLevel : QRCode.CorrectLevel.H
|
||||
});
|
||||
|
||||
{% for service in v3_services %}
|
||||
$("#{{ service.id }}").tooltip({ content: "<img style='width: 300px; height: 300px;' src='/api/get_qr_code_image?url={{ service.link }}'/>" });
|
||||
{% endfor %}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
|
@ -89,6 +93,7 @@
|
|||
<br/><br/>
|
||||
<button id="show_onion_urls" class="ui-button ui-widget ui-corner-all">Show Onion URLs</button>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<div class="sub_header">v3 Addresses</div>
|
||||
<table class="bitcoind_table">
|
||||
|
@ -96,6 +101,8 @@
|
|||
<td>Service</td>
|
||||
<td>Address</td>
|
||||
<td>Port</td>
|
||||
<td>Link</td>
|
||||
<td></td>
|
||||
<td>Guide</td>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -107,6 +114,16 @@
|
|||
<span class="onion_url_placeholder">..................................................</span>
|
||||
</td>
|
||||
<td>{{ service.port }}</td>
|
||||
<td>
|
||||
{% if service.show_link %}
|
||||
<a href="{{ service.link }}" target="_blank">Link</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if service.show_link %}
|
||||
<img id="{{ service.id }}" style="width: 18px;" title="" src="{{ url_for('static', filename="images/qr_code.png") }}"/>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if service.guide|length %}
|
||||
<a href="{{ service.guide }}" target="_blank">Guide</a>
|
||||
|
@ -116,6 +133,7 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
|
||||
<div class="sub_header">v2 Addresses</div>
|
||||
<table class="bitcoind_table">
|
||||
|
|
|
@ -10,6 +10,29 @@ import subprocess
|
|||
|
||||
mynode_tor = Blueprint('mynode_tor',__name__)
|
||||
|
||||
def create_v3_service(name, url, port, show_link, guide, force_https=False):
|
||||
service = {}
|
||||
service["service"] = name
|
||||
service["id"] = name.replace(" ","").replace("(","").replace(")","").lower()
|
||||
service["url"] = url
|
||||
service["port"] = port
|
||||
service["show_link"] = show_link
|
||||
service["link"] = ""
|
||||
if show_link:
|
||||
try:
|
||||
if "/" in port:
|
||||
p = port.split("/")[1].strip()
|
||||
service["link"] = "https://"+url+":"+p
|
||||
else:
|
||||
if force_https:
|
||||
service["link"] = "https://"+url+":"+port
|
||||
else:
|
||||
service["link"] = "http://"+url+":"+port
|
||||
except:
|
||||
service["link"] = "URL_ERROR"
|
||||
service["guide"] = guide
|
||||
return service
|
||||
|
||||
### Page functions
|
||||
@mynode_tor.route("/tor")
|
||||
def page_tor():
|
||||
|
@ -32,26 +55,26 @@ def page_tor():
|
|||
|
||||
# Services
|
||||
v3_services = []
|
||||
v3_services.append({"service": "myNode Web", "url": general_onion_url, "port": "80","guide":""})
|
||||
v3_services.append({"service": "WebSSH", "url": general_onion_url,"port": "2222 / 2223","guide":""})
|
||||
v3_services.append({"service": "LND Hub", "url": general_onion_url,"port": "3000 / 3001","guide":""})
|
||||
v3_services.append({"service": "BTC RPC Explorer", "url": general_onion_url,"port": "3002 / 3003","guide":""})
|
||||
v3_services.append({"service": "Ride the Lightning", "url": general_onion_url,"port": "3010 / 3011","guide":""})
|
||||
v3_services.append({"service": "Caravan", "url": general_onion_url,"port": "3020","guide":""})
|
||||
v3_services.append({"service": "Thunderhub", "url": general_onion_url,"port": "3030 / 3031","guide":""})
|
||||
v3_services.append({"service": "Mempool", "url": general_onion_url,"port": "4080 / 4081","guide":""})
|
||||
v3_services.append({"service": "LNbits", "url": general_onion_url,"port": "5000 / 5001","guide":""})
|
||||
v3_services.append({"service": "Whirlpool", "url": general_onion_url,"port": "8899","guide":""})
|
||||
v3_services.append({"service": "Netdata", "url": general_onion_url,"port": "19999 / 20000","guide":""})
|
||||
v3_services.append({"service": "Specter Desktop", "url": general_onion_url,"port": "25441","guide":""})
|
||||
v3_services.append({"service": "Glances", "url": general_onion_url,"port": "61208 / 61209","guide":""})
|
||||
v3_services.append({"service": "BTCPay Server", "url": btcpay_onion_url,"port": "49392 / 49393","guide":""})
|
||||
v3_services.append({"service": "Bitcoin API (REST)", "url": btc_onion_url,"port": "8332","guide":""})
|
||||
v3_services.append({"service": "LND API (gRPC)", "url": lnd_onion_url,"port": "10009","guide":""})
|
||||
v3_services.append({"service": "LND API (REST)", "url": lnd_onion_url,"port": "10080","guide":""})
|
||||
v3_services.append({"service": "SSH", "url": ssh_onion_url, "port": "22022","guide":""})
|
||||
v3_services.append({"service": "Electrum Server", "url": electrs_onion_url,"port": "50001","guide":"https://mynodebtc.com/guide/electrum_server_tor"})
|
||||
v3_services.append({"service": "Electrum Server", "url": electrs_onion_url,"port": "50002","guide":"https://mynodebtc.com/guide/electrum_server_tor"})
|
||||
v3_services.append(create_v3_service("myNode Web", general_onion_url, "80", True, ""))
|
||||
v3_services.append(create_v3_service("WebSSH", general_onion_url, "2222 / 2223", True, ""))
|
||||
v3_services.append(create_v3_service("LND Hub", general_onion_url, "3000 / 3001", True, ""))
|
||||
v3_services.append(create_v3_service("BTC RPC Explorer", general_onion_url, "3002 / 3003", False, ""))
|
||||
v3_services.append(create_v3_service("Ride the Lightning", general_onion_url, "3010 / 3011", True, ""))
|
||||
v3_services.append(create_v3_service("Caravan", general_onion_url, "3020", True, ""))
|
||||
v3_services.append(create_v3_service("Thunderhub", general_onion_url, "3030 / 3031", True, ""))
|
||||
v3_services.append(create_v3_service("Mempool", general_onion_url, "4080 / 4081", True, ""))
|
||||
v3_services.append(create_v3_service("LNbits", general_onion_url, "5000 / 5001", True, ""))
|
||||
v3_services.append(create_v3_service("Whirlpool", general_onion_url, "8899", False, ""))
|
||||
v3_services.append(create_v3_service("Netdata", general_onion_url, "19999 / 20000", True, ""))
|
||||
v3_services.append(create_v3_service("Specter Desktop", general_onion_url, "25441", True, "", force_https=True))
|
||||
v3_services.append(create_v3_service("Glances", general_onion_url, "61208 / 61209", True, ""))
|
||||
v3_services.append(create_v3_service("BTCPay Server", btcpay_onion_url, "49392 / 49393", True, ""))
|
||||
v3_services.append(create_v3_service("Bitcoin API (REST)", btc_onion_url, "8332", False, ""))
|
||||
v3_services.append(create_v3_service("LND API (gRPC)", lnd_onion_url, "10009", False, ""))
|
||||
v3_services.append(create_v3_service("LND API (REST)", lnd_onion_url, "10080", False, ""))
|
||||
v3_services.append(create_v3_service("SSH", ssh_onion_url, "22022", False, ""))
|
||||
v3_services.append(create_v3_service("Electrum Server", electrs_onion_url, "50001", False, "https://mynodebtc.com/guide/electrum_server_tor"))
|
||||
v3_services.append(create_v3_service("Electrum Server", electrs_onion_url, "50002", False, "https://mynodebtc.com/guide/electrum_server_tor"))
|
||||
|
||||
v2_services = []
|
||||
v2_services.append({"service": "Bitcoin API (REST)", "url": btc_info_v2["url"], "password": btc_info_v2["pass"], "port": "8332","guide":""})
|
||||
|
|
|
@ -199,7 +199,7 @@ pip2 install --upgrade wheel
|
|||
pip2 install speedtest-cli transmissionrpc flask python-bitcoinrpc redis prometheus_client requests
|
||||
pip2 install python-pam python-bitcoinlib psutil
|
||||
pip2 install grpcio grpcio-tools googleapis-common-protos
|
||||
pip2 install tzupdate virtualenv pysocks redis
|
||||
pip2 install tzupdate virtualenv pysocks redis qrcode image
|
||||
|
||||
|
||||
# Update Python3 to 3.7.X
|
||||
|
|
Loading…
Reference in New Issue
Block a user