Add toggle for LND Tor stream isolation

This commit is contained in:
Taylor Helsper 2022-05-04 23:57:17 -05:00
parent 2c1fe6cc42
commit f2c0522320
5 changed files with 62 additions and 6 deletions

View File

@ -26,6 +26,11 @@ else
# Append Tor/IP section (check new file or old file, should be migrated to new)
if [ -f /mnt/hdd/mynode/settings/btc_lnd_tor_enabled ] || [ -f /mnt/hdd/mynode/settings/.btc_lnd_tor_enabled ]; then
cat /usr/share/mynode/lnd_tor.conf >> /mnt/hdd/mynode/lnd/lnd.conf
# Upadte LND Tor stream isolation (true is default)
if [ -f /mnt/hdd/mynode/settings/streamisolation_tor_disabled ]; then
sed -i "s/tor.streamisolation=.*/tor.streamisolation=false/g" /mnt/hdd/mynode/lnd/lnd.conf
fi
else
cat /usr/share/mynode/lnd_ipv4.conf >> /mnt/hdd/mynode/lnd/lnd.conf
fi

View File

@ -5,5 +5,5 @@ nat=false
[Tor]
tor.active=true
tor.v3=true
tor.streamisolation=true
tor.streamisolation=true # Causes poor performance as channel count increases

View File

@ -1132,19 +1132,22 @@ def reset_tor():
def is_btc_lnd_tor_enabled():
return settings_file_exists("btc_lnd_tor_enabled")
def enable_btc_lnd_tor():
create_settings_file("btc_lnd_tor_enabled")
def disable_btc_lnd_tor():
delete_settings_file("btc_lnd_tor_enabled")
def is_streamisolation_tor_enabled():
return not settings_file_exists("streamisolation_tor_disabled")
def enable_streamisolation_tor():
delete_settings_file("streamisolation_tor_disabled")
def disable_streamisolation_tor():
create_settings_file("streamisolation_tor_disabled")
def is_aptget_tor_enabled():
return os.path.isfile("/mnt/hdd/mynode/settings/torify_apt_get")
def enable_aptget_tor():
touch("/mnt/hdd/mynode/settings/torify_apt_get")
def disable_aptget_tor():
delete_file("/mnt/hdd/mynode/settings/torify_apt_get")

View File

@ -3,7 +3,7 @@ from flask import Blueprint, render_template, session, abort, Markup, request, r
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from bitcoin import is_bitcoin_synced
from bitcoin_info import using_bitcoin_custom_config
from lightning_info import using_lnd_custom_config
from lightning_info import using_lnd_custom_config, restart_lnd
from pprint import pprint, pformat
from threading import Timer
from thread_functions import *
@ -95,6 +95,7 @@ def page_settings():
"btcrpcexplorer_token_enabled": is_btcrpcexplorer_token_enabled(),
"is_btc_lnd_tor_enabled": is_btc_lnd_tor_enabled(),
"is_aptget_tor_enabled": is_aptget_tor_enabled(),
"is_streamisolation_tor_enabled": is_streamisolation_tor_enabled(),
"skip_fsck": skip_fsck(),
"uptime": uptime,
"date": date,
@ -786,6 +787,22 @@ def page_enable_btc_lnd_tor():
}
return render_template('reboot.html', **templateData)
@mynode_settings.route("/settings/enable_streamisolation_tor")
def page_enable_streamisolation_tor():
check_logged_in()
enable = request.args.get('enable')
if enable == "1":
enable_streamisolation_tor()
else:
disable_streamisolation_tor()
# Restart LND
restart_lnd()
flash("Restarting lnd...", category="message")
return redirect("/settings")
@mynode_settings.route("/settings/set_https_forced")
def page_set_https_forced_page():
check_logged_in()

View File

@ -434,6 +434,21 @@
}
});
$('#streamisolation_tor_checkbox').change(function () {
$("#streamisolation_tor").show();
});
$("#streamisolation_tor").on("click", function() {
enabled=$('#streamisolation_tor_checkbox').is(":checked")
if (enabled)
{
window.location.href='/settings/enable_streamisolation_tor?enable=1'
}
else
{
window.location.href='/settings/enable_streamisolation_tor?enable=0'
}
});
$('#www_python3_checkbox').change(function () {
$("#www_python3_button").show();
});
@ -950,6 +965,22 @@
<button id="aptget_tor" style="display: none;" class="ui-button ui-widget ui-corner-all settings_button_small">Save</button>
<div class="divider"></div>
{% if is_btc_lnd_tor_enabled %}
<div class="settings_block_subheader">Use Tor Stream Isolation for LND</div>
When using tor, enable stream isolation for LND. This increases privacy, but it can take significant resources with large numnbers of lightning channels.
<br/><br/>
This is not recommended to disable unless you are having lnd issues with many channels.
<br/><br/>
<label class="switch">
<input type="checkbox" id="streamisolation_tor_checkbox" {% if is_streamisolation_tor_enabled %}checked{% endif %}>
<span class="slider round"></span>
</label>
<br/><br/>
<button id="streamisolation_tor" style="display: none;" class="ui-button ui-widget ui-corner-all settings_button_small">Save</button>
<div class="divider"></div>
{% endif %}
<div class="settings_block_subheader">Reset Tor</div>
This will reset all of your Tor service settings and regenerate your Onion URLs.