1
0
Fork 0
mirror of https://github.com/tunix/digitalocean-dyndns synced 2024-12-22 04:49:52 +00:00

Adding check for valid ip address

In some cases the return body from ifconfig.co is an HTML error page.
This change makes sure the response is a valid IP address.
This commit is contained in:
Harald Ringvold 2021-03-20 21:09:58 +01:00
parent 8c940d5bd2
commit 9b59388a58

View file

@ -30,7 +30,8 @@ while ( true ); do
echo "Trying with $service..."
ip="$(curl -s $service)"
test -n "$ip" && break
valid_ip=$(echo $ip | grep '[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}')
test -n "$valid_ip" && break
done
echo "Found IP address $ip"