Validate list of ntp servers (ip4, hostname, or fqdn)

This commit is contained in:
William Wernert
2021-03-25 14:45:33 -04:00
parent 150e724a4a
commit eb674b3b93
5 changed files with 27 additions and 8 deletions

View File

@@ -419,6 +419,20 @@ valid_proxy() {
[[ $has_prefix == true ]] && [[ $valid_url == true ]] && return 0 || return 1
}
valid_ntp_list() {
local string=$1
local ntp_arr
IFS="," read -r -a ntp_arr <<< "$string"
for ntp in "${ntp_arr[@]}"; do
if ! valid_ip4 "$ntp" && ! valid_hostname "$ntp" && ! valid_fqdn "$ntp"; then
return 1
fi
done
return 0
}
valid_string() {
local str=$1
local min_length=${2:-1}