Add tor reset option

This commit is contained in:
Taylor Helsper 2019-09-02 18:38:51 -05:00
parent 588a8fd6bf
commit 1f8d4de5ca
2 changed files with 85 additions and 1 deletions

View File

@ -81,6 +81,11 @@ def restart_quicksync():
delete_quicksync_data()
reboot_device()
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")
def factory_reset():
# Reset subsystems that have local data
delete_quicksync_data()
@ -88,8 +93,14 @@ def factory_reset():
# Delete LND data
delete_lnd_data()
# Delete Tor data
reset_tor()
# Disable services
os.system("systemctl disable electrs")
os.system("systemctl disable electrs --no-pager")
os.system("systemctl disable lndhub --no-pager")
os.system("systemctl disable btc_rpc_explorer --no-pager")
os.system("systemctl disable vpn --no-pager")
# Trigger drive to be reformatted on reboot
os.system("rm -f /mnt/hdd/.mynode")
@ -284,6 +295,29 @@ def page_lnd_delete_wallet():
flash("Lightning wallet deleted!", category="message")
return redirect(url_for(".page_settings"))
@mynode_settings.route("/settings/reset-tor", methods=['POST'])
def page_reset_tor():
p = pam.pam()
pw = request.form.get('password_reset_tor')
if pw == None or p.authenticate("admin", pw) == False:
flash("Invalid Password", category="error")
return redirect(url_for(".page_settings"))
else:
# Successful Auth
reset_tor()
# Trigger reboot
t = Timer(1.0, reboot_device)
t.start()
# Wait until device is restarted
templateData = {
"title": "myNode Reboot",
"header_text": "Restarting",
"subheader_text": "This will take several minutes..."
}
return render_template('reboot.html', **templateData)
@mynode_settings.route("/settings/mynode_logs.tar.gz")
def download_logs_page():
os.system("rm -rf /tmp/mynode_logs.tar.gz")

View File

@ -53,6 +53,33 @@
});
function resetTor() {
$("#reset_tor_form").submit();
reset_tor_dialog.dialog( "close" );
}
reset_tor_dialog = $( "#reset-tor-dialog" ).dialog({
autoOpen: false,
resizable: false,
height: "auto",
width: 600,
modal: true,
position: { my: "center top", at: "center top", of: window, collision: "none" },
buttons: {
"Reset Tor": resetTor,
Cancel: function() {
reset_tor_dialog.dialog( "close" );
}
},
open: function() {
$("#password_reset_tor").val("")
}
});
$("#reset_tor").on("click", function() {
reset_tor_dialog.dialog( "open" );
});
$("#reset-blockchain").on("click", function() {
// Enable electrs
var okFunction = function() {
@ -296,6 +323,16 @@
</div>
<div class="settings_block">
<div class="settings_block_header">Tor</div>
<div class="settings_block_subheader">Reset Tor</div>
This will reset all of your Tor service settings and re-generate your Onion URLs.
<br/>
<button id="reset_tor" class="ui-button ui-widget ui-corner-all settings_button">Reset Tor</button>
</div>
<div class="settings_block">
<div class="settings_block_header">Advanced</div>
@ -376,6 +413,19 @@
</form>
</div>
<div id="reset-tor-dialog" title="Reset Tor" style="display:none;">
<form id="reset_tor_form" name="reset_tor_form" action="/settings/reset-tor" method="POST">
<p>This will reset all your Tor services. After rebooting, they will get new IDs and certificates.</p>
<p>This will reboot your device.</p>
<b>Password:</b>
<br/>
<input type="password" name="password_reset_tor" id="password_reset_tor" value="" class="text ui-widget-content ui-corner-all">
<!-- Allow form submission with keyboard without duplicating the dialog button -->
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
</form>
</div>
<div id="factory-reset-dialog" title="Factory Reset" style="display:none;">
<form id="factory_reset_form" name="factory_reset_form" action="/settings/factory-reset" method="POST">
<p>Factory reset will revert your device and all storage to the initial state.</p>