fix: more robust ping method

This commit is contained in:
aclist committed 2025-04-17 21:43:43 +09:00
1 parent 90b3aa8663
commit 5393bf1f5f
1 file changed
+9 -4
+9 -4
View File
@@ -784,12 +784,17 @@ logger(){
} }
test_ping(){ test_ping(){
shift shift
local time
local res
local ip="$1" local ip="$1"
local qport="$2" local qport="$2"
local res res=$(a2s $ip $qport info)
res=$(ping -c1 -4 -W0.5 $1 | grep time= | awk -F= '{print $4}') if [[ -z $res ]]; then
[[ ! $? -eq 0 ]] && res="Timed out" time="Timed out"
printf "%s" "$res" else
time=$(<<< "$res" jq -r '.[].ping')
fi
printf "%s" "$time"
} }
show_server_modlist(){ show_server_modlist(){
shift shift