From 5d35c035597fe746110e16f2774c78d7e9b4118a Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Wed, 27 Dec 2023 19:23:21 +0100 Subject: [PATCH] better comments --- scripts/_common.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d63b5a3..901985c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,17 +10,19 @@ is_public_ip(){ # used to discriminate publics IPs over privates IPs +# private IPv4 start with: 10.; 169.; 172. or 192.168. +# private IPv6 start with: fc; fd or fe80: local IP="$1" if [[ "$IP" =~ ^10.*|^169.*|^172.*|^192.168.* ]] ; then - # private ipv4, so false + # private IPv4, so false return 1 elif [[ "$IP" =~ ^fc*|^fd*|^fe80:* ]] ; then - # private ipv6, so false + # private IPv6, so false return 1 else - # public ip, so true + # public IP, so true return 0 fi } @@ -32,9 +34,10 @@ process_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"; then + # if the IP is public and the user doesn't want to expose port 53, skip it if is_public_ip "$ip" && [ "$open_port_53" == "false" ] ; then - # if the IP is public and the user doesn't want to expose port 53, skip it break else ips="$ip"