Updated IPV4 regex.

This commit is contained in:
Raphaël Numbus
2026-05-29 21:59:45 +02:00
parent fc92aee0fe
commit 5ad0584e9e
+4 -3
View File
@@ -47,7 +47,7 @@ get_valid_input() {
# Handle Regex Validation # Handle Regex Validation
if [[ -n "${REGEX}" ]]; then if [[ -n "${REGEX}" ]]; then
if [[ "${INPUT}" =~ ${REGEX} ]]; then if [[ ${INPUT} =~ ${REGEX} ]]; then
export "${VAR_NAME}"="${INPUT}" export "${VAR_NAME}"="${INPUT}"
break break
else else
@@ -118,7 +118,7 @@ setup_ssh() {
Target password : $(gum style --italic "\"${LIVE_TARGET_PASSWORD}\"")" Target password : $(gum style --italic "\"${LIVE_TARGET_PASSWORD}\"")"
gum confirm "Are these correct ?" || { gum confirm "Are these correct ?" || {
get_valid_input "LIVE_TARGET_IP" "➡️ Provide the IP address of your machine in a NixOS live environment :" "192.168.1.100" "IP_REGEX"; get_valid_input "LIVE_TARGET_IP" "➡️ Provide the IP address of your machine in a NixOS live environment :" "192.168.1.100" "IP_REGEX";
get_valid_input "LIVE_TARGET_IP" "➡️ Provide the password of your machine in a NixOS live environment :" "password" "" "true" "true"; get_valid_input "LIVE_TARGET_PASSWORD " "➡️ Provide the password of your machine in a NixOS live environment :" "password" "" "true" "true";
continue; continue;
} }
gum confirm "Retry connection ?" || { gum confirm "Retry connection ?" || {
@@ -802,7 +802,8 @@ else
STDERR="/dev/null" STDERR="/dev/null"
fi fi
IP_REGEX='^(((?!25?[6-9])[12]\d|[1-9])?\d\.?\b){4}$' IP_OCTET='(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'
IP_REGEX="^${IP_OCTET}\\.${IP_OCTET}\\.${IP_OCTET}\\.${IP_OCTET}$"
SUBNET_REGEX='^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$' SUBNET_REGEX='^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$'
DOMAIN_REGEX='^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$' DOMAIN_REGEX='^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$'
EMAIL_REGEX='^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$' EMAIL_REGEX='^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'