Upgrade to Tor v3

This commit is contained in:
Taylor Helsper 2020-03-08 23:20:45 -05:00
parent de1126bbe0
commit f9d918c814
8 changed files with 60 additions and 41 deletions

View File

@ -214,22 +214,28 @@ CookieAuthFileGroupReadable 1
# Hidden Service for myNode
HiddenServiceDir /var/lib/tor/mynode/
HiddenServiceVersion 2
HiddenServiceAuthorizeClient stealth mynode
HiddenServiceVersion 3
HiddenServicePort 80 127.0.0.1:80
HiddenServicePort 443 127.0.0.1:443
HiddenServicePort 2222 127.0.0.1:2222
HiddenServicePort 3000 127.0.0.1:3000
HiddenServicePort 3002 127.0.0.1:3002
#HiddenServicePort 3004 127.0.0.1:3004
HiddenServicePort 3010 127.0.0.1:3010
HiddenServicePort 4080 127.0.0.1:4080
HiddenServicePort 8332 127.0.0.1:8332
HiddenServicePort 8899 127.0.0.1:8899
HiddenServicePort 10009 127.0.0.1:10009
HiddenServicePort 10080 127.0.0.1:10080
HiddenServicePort 19999 127.0.0.1:19999
HiddenServicePort 49392 127.0.0.1:49392
HiddenServicePort 50001 127.0.0.1:50001
HiddenServicePort 50002 127.0.0.1:50002
HiddenServicePort 61208 127.0.0.1:61208
# Hidden Service for myNode (BTC)
HiddenServiceDir /var/lib/tor/mynode_btc/
HiddenServiceVersion 3
HiddenServicePort 8332 127.0.0.1:8332
# Hidden Service for myNode (LND)
HiddenServiceDir /var/lib/tor/mynode_lnd/
HiddenServiceVersion 3
HiddenServicePort 10009 127.0.0.1:10009
HiddenServicePort 10080 127.0.0.1:10080

View File

@ -28,7 +28,7 @@ while true; do
done
# Find URLs
LND_TOR_ADDR=$(cat /var/lib/tor/mynode/hostname | awk '{print $1}')
LND_TOR_ADDR=$(cat /var/lib/tor/mynode_lnd/hostname)
LOCAL_IP_ADDR=$(hostname -I | head -n 1)
# Generate QR Codes

View File

@ -4,6 +4,6 @@ nat=false
[Tor]
tor.active=true
tor.v2=true
tor.v3=true
tor.streamisolation=true

View File

@ -463,6 +463,33 @@ def disable_btc_lnd_tor():
os.system("rm -f mnt/hdd/mynode/settings/.btc_lnd_tor_enabled")
os.system("sync")
def get_onion_url_general():
try:
if os.path.isfile("/var/lib/tor/mynode/hostname"):
with open("/var/lib/tor/mynode/hostname") as f:
return f.read()
except:
pass
return "error"
def get_onion_url_btc():
try:
if os.path.isfile("/var/lib/tor/mynode_btc/hostname"):
with open("/var/lib/tor/mynode_btc/hostname") as f:
return f.read()
except:
pass
return "error"
def get_onion_url_lnd():
try:
if os.path.isfile("/var/lib/tor/mynode_lnd/hostname"):
with open("/var/lib/tor/mynode_lnd/hostname") as f:
return f.read()
except:
pass
return "error"
#==================================
# Firewall Functions

View File

@ -36,17 +36,14 @@ def electrum_server_page():
# Get Onion URLs
electrs_onion_hostname = "..."
electrs_onion_password = "..."
electrs_onion_command = "..."
if os.path.isfile("/var/lib/tor/mynode/hostname"):
with open("/var/lib/tor/mynode/hostname") as f:
contents = f.read().split()
electrs_onion_hostname = contents[0]
electrs_onion_password = contents[1]
electrs_onion_hostname = contents
electrs_onion_command = "./electrum -1 -s {}:50002:s -p socks5:localhost:9050".format(electrs_onion_hostname)
else:
electrs_onion_hostname = "disabled"
electrs_onion_password = "disabled"
electrs_onion_command = "disabled"
# Load page
@ -62,7 +59,6 @@ def electrum_server_page():
"server_secure_port": server_secure_port,
"electrs_command": electrs_command,
"electrs_onion_hostname": electrs_onion_hostname,
"electrs_onion_password": electrs_onion_password,
"electrs_onion_command": electrs_onion_command,
"ui_settings": read_ui_settings()
}

View File

@ -58,10 +58,12 @@
<div class="info_tile_header">Electrum Tor Hostname</div>
<div class="info_tile_contents">{{electrs_onion_hostname}}</div>
</div>
<!--
<div class="info_tile">
<div class="info_tile_header">Electrum Tor Password</div>
<div class="info_tile_contents">{{electrs_onion_password}}</div>
</div>
-->
</div>
<div class="app_tile_row">
<div class="info_tile">

View File

@ -34,16 +34,14 @@
<td>Service</td>
<td>Address</td>
<td>Port</td>
<td>Password</td>
<td>Guide</td>
</thead>
<tbody>
{% for service in services %}
<tr>
<td><b>{{ service.service }}</b></td>
<td>{{ mynode_onion_hostname }}</td>
<td>{{ service.url }}</td>
<td>{{ service.port }}</td>
<td>{{ mynode_onion_password }}</td>
<td>
{% if service.guide|length %}
<a href="{{ service.guide }}" target="_blank">Guide</a>

View File

@ -2,7 +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 settings import read_ui_settings
from device_info import is_community_edition, get_bitcoin_rpc_password
from device_info import *
from user_management import check_logged_in
import os
import json
@ -15,46 +15,36 @@ mynode_tor = Blueprint('mynode_tor',__name__)
@mynode_tor.route("/tor")
def page_tor():
check_logged_in()
mynode_onion_hostname = "..."
mynode_onion_password = "..."
# Check if we are premium
if is_community_edition():
return redirect("/")
# Get Onion URLs
try:
if os.path.isfile("/var/lib/tor/mynode/hostname"):
with open("/var/lib/tor/mynode/hostname") as f:
contents = f.read().split()
mynode_onion_hostname = contents[0]
mynode_onion_password = contents[1]
except:
mynode_onion_hostname = "error"
mynode_onion_password = "error"
general_onion_url = get_onion_url_general()
btc_onion_url = get_onion_url_btc()
lnd_onion_url = get_onion_url_lnd()
# Services
services = []
services.append({"service":"myNode Web","port": "80","guide":""})
services.append({"service":"LND Hub","port": "3000","guide":""})
services.append({"service":"BTC RPC Explorer","port": "3002","guide":""})
services.append({"service":"LND Admin","port": "3004","guide":""})
services.append({"service":"Ride the Lightning","port": "3010","guide":""})
services.append({"service":"Bitcoin API (REST)","port": "8332","guide":""})
services.append({"service":"LND API (gRPC)","port": "10009","guide":""})
services.append({"service":"LND API (REST)","port": "10080","guide":""})
services.append({"service":"Electrum Server","port": "50001","guide":"https://mynodebtc.com/guide/electrum_server_tor"})
services.append({"service":"Electrum Server","port": "50002","guide":"https://mynodebtc.com/guide/electrum_server_tor"})
services.append({"service": "myNode Web", "url": general_onion_url, "port": "80","guide":""})
services.append({"service": "LND Hub", "url": general_onion_url,"port": "3000","guide":""})
services.append({"service": "BTC RPC Explorer", "url": general_onion_url,"port": "3002","guide":""})
services.append({"service": "LND Admin", "url": general_onion_url,"port": "3004","guide":""})
services.append({"service": "Ride the Lightning", "url": general_onion_url,"port": "3010","guide":""})
services.append({"service": "Bitcoin API (REST)", "url": btc_onion_url,"port": "8332","guide":""})
services.append({"service": "LND API (gRPC)", "url": lnd_onion_url,"port": "10009","guide":""})
services.append({"service": "LND API (REST)", "url": lnd_onion_url,"port": "10080","guide":""})
services.append({"service": "Electrum Server", "url": general_onion_url,"port": "50001","guide":"https://mynodebtc.com/guide/electrum_server_tor"})
services.append({"service": "Electrum Server", "url": general_onion_url,"port": "50002","guide":"https://mynodebtc.com/guide/electrum_server_tor"})
# App links
rpc_password = get_bitcoin_rpc_password()
fully_noded_link = "btcrpc://mynode:{}@{}:8332?label=myNode%20Tor&v2password={}".format(rpc_password, mynode_onion_hostname, mynode_onion_password)
fully_noded_link = "btcrpc://mynode:{}@{}:8332?label=myNode%20Tor".format(rpc_password, btc_onion_url)
# Load page
templateData = {
"title": "myNode Tor Services",
"mynode_onion_hostname": mynode_onion_hostname,
"mynode_onion_password": mynode_onion_password,
"services": services,
"fully_noded_link": fully_noded_link,
"ui_settings": read_ui_settings()