Add Electrum Server Tor Service

This commit is contained in:
Taylor Helsper 2019-08-30 22:44:02 -05:00
parent 932c7dc7e6
commit 01a8d0a266
9 changed files with 187 additions and 48 deletions

View File

@ -210,4 +210,8 @@ SOCKSPort 9050
Log notice stdout
ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1
CookieAuthFileGroupReadable 1
# Hidden Service for Electrum Server
HiddenServiceDir /var/lib/tor/electrs_hidden_service/
HiddenServicePort 50001 127.0.0.1:50001

View File

@ -3,6 +3,7 @@ from config import *
from flask import Flask, render_template, Markup, send_from_directory, redirect, request, url_for
from bitcoind import mynode_bitcoind
from bitcoin_cli import mynode_bitcoin_cli
from tor import mynode_tor
from vpn import mynode_vpn
if CONFIG["electrs_enabled"]:
from electrum_server import *
@ -35,6 +36,7 @@ app.config['TEMPLATES_AUTO_RELOAD'] = True
app.register_blueprint(mynode_bitcoind)
app.register_blueprint(mynode_lnd)
app.register_blueprint(mynode_bitcoin_cli)
app.register_blueprint(mynode_tor)
if CONFIG["electrs_enabled"]:
app.register_blueprint(mynode_electrum_server)
app.register_blueprint(mynode_vpn)

View File

@ -93,6 +93,19 @@ a:active {
padding-bottom: 10px;
}
.app_tile_row_divider_left {
width: 50%;
float: left;
margin: 0px;
}
.app_tile_row_divider_right {
width: 50%;
float: right;
margin: 0px;
}
.app_tile_row {
margin: auto;
display: flex;
@ -100,6 +113,15 @@ a:active {
justify-content: center;
margin-bottom: 10px;
}
.app_tile_row_section {
margin: auto;
display: flex;
text-align: center;
justify-content: center;
margin-bottom: 0px;
margin-left: 20px;
margin-right: 20px;
}
.app_tile {
display: inline-block;
position: relative;

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -62,6 +62,19 @@
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-btcrpcexplorer">{% if btcrpcexplorer_enabled %}Disable{% else %}Enable{% endif %}</a>
</div>
</div>
<div class="app_tile">
<div class="app_status_icon {% if product_key_skipped %}gray{% else %}green{% endif %}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/tor.png")}}"/></div>
<div class="app_title">Tor Services</div>
<div class="app_status"></div>
<div class="app_contents">
{% if product_key_skipped %}
Premium Feature
{% else %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/tor">Tor Services</a>
{% endif %}
</div>
</div>
<div class="app_tile">
<div class="app_status_icon"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/cli.png")}}"/></div>
@ -70,35 +83,3 @@
<div class="app_contents"><a class="ui-button ui-widget ui-corner-all mynode_button" href="/bitcoin-cli">CLI</a></div>
</div>
</div>
<div class="main_header">Services</div>
<div class="app_tile_row">
<div class="app_tile">
<div class="app_status_icon {{ electrs_status_color }}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/electrum_logo.png")}}"/></div>
<div class="app_title">Electrum Server</div>
<div class="app_status">{{ electrs_status }}</div>
<div class="app_contents">
{% if electrs_enabled %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/electrum-server">Info</a>
{% endif %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-electrs">{% if electrs_enabled %}Disable{% else %}Enable{% endif %}</a>
</div>
</div>
<div class="app_tile">
<div class="app_status_icon {{ vpn_status_color }}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/vpn.png")}}"/></div>
<div class="app_title">VPN</div>
<div class="app_status">{{ vpn_status }}</div>
<div class="app_contents">
{% if product_key_skipped %}
Premium Feature
{% else %}
{% if vpn_enabled %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/vpn-info">Info</a>
{% endif %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-vpn">{% if vpn_enabled %}Disable{% else %}Enable{% endif %}</a>
{% endif %}
</div>
</div>
</div>

View File

@ -98,24 +98,61 @@
</div>
{% endif %}
<div class="main_header">Core Services</div>
<div class="app_tile_row">
<div class="app_tile">
<div class="app_status_icon {{ bitcoind_status_color }}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/bitcoin.png")}}"/></div>
<div class="app_title">Bitcoin</div>
<div class="app_status">{{ bitcoind_status }}</div>
<div class="app_contents">
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/bitcoind">Status</a>
<div>
<div class="main_header">Core Services</div>
<div class="app_tile_row_section">
<div class="app_tile">
<div class="app_status_icon {{ bitcoind_status_color }}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/bitcoin.png")}}"/></div>
<div class="app_title">Bitcoin</div>
<div class="app_status">{{ bitcoind_status }}</div>
<div class="app_contents">
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/bitcoind">Status</a>
</div>
</div>
<div class="app_tile">
<div class="app_status_icon {{ lnd_status_color }}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/lightning.png")}}"/></div>
<div class="app_title">Lightning</div>
<div class="app_status">{{ lnd_status }}</div>
<div class="app_contents">
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/lnd">Lightning Wallet</a>
</div>
</div>
</div>
</div>
<div class="app_tile">
<div class="app_status_icon {{ lnd_status_color }}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/lightning.png")}}"/></div>
<div class="app_title">Lightning</div>
<div class="app_status">{{ lnd_status }}</div>
<div class="app_contents">
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/lnd">Lightning Wallet</a>
<div>
<div class="main_header">Services</div>
<div class="app_tile_row_section">
<div class="app_tile">
<div class="app_status_icon {{ electrs_status_color }}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/electrum_logo.png")}}"/></div>
<div class="app_title">Electrum Server</div>
<div class="app_status">{{ electrs_status }}</div>
<div class="app_contents">
{% if electrs_enabled %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/electrum-server">Info</a>
{% endif %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-electrs">{% if electrs_enabled %}Disable{% else %}Enable{% endif %}</a>
</div>
</div>
<div class="app_tile">
<div class="app_status_icon {{ vpn_status_color }}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/vpn.png")}}"/></div>
<div class="app_title">VPN</div>
<div class="app_status">{{ vpn_status }}</div>
<div class="app_contents">
{% if product_key_skipped %}
Premium Feature
{% else %}
{% if vpn_enabled %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/vpn-info">Info</a>
{% endif %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-vpn">{% if vpn_enabled %}Disable{% else %}Enable{% endif %}</a>
{% endif %}
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,61 @@
<!DOCTYPE html lang="en">
<head>
<title>{{ title }}</title>
<link rel="shortcut icon" href="{{ url_for('static', filename='images/favicon.ico') }}">
<link rel="stylesheet" href="{{ url_for('static', filename="css/mynode.css")}}">
<link rel="stylesheet" href="{{ url_for('static', filename="css/mynode_bitcoind.css")}}">
<link href="{{ url_for('static', filename="jquery_ui/jquery-ui.css")}}" rel="stylesheet">
<meta http-equiv="Content-Language" content="en">
<meta name="google" content="notranslate">
<script src="{{ url_for('static', filename="js/jquery-3.3.1.min.js")}}"></script>
<script src="{{ url_for('static', filename="jquery_ui/jquery-ui.js")}}"></script>
<script src="{{ url_for('static', filename="js/mynode.js")}}"></script>
</head>
<body>
<div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename="images/logo.png")}}"/></a></div>
<div class="mynode_back_div">
<a class="ui-button ui-widget ui-corner-all mynode_back" href="/"><span class="ui-icon ui-icon-home"></span>home&nbsp;</a>
</div>
<div style="margin: auto; text-align: center;">
{{ message }}
</div>
<div class="main_header">Tor Services</div>
<br/>
<div class="app_tile_row">
<div class="info_tile">
<div class="info_tile_header">Bitcoin</div>
<div class="info_tile_contents">Tor Enabled</div>
</div>
<div class="info_tile">
<div class="info_tile_header">Lightning</div>
<div class="info_tile_contents">Tor Enabled</div>
</div>
</div>
<div class="app_tile_row">
<div class="info_tile">
<div class="info_tile_header">Electrum Server</div>
<div class="info_tile_contents">Tor Enabled</div>
</div>
<div class="info_tile">
<div class="info_tile_header">Onion Hostname</div>
<div class="info_tile_contents">{{electrs_onion_hostname}}</div>
</div>
<div class="info_tile">
<div class="info_tile_header">Electrum Command</div>
<div class="info_tile_contents">{{electrs_onion_command}}</div>
</div>
<div class="info_tile">
<div class="info_tile_header">Help</div>
<div class="info_tile_contents"><a href="http://docs.electrum.org/en/latest/tor.html" target="_blank">Link</a></div>
</div>
</div>
{% include 'includes/footer.html' %}
</body>
</html>

View File

@ -0,0 +1,32 @@
from flask import Blueprint, render_template, session, abort, Markup, request, redirect
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from pprint import pprint, pformat
import os
import json
import time
import subprocess
mynode_tor = Blueprint('mynode_tor',__name__)
### Page functions
@mynode_tor.route("/tor")
def page_tor():
electrs_onion_hostname = "..."
electrs_onion_command = "..."
# Get Onion URLs
if os.path.isfile("/var/lib/tor/electrs_hidden_service/hostname"):
with open("/var/lib/tor/electrs_hidden_service/hostname") as f:
electrs_onion_hostname = f.read().strip()
electrs_onion_command = "./electrum -1 -s {}:50001:t -p socks5:localhost:9050".format(electrs_onion_hostname)
else:
electrs_onion_hostname = "disabled"
electrs_onion_command = "disabled"
# Load page
templateData = {
"title": "myNode Tor Services",
"electrs_onion_hostname": electrs_onion_hostname,
"electrs_onion_command": electrs_onion_command
}
return render_template('tor.html', **templateData)