From 98080c7d07cbc1110f1495fee0613f3815a92218 Mon Sep 17 00:00:00 2001 From: Aaron Riedel Date: Wed, 24 Jul 2024 14:06:03 +0200 Subject: [PATCH] add validity check for ipv4 addresses --- ddns4.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddns4.sh b/ddns4.sh index ab2e6fb..7388416 100755 --- a/ddns4.sh +++ b/ddns4.sh @@ -44,10 +44,10 @@ echo -e "${INFO} started $(date)" echo -e "${INFO} DNS Record will be $SUBDOMAIN_IPV4.$DNSZONE_IPV4" echo -e "${PENDING} get IP address" IPv4="$(curl -s4 https://ip.hetzner.com)" -if [[ -z $IPv4 ]]; then +if [[ -z $IPv4 || ! $IPv4 =~ ^[0-9]{1,3}("."[0-9]{1,3}){3}$ ]]; then IPv4="$(curl -s4 https://icanhazip.com)" -fi -if [[ -z $IPv4 ]]; then +fi +if [[ -z $IPv4 || ! $IPv4 =~ ^[0-9]{1,3}("."[0-9]{1,3}){3}$ ]]; then echo -e "${REPLACE}${FAIL} IPv4 not found" exit 1 else