Add option to enable/disable IPv6

This commit is contained in:
Taylor Helsper 2024-06-24 00:15:11 -05:00
parent be0702c852
commit e6f7b9c950
4 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,5 @@
# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

View File

@ -1459,3 +1459,17 @@ def generate_qr_code(url):
except Exception as e:
log_message("generate_qr_code exception: {}".format(str(e)))
return None
#==================================
# General Settings Functions
#==================================
def custom_settings_file_handler(name, enabled):
if name == "ipv6_disabled":
if enabled:
os.system("cp -f /usr/share/mynode/sysctl_noipv6.conf /etc/sysctl.d/10-disableipv6.conf")
os.system("sync")
else:
os.system("rm -f /etc/sysctl.d/10-disableipv6.conf")
os.system("sync")
else:
log_message("No custom setting handler for: "+name)

View File

@ -98,6 +98,7 @@ def page_settings():
"electrs_tx_lookup_limit": get_electrs_index_lookup_limit(),
"btcrpcexplorer_token_enabled": is_btcrpcexplorer_token_enabled(),
"is_i2p_enabled": is_service_enabled("i2pd"),
"is_ipv6_enabled": not settings_file_exists("ipv6_disabled"),
"is_btc_ipv4_enabled": settings_file_exists("btc_ipv4_enabled"),
"is_btc_tor_enabled": settings_file_exists("btc_tor_enabled"),
"is_btc_i2p_enabled": settings_file_exists("btc_i2p_enabled"),
@ -1203,6 +1204,8 @@ def page_toggle_setting():
else:
flash("Error Updating Setting", category="error")
return redirect("/settings")
custom_settings_file_handler(name, (enable == "1"))
# Restart service if necessary
service_to_restart = request.args.get('restart_service')

View File

@ -682,6 +682,21 @@
}
});
$('#ipv6_checkbox').change(function () {
$("#ipv6").show();
});
$("#ipv6").on("click", function() {
checked=$('#ipv6_checkbox').is(":checked")
// Inverted setting (uses disable flag)
val = "1"
if (checked)
{
val = "0"
}
$('#loading_spinner_overlay').fadeIn();
window.location.href='/settings/toggle_setting?name=ipv6_disabled&enable='+val+'&reboot=1'
});
$('#tor_repo_checkbox').change(function () {
$("#tor_repo").show();
});
@ -1035,6 +1050,18 @@
<br/><br/>
<button id="i2p" style="display: none;" class="ui-button ui-widget ui-corner-all settings_button_small">Save</button>
<div class="divider"></div>
<div class="settings_block_subheader">IPv6</div>
IPv6 can be enabled or disabled. It is enabled by default, but some older nodes may have issues with some apps or connections while enabled, so it can be disabled here.
<br/><br/>
<label class="switch">
<input type="checkbox" id="ipv6_checkbox" {% if is_ipv6_enabled %}checked{% endif %}>
<span class="slider round"></span>
</label>
<br/><br/>
<button id="ipv6" style="display: none;" class="ui-button ui-widget ui-corner-all settings_button_small">Save</button>
</div>