From ae4fcc9546087845ecd11ff0880522c074ec667b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Thu, 15 May 2025 11:35:53 +0200 Subject: [PATCH] Update install.func --- misc/install.func | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/misc/install.func b/misc/install.func index 39c8907..ab26281 100644 --- a/misc/install.func +++ b/misc/install.func @@ -96,6 +96,7 @@ network_check() { ipv4_connected=false ipv6_connected=false sleep 1 + # Check IPv4 connectivity to Google, Cloudflare & Quad9 DNS servers. if ping -c 1 -W 1 1.1.1.1 &>/dev/null || ping -c 1 -W 1 8.8.8.8 &>/dev/null || ping -c 1 -W 1 9.9.9.9 &>/dev/null; then msg_ok "IPv4 Internet Connected" @@ -114,7 +115,7 @@ network_check() { # If both IPv4 and IPv6 checks fail, prompt the user if [[ $ipv4_connected == false && $ipv6_connected == false ]]; then - read -r -p "No Internet detected,would you like to continue anyway? " prompt + read -r -p "No Internet detected, would you like to continue anyway? " prompt if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then echo -e "${INFO}${RD}Expect Issues Without Internet${CL}" else @@ -123,12 +124,20 @@ network_check() { fi fi + # DNS resolution checks for GitHub-related domains (IPv4 and/or IPv6) GITHUB_HOSTS=("github.com" "raw.githubusercontent.com" "api.github.com") for HOST in "${GITHUB_HOSTS[@]}"; do - RESOLVEDIP=$(getent hosts "$HOST" | awk '{ print $1 }') - if [[ -z "$RESOLVEDIP" || (! "$RESOLVEDIP" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ && ! "$RESOLVEDIP" =~ ^([a-fA-F0-9:]+)$) ]]; then - msg_error "DNS resolution failed or invalid IP for $HOST" + RESOLVEDIP="" + while read -r IP; do + if [[ "$IP" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ || "$IP" =~ ^[a-fA-F0-9:]+$ ]]; then + RESOLVEDIP="$IP" + break + fi + done < <(getent hosts "$HOST" | awk '{ print $1 }') + + if [[ -z "$RESOLVEDIP" ]]; then + msg_error "DNS resolution failed or no valid IPv4/IPv6 address for $HOST" exit 1 else msg_ok "Resolved $HOST → ${BL}$RESOLVEDIP${CL}"