From 515b371a7dbdbb0709c17267f53ea96e2bc162fe Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 31 Dec 2023 02:04:04 +0100 Subject: [PATCH] fix process_ips() --- scripts/_common.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6540310..05a1477 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -73,19 +73,22 @@ process_ips(){ local ips="$1" local processed_ips="" - for i in $(seq "$(echo "$ips" | wc -w)" -1 1); do - ip=$(echo "$ips" | awk "{print \$$i}") - # check if the so-called IP really is one - if [ "$(ynh_validate_ip4 --ip_address="$ip")" ] || [ "$(ynh_validate_ip6 --ip_address="$ip")" ] ; then - # don't process if the IP is public and the port 53 closed - if [ "$(is_public_ip "$ip")" == 0 ] && [ "$open_port_53" == "false" ] ; then - # don't add this IP (do nothing) - : - else - # add this IP and a space as IP delimiter - processed_ips+="$ip " - fi + # remove the 'inet6' and 'inet' from the IP + ips="$(echo "$ips" | sed "s/inet6//g ; s/inet//g")" + + # for each IP + for ip in $ips; do + # check if the so-called IP really is one + if [ "$(ynh_validate_ip4 --ip_address="$ip")" ] || [ "$(ynh_validate_ip6 --ip_address="$ip")" ] ; then + # don't process if the IP is public and the port 53 closed + if [ "$(is_public_ip "$ip")" == 0 ] && [ "$open_port_53" == "false" ] ; then + # don't add this IP (do nothing) + : + else + # add this IP and a space as IP delimiter + processed_ips+="$ip " fi + fi done echo "${processed_ips:-}"