mirror of
https://github.com/YunoHost-Apps/adguardhome_ynh.git
synced 2024-09-03 18:06:23 +02:00
if the IP is public and the user doesn't want to expose port 53, skip it
This commit is contained in:
parent
77c7cedc79
commit
2c8322ce7c
3 changed files with 39 additions and 4 deletions
|
@ -8,6 +8,21 @@
|
|||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
is_public_ip(){
|
||||
local IP
|
||||
IP="$1"
|
||||
if [[ "$IP" =~ ^10.*|^169.*|^172.*|^192.168.* ]] ; then
|
||||
# private ipv4
|
||||
returns false
|
||||
elif [[ "$IP" =~ ^fd*|^fe80:* ]] ; then
|
||||
# private ipv6
|
||||
returns false
|
||||
else
|
||||
# public ip
|
||||
returns true
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -103,8 +103,13 @@ ipv4_addr=""
|
|||
for i in $(seq "$(echo "$ipv4_route_output" | wc -w)" -1 1); do
|
||||
ip=$(echo "$ipv4_route_output" | awk "{print \$$i}")
|
||||
if ynh_validate_ip4 --ip_address="$ip"; then
|
||||
ipv4_addr="- $ip"
|
||||
break
|
||||
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
|
||||
ipv4_addr="- $ip"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -112,8 +117,13 @@ ipv6_addr=""
|
|||
for i in $(seq "$(echo "$ipv6_route_output" | wc -w)" -1 1); do
|
||||
ip=$(echo "$ipv6_route_output" | awk "{print \$$i}")
|
||||
if ynh_validate_ip6 --ip_address="$ip"; then
|
||||
ipv6_addr="- $ip"
|
||||
break
|
||||
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
|
||||
ipv6_addr="- $ip"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -154,8 +154,13 @@ ipv4_addr=""
|
|||
for i in $(seq "$(echo "$ipv4_route_output" | wc -w)" -1 1); do
|
||||
ip=$(echo "$ipv4_route_output" | awk "{print \$$i}")
|
||||
if ynh_validate_ip4 --ip_address="$ip"; then
|
||||
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
|
||||
ipv4_addr="$ip"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -163,8 +168,13 @@ ipv6_addr=""
|
|||
for i in $(seq "$(echo "$ipv6_route_output" | wc -w)" -1 1); do
|
||||
ip=$(echo "$ipv6_route_output" | awk "{print \$$i}")
|
||||
if ynh_validate_ip6 --ip_address="$ip"; then
|
||||
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
|
||||
ipv6_addr="$ip"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue