mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-29 05:30:53 +00:00
Improve network connectivity and DNS checks (#13222)
This commit is contained in:
committed by
GitHub
parent
4ce6271ec0
commit
a2616ee258
@@ -90,11 +90,18 @@ setting_up_container() {
|
|||||||
network_check() {
|
network_check() {
|
||||||
set +e
|
set +e
|
||||||
trap - ERR
|
trap - ERR
|
||||||
|
ipv4_connected=false
|
||||||
|
|
||||||
|
# Check IPv4 connectivity to Cloudflare, Google & 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
|
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
|
||||||
ipv4_status="${GN}✔${CL} IPv4"
|
msg_ok "IPv4 Internet Connected"
|
||||||
|
ipv4_connected=true
|
||||||
else
|
else
|
||||||
ipv4_status="${RD}✖${CL} IPv4"
|
msg_error "IPv4 Internet Not Connected"
|
||||||
read -r -p "Internet NOT connected. Continue anyway? <y/N> " prompt
|
fi
|
||||||
|
|
||||||
|
if [[ $ipv4_connected == false ]]; then
|
||||||
|
read -r -p "No Internet detected, would you like to continue anyway? <y/N> " prompt
|
||||||
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
|
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
echo -e "${INFO}${RD}Expect Issues Without Internet${CL}"
|
echo -e "${INFO}${RD}Expect Issues Without Internet${CL}"
|
||||||
else
|
else
|
||||||
@@ -102,12 +109,28 @@ network_check() {
|
|||||||
exit 122
|
exit 122
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }')
|
|
||||||
if [[ -z "$RESOLVEDIP" ]]; then
|
# DNS resolution checks for GitHub-related domains
|
||||||
msg_error "Internet: ${ipv4_status} DNS Failed"
|
GIT_HOSTS=("github.com" "raw.githubusercontent.com" "api.github.com" "git.community-scripts.org")
|
||||||
|
GIT_STATUS="Git DNS:"
|
||||||
|
DNS_FAILED=false
|
||||||
|
|
||||||
|
for HOST in "${GIT_HOSTS[@]}"; do
|
||||||
|
RESOLVEDIP=$(getent hosts "$HOST" | awk '{ print $1 }' | grep -E '(^([0-9]{1,3}\.){3}[0-9]{1,3}$)|(^[a-fA-F0-9:]+$)' | head -n1)
|
||||||
|
if [[ -z "$RESOLVEDIP" ]]; then
|
||||||
|
GIT_STATUS+="$HOST:($DNSFAIL)"
|
||||||
|
DNS_FAILED=true
|
||||||
|
else
|
||||||
|
GIT_STATUS+=" $HOST:($DNSOK)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$DNS_FAILED" == true ]]; then
|
||||||
|
fatal "$GIT_STATUS"
|
||||||
else
|
else
|
||||||
msg_ok "Internet: ${ipv4_status} DNS: ${BL}${RESOLVEDIP}${CL}"
|
msg_ok "$GIT_STATUS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user