V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m24s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m24s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -47,7 +47,7 @@ validation_ipv6() {
|
||||
declare var_addr="${var_ip%%\%*}"
|
||||
declare var_has_double_colon=0
|
||||
|
||||
### Step 1 – IPv4-mapped / -embedded addresses (::ffff:192.0.2.1)
|
||||
### Step 1 - IPv4-mapped / -embedded addresses (::ffff:192.0.2.1)
|
||||
if [[ "${var_addr}" == *.* ]]; then
|
||||
declare var_ipv4_part="${var_addr##*:}"
|
||||
validation_ipv4 "${var_ipv4_part}" || exit "${ERR_INVALID_IPV6}"
|
||||
@@ -55,26 +55,26 @@ validation_ipv6() {
|
||||
var_addr="${var_addr%:*}:0:0"
|
||||
fi
|
||||
|
||||
### Step 2 – Detect forbidden multiple '::'
|
||||
### Step 2 - Detect forbidden multiple '::'
|
||||
if [[ "${var_addr}" == *::* ]]; then
|
||||
var_has_double_colon=1
|
||||
### Remove first '::' and check there is no second one.
|
||||
[[ ${var_addr#*::*} == *::* ]] && exit "${ERR_INVALID_IPV6}"
|
||||
fi
|
||||
|
||||
### Step 3 – Split into hextets and validate format.
|
||||
### Step 3 - Split into hextets and validate format.
|
||||
declare var_hextet
|
||||
declare -a var_segments
|
||||
IFS=':' read -ra var_segments <<< "${var_addr}"
|
||||
declare seg_count=${#var_segments[@]}
|
||||
|
||||
for var_hextet in "${var_segments[@]}"; do
|
||||
### Empty ⇔ part of '::' compression
|
||||
### Empty part of '::' compression
|
||||
[[ -z "${var_hextet}" ]] && continue
|
||||
[[ "${var_hextet}" =~ ^[0-9a-fA-F]{1,4}$ ]] || exit "${ERR_INVALID_IPV6}"
|
||||
done
|
||||
|
||||
### Step 4 – Check total hextet count.
|
||||
### Step 4 - Check total hextet count.
|
||||
if (( var_has_double_colon )); then
|
||||
(( seg_count <= 8 )) || exit "${ERR_INVALID_IPV6}"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user