add ping_proxy function

This commit is contained in:
Xtreme
2025-10-26 18:15:40 +03:30
parent e423d7da8a
commit 334e26e7da

View File

@@ -49,6 +49,18 @@ backup_resolv() {
cp /etc/resolv.conf "/etc/resolv.conf.bak.$(date +%Y%m%d_%H%M%S)" cp /etc/resolv.conf "/etc/resolv.conf.bak.$(date +%Y%m%d_%H%M%S)"
} }
ping_proxy() {
local domain="$1"
local times=($(ping -c 3 -W 1 "$domain" 2>/dev/null | grep -oP 'time=\K[0-9.]+'))
if [ ${#times[@]} -gt 0 ]; then
printf '%s\n' "${times[@]}" | sort -n | head -1
else
echo "timeout"
fi
}
# Set DNS servers based on user selection # Set DNS servers based on user selection
set_dns() { set_dns() {
echo echo