mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-19 21:04:06 -07:00
cidr ip format validator
This commit is contained in:
parent
cc4e053148
commit
82c1c09f6d
1 changed files with 10 additions and 1 deletions
11
func/main.sh
11
func/main.sh
|
@ -502,9 +502,18 @@ is_alias_format_valid() {
|
||||||
is_ip_format_valid() {
|
is_ip_format_valid() {
|
||||||
object_name=${2-ip}
|
object_name=${2-ip}
|
||||||
ip_regex='([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'
|
ip_regex='([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'
|
||||||
if ! [[ $1 =~ ^$ip_regex\.$ip_regex\.$ip_regex\.$ip_regex$ ]]; then
|
ip_clean=$(echo "${1%/[0-9][0-9]}")
|
||||||
|
ip_clean=$(echo "${1%/[0-9]}")
|
||||||
|
if ! [[ $ip_clean =~ ^$ip_regex\.$ip_regex\.$ip_regex\.$ip_regex$ ]]; then
|
||||||
check_result $E_INVALID "invalid $object_name format :: $1"
|
check_result $E_INVALID "invalid $object_name format :: $1"
|
||||||
fi
|
fi
|
||||||
|
if [ $1 != "$ip_clean" ]; then
|
||||||
|
ip_cidr="$ip_clean/"
|
||||||
|
ip_cidr=$(echo "${1#$ip_cidr}")
|
||||||
|
if [[ "$ip_cidr" -gt 32 ]]; then
|
||||||
|
check_result $E_INVALID "invalid $object_name format :: $1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Proxy extention format validator
|
# Proxy extention format validator
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue