Skip to content

Commit

Permalink
Add SSH to Tor; Seperate Electrs URL
Browse files Browse the repository at this point in the history
  • Loading branch information
tehelsper committed Mar 10, 2020
1 parent fb9bd5a commit 8172d79
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
15 changes: 12 additions & 3 deletions rootfs/standard/etc/tor/torrc
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ HiddenServicePort 4080 127.0.0.1:4080
HiddenServicePort 8899 127.0.0.1:8899
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)
Expand All @@ -238,4 +236,15 @@ HiddenServicePort 8332 127.0.0.1:8332
HiddenServiceDir /var/lib/tor/mynode_lnd/
HiddenServiceVersion 3
HiddenServicePort 10009 127.0.0.1:10009
HiddenServicePort 10080 127.0.0.1:10080
HiddenServicePort 10080 127.0.0.1:10080

# Hidden Service for myNode (Electrum Server)
HiddenServiceDir /var/lib/tor/mynode_electrs/
HiddenServiceVersion 3
HiddenServicePort 50001 127.0.0.1:50001
HiddenServicePort 50002 127.0.0.1:50002

# Hidden Service for myNode (SSH)
HiddenServiceDir /var/lib/tor/mynode_ssh/
HiddenServiceVersion 3
HiddenServicePort 22022 127.0.0.1:22
19 changes: 19 additions & 0 deletions rootfs/standard/var/www/mynode/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ def reset_tor():
os.system("rm -rf /var/lib/tor/*")
os.system("rm -rf /mnt/hdd/mynode/bitcoin/onion_private_key")
os.system("rm -rf /mnt/hdd/mynode/lnd/v2_onion_private_key")
os.system("rm -rf /mnt/hdd/mynode/lnd/v3_onion_private_key")

def is_btc_lnd_tor_enabled():
return os.path.isfile("/mnt/hdd/mynode/settings/.btc_lnd_tor_enabled")
Expand All @@ -463,6 +464,15 @@ def disable_btc_lnd_tor():
os.system("rm -f mnt/hdd/mynode/settings/.btc_lnd_tor_enabled")
os.system("sync")

def get_onion_url_ssh():
try:
if os.path.isfile("/var/lib/tor/mynode_ssh/hostname"):
with open("/var/lib/tor/mynode_ssh/hostname") as f:
return f.read()
except:
pass
return "error"

def get_onion_url_general():
try:
if os.path.isfile("/var/lib/tor/mynode/hostname"):
Expand Down Expand Up @@ -490,6 +500,15 @@ def get_onion_url_lnd():
pass
return "error"

def get_onion_url_electrs():
try:
if os.path.isfile("/var/lib/tor/mynode_electrs/hostname"):
with open("/var/lib/tor/mynode_electrs/hostname") as f:
return f.read()
except:
pass
return "error"


#==================================
# Firewall Functions
Expand Down
4 changes: 2 additions & 2 deletions rootfs/standard/var/www/mynode/electrum_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from pprint import pprint, pformat
from bitcoin_info import *
from device_info import get_local_ip, skipped_product_key, get_onion_url_general
from device_info import get_local_ip, skipped_product_key, get_onion_url_electrs
from user_management import check_logged_in
from settings import read_ui_settings
from electrum_info import *
Expand Down Expand Up @@ -35,7 +35,7 @@ def electrum_server_page():
electrs_command = "./electrum -1 -s {}:50002:s".format(server_ip)

# Get Onion URLs
electrs_onion_hostname = get_onion_url_general()
electrs_onion_hostname = get_onion_url_electrs()
electrs_onion_command = "./electrum -1 -s {}:50002:s -p socks5:localhost:9050".format(electrs_onion_hostname)


Expand Down
17 changes: 13 additions & 4 deletions rootfs/standard/var/www/mynode/templates/tor.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@

<script>
$(document).ready(function() {
hidden=1
$("#show_onion_urls").on("click", function() {
//$("#show_onion_urls").hide(0);
$(".onion_url_placeholder").hide(0)
$(".onion_url").show();
if (hidden == 1) {
$("#show_onion_urls").html('Hide Onion URLs');
$(".onion_url_placeholder").hide(0)
$(".onion_url").show();
hidden=0;
} else {
$("#show_onion_urls").html('Show Onion URLs');
$(".onion_url_placeholder").show()
$(".onion_url").hide(0);
hidden=1;
}
});
});
</script>
Expand Down Expand Up @@ -61,7 +70,7 @@
<td><b>{{ service.service }}</b></td>
<td>
<span class="onion_url">{{ service.url }}</span>
<span class="onion_url_placeholder">.....................................</span>
<span class="onion_url_placeholder">..................................................</span>
</td>
<td>{{ service.port }}</td>
<td>
Expand Down
7 changes: 5 additions & 2 deletions rootfs/standard/var/www/mynode/tor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ def page_tor():
return redirect("/")

# Get Onion URLs
ssh_onion_url = get_onion_url_ssh()
general_onion_url = get_onion_url_general()
btc_onion_url = get_onion_url_btc()
lnd_onion_url = get_onion_url_lnd()
electrs_onion_url = get_onion_url_electrs()

# Services
services = []
Expand All @@ -34,8 +36,9 @@ def page_tor():
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"})
services.append({"service": "SSH", "url": ssh_onion_url, "port": "22022","guide":""})
services.append({"service": "Electrum Server", "url": electrs_onion_url,"port": "50001","guide":"https://mynodebtc.com/guide/electrum_server_tor"})
services.append({"service": "Electrum Server", "url": electrs_onion_url,"port": "50002","guide":"https://mynodebtc.com/guide/electrum_server_tor"})

# App links
rpc_password = get_bitcoin_rpc_password()
Expand Down

2 comments on commit 8172d79

@Amiga500
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice for the "hide" button!

@Amiga500
Copy link
Contributor

@Amiga500 Amiga500 commented on 8172d79 Mar 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using more dots to "cover" the address let the distance about the same as when the address is showed. I don't try it.. but it seems similar to one correct

................................................................................................................................................

Please sign in to comment.