fix: remove cloudflare service and improve ipv4/ipv6 handling
All checks were successful
ci / docker (push) Successful in 25s
All checks were successful
ci / docker (push) Successful in 25s
This commit is contained in:
parent
b8d31865d1
commit
03fe312c02
1 changed files with 12 additions and 7 deletions
19
dyndns.sh
19
dyndns.sh
|
@ -6,8 +6,9 @@ sleep_interval=${SLEEP_INTERVAL:-300}
|
||||||
remove_duplicates=${REMOVE_DUPLICATES:-"false"}
|
remove_duplicates=${REMOVE_DUPLICATES:-"false"}
|
||||||
|
|
||||||
# Only services with ipv6 supported are listed here.
|
# Only services with ipv6 supported are listed here.
|
||||||
|
# And are not using cloudflare or similar services
|
||||||
|
# that may block requests from this script.
|
||||||
services=(
|
services=(
|
||||||
"ifconfig.co"
|
|
||||||
"ifconfig.io"
|
"ifconfig.io"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -96,19 +97,22 @@ do
|
||||||
do
|
do
|
||||||
echo "Trying with $service..."
|
echo "Trying with $service..."
|
||||||
|
|
||||||
ipv4="$(curl -4 -s -f $service || echo "")"
|
ipv4="$(curl -4 -s -f --connect-timeout=2 $service || echo "")"
|
||||||
ipv6="$(curl -6 -s -f $service || echo "")"
|
ipv6="$(curl -6 -s -f --connect-timeout=2 $service || echo "")"
|
||||||
|
|
||||||
test -n "$ipv4$ipv6" && break
|
if [[ -n "$ipv4$ipv6" ]]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "Failed to retrieve IP from $service"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Found IPv4 address $ipv4"
|
|
||||||
echo "Found IPv6 address $ipv6"
|
|
||||||
|
|
||||||
if [[ -z $ipv4 ]]
|
if [[ -z $ipv4 ]]
|
||||||
then
|
then
|
||||||
echo "IPv4 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
|
echo "IPv4 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
|
||||||
else
|
else
|
||||||
|
echo "Found IPv4 address $ipv4"
|
||||||
configure_record $ipv4 "A"
|
configure_record $ipv4 "A"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -116,6 +120,7 @@ do
|
||||||
then
|
then
|
||||||
echo "IPv6 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
|
echo "IPv6 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
|
||||||
else
|
else
|
||||||
|
echo "Found IPv6 address $ipv6"
|
||||||
configure_record $ipv6 "AAAA"
|
configure_record $ipv6 "AAAA"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue