Improve PMA IP fallback with final OpenDNS 8443 probe

main
Anthony 2026-02-26 23:33:33 +08:00
parent 52df5d0058
commit 716b67ca0d
1 changed files with 11 additions and 0 deletions

View File

@ -636,6 +636,17 @@ if command -v timeout >/dev/null 2>&1; then
break break
fi fi
done done
# Final IP fallback: probe externally observed public IP even if earlier
# candidates existed but were private/non-routable for inbound 8443.
if [[ -z "$SELECTED_URL_HOST" ]] && command -v dig >/dev/null 2>&1; then
observed_public_ip="$(dig +short myip.opendns.com @resolver1.opendns.com 2>/dev/null | tail -n1 || true)"
if [[ "$observed_public_ip" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]] && [[ ! "$observed_public_ip" =~ ^(10\.|127\.|169\.254\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|192\.168\.) ]]; then
if timeout 4 bash -c "exec 3<>/dev/tcp/$observed_public_ip/8443" >/dev/null 2>&1; then
SELECTED_URL_HOST="$observed_public_ip"
fi
fi
fi
fi fi
if [[ -n "$SELECTED_URL_HOST" ]] && [[ "$SELECTED_URL_HOST" != "$URL_HOST" ]]; then if [[ -n "$SELECTED_URL_HOST" ]] && [[ "$SELECTED_URL_HOST" != "$URL_HOST" ]]; then