mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-04-29 17:42:44 +00:00
Merge 3455fc2c2fdd9dc5aee941c9126c5769f46b8789 into 9b267bb5725eca0b2b8f34682aca89f5d3fbcb5e
This commit is contained in:
commit
3dcf21ebcd
54
acme.sh
54
acme.sh
@ -4308,18 +4308,50 @@ _match_issuer() {
|
|||||||
|
|
||||||
#ip
|
#ip
|
||||||
_isIPv4() {
|
_isIPv4() {
|
||||||
for seg in $(echo "$1" | tr '.' ' '); do
|
# Disable pathname expansion
|
||||||
_debug2 seg "$seg"
|
set -f
|
||||||
if [ "$(echo "$seg" | tr -d '[0-9]')" ]; then
|
|
||||||
#not all number
|
# Save the current value of IFS
|
||||||
return 1
|
_isIPv4_saveIFS="$IFS"
|
||||||
|
IFS='.'
|
||||||
|
|
||||||
|
# Split the IP into octets
|
||||||
|
_chk_ipv4="$1"
|
||||||
|
# We specifically want word splitting here. We have disabled pathname expansion (globbing) with set -f.
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
set -- $_chk_ipv4
|
||||||
|
|
||||||
|
# Restore the original value of IFS
|
||||||
|
IFS="$_isIPv4_saveIFS"
|
||||||
|
|
||||||
|
# Re-enable pathname expansion
|
||||||
|
set +f
|
||||||
|
|
||||||
|
# Check if the IP has exactly 4 octets
|
||||||
|
if [ $# -ne 4 ]; then
|
||||||
|
# Invalid IPv4 address
|
||||||
|
_debug2 "$_chk_ipv4 does not have 4 octets"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ $seg -ge 0 ] && [ $seg -lt 256 ]; then
|
|
||||||
continue
|
# Validate each octet
|
||||||
fi
|
for octet in "$@"; do
|
||||||
return 1
|
_debug2 octet "$octet"
|
||||||
done
|
# Check if octet is numeric
|
||||||
return 0
|
if ! [ "$octet" -eq "$octet" ] 2>/dev/null; then
|
||||||
|
# octet is not numeric
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if octet is in range 0-255
|
||||||
|
if [ "$octet" -lt 0 ] || [ "$octet" -gt 255 ]; then
|
||||||
|
# octet is out of range
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# If all checks pass, IP is valid
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#ip6
|
#ip6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user