dig names the resolver it could not reach in its error text, so a DNS timeout was scraped as the answer and restarted DDNS over nothing
This commit is contained in:
@@ -270,7 +270,17 @@ log "$ICON_SUCCESS Internet reachable"
|
|||||||
# ==============================================================================================
|
# ==============================================================================================
|
||||||
if [[ -n "$DDNS_DOMAIN" ]] && [[ -n "$DDNS_CONTAINER" ]]; then
|
if [[ -n "$DDNS_DOMAIN" ]] && [[ -n "$DDNS_CONTAINER" ]]; then
|
||||||
PUBLIC_IP=$(curl -sf --max-time 5 https://ifconfig.me 2>/dev/null | tr -d '[:space:]')
|
PUBLIC_IP=$(curl -sf --max-time 5 https://ifconfig.me 2>/dev/null | tr -d '[:space:]')
|
||||||
DNS_IP=$(dig +short "$DDNS_DOMAIN" @1.1.1.1 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)
|
# dig's failure text names the resolver it could not reach (";; communications error to
|
||||||
|
# 1.1.1.1#53: timed out"), so scraping its output for an address yields the server, not the
|
||||||
|
# answer — a guaranteed mismatch that restarts DDNS over what is only a DNS timeout. Trust
|
||||||
|
# the exit status, and anchor the match so only a bare answer line counts. NXDOMAIN exits 0
|
||||||
|
# with no output and correctly falls through to the "could not resolve" branch below.
|
||||||
|
if DNS_ANSWER=$(dig +short "$DDNS_DOMAIN" @1.1.1.1 2>/dev/null); then
|
||||||
|
DNS_IP=$(printf '%s\n' "$DNS_ANSWER" \
|
||||||
|
| grep -Eox '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)
|
||||||
|
else
|
||||||
|
DNS_IP=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z "$PUBLIC_IP" ]]; then
|
if [[ -z "$PUBLIC_IP" ]]; then
|
||||||
warn "Could not determine public IP — skipping DDNS check"
|
warn "Could not determine public IP — skipping DDNS check"
|
||||||
|
|||||||
Reference in New Issue
Block a user