Refactor advanced_settings and add whitelist check
Moved and redefined _is_whitelisted_key as a global function for use in multiple locations. Improved formatting and readability in the advanced_settings wizard, including better handling of container type selection and IPv6 configuration steps.
This commit is contained in:
parent
54faeadf07
commit
76e933b3a4
@ -780,7 +780,13 @@ if ! declare -p VAR_WHITELIST >/dev/null 2>&1; then
|
|||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Note: _is_whitelisted_key() is defined above in default_var_settings section
|
# Global whitelist check function (used by _load_vars_file_to_map and others)
|
||||||
|
_is_whitelisted_key() {
|
||||||
|
local k="$1"
|
||||||
|
local w
|
||||||
|
for w in "${VAR_WHITELIST[@]}"; do [ "$k" = "$w" ] && return 0; done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
_sanitize_value() {
|
_sanitize_value() {
|
||||||
# Disallow Command-Substitution / Shell-Meta
|
# Disallow Command-Substitution / Shell-Meta
|
||||||
@ -1199,7 +1205,10 @@ advanced_settings() {
|
|||||||
1)
|
1)
|
||||||
local default_on="ON"
|
local default_on="ON"
|
||||||
local default_off="OFF"
|
local default_off="OFF"
|
||||||
[[ "$_ct_type" == "0" ]] && { default_on="OFF"; default_off="ON"; }
|
[[ "$_ct_type" == "0" ]] && {
|
||||||
|
default_on="OFF"
|
||||||
|
default_off="ON"
|
||||||
|
}
|
||||||
|
|
||||||
if result=$(whiptail --backtitle "Proxmox VE Helper Scripts [Step $STEP/$MAX_STEP]" \
|
if result=$(whiptail --backtitle "Proxmox VE Helper Scripts [Step $STEP/$MAX_STEP]" \
|
||||||
--title "CONTAINER TYPE" \
|
--title "CONTAINER TYPE" \
|
||||||
@ -1445,40 +1454,40 @@ advanced_settings() {
|
|||||||
|
|
||||||
_ipv6_method="$result"
|
_ipv6_method="$result"
|
||||||
case "$result" in
|
case "$result" in
|
||||||
static)
|
static)
|
||||||
local ipv6_addr
|
local ipv6_addr
|
||||||
if ipv6_addr=$(whiptail --backtitle "Proxmox VE Helper Scripts" \
|
if ipv6_addr=$(whiptail --backtitle "Proxmox VE Helper Scripts" \
|
||||||
--title "STATIC IPv6 ADDRESS" \
|
--title "STATIC IPv6 ADDRESS" \
|
||||||
--inputbox "\nEnter IPv6 CIDR address\n(e.g. 2001:db8::1/64)" 12 58 "" \
|
--inputbox "\nEnter IPv6 CIDR address\n(e.g. 2001:db8::1/64)" 12 58 "" \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [[ "$ipv6_addr" =~ ^([0-9a-fA-F:]+:+)+[0-9a-fA-F]+(/[0-9]{1,3})$ ]]; then
|
if [[ "$ipv6_addr" =~ ^([0-9a-fA-F:]+:+)+[0-9a-fA-F]+(/[0-9]{1,3})$ ]]; then
|
||||||
_ipv6_addr="$ipv6_addr"
|
_ipv6_addr="$ipv6_addr"
|
||||||
# Optional gateway
|
# Optional gateway
|
||||||
_ipv6_gate=$(whiptail --backtitle "Proxmox VE Helper Scripts" \
|
_ipv6_gate=$(whiptail --backtitle "Proxmox VE Helper Scripts" \
|
||||||
--title "IPv6 GATEWAY" \
|
--title "IPv6 GATEWAY" \
|
||||||
--inputbox "\nEnter IPv6 gateway (optional, leave blank for none)" 10 58 "" \
|
--inputbox "\nEnter IPv6 gateway (optional, leave blank for none)" 10 58 "" \
|
||||||
3>&1 1>&2 2>&3) || true
|
3>&1 1>&2 2>&3) || true
|
||||||
((STEP++))
|
((STEP++))
|
||||||
else
|
else
|
||||||
whiptail --msgbox "Invalid IPv6 CIDR format." 8 58
|
whiptail --msgbox "Invalid IPv6 CIDR format." 8 58
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
;;
|
fi
|
||||||
dhcp)
|
;;
|
||||||
_ipv6_addr="dhcp"
|
dhcp)
|
||||||
_ipv6_gate=""
|
_ipv6_addr="dhcp"
|
||||||
((STEP++))
|
_ipv6_gate=""
|
||||||
;;
|
((STEP++))
|
||||||
none)
|
;;
|
||||||
_ipv6_addr="none"
|
none)
|
||||||
_ipv6_gate=""
|
_ipv6_addr="none"
|
||||||
((STEP++))
|
_ipv6_gate=""
|
||||||
;;
|
((STEP++))
|
||||||
*)
|
;;
|
||||||
_ipv6_addr=""
|
*)
|
||||||
_ipv6_gate=""
|
_ipv6_addr=""
|
||||||
((STEP++))
|
_ipv6_gate=""
|
||||||
;;
|
((STEP++))
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
((STEP--))
|
((STEP--))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user