From 716b67ca0d7ad9f54a6a525e60152d5cd3da2e37 Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 26 Feb 2026 23:33:33 +0800 Subject: [PATCH] Improve PMA IP fallback with final OpenDNS 8443 probe --- scripts/pma-gateway/create_pma_gateway.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/pma-gateway/create_pma_gateway.sh b/scripts/pma-gateway/create_pma_gateway.sh index 169f6e1..eb15ec2 100644 --- a/scripts/pma-gateway/create_pma_gateway.sh +++ b/scripts/pma-gateway/create_pma_gateway.sh @@ -636,6 +636,17 @@ if command -v timeout >/dev/null 2>&1; then break fi 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 if [[ -n "$SELECTED_URL_HOST" ]] && [[ "$SELECTED_URL_HOST" != "$URL_HOST" ]]; then