From 5393bf1f5f4bb3fc3d1027a3c149b6abbefe469e Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 17 Apr 2025 21:43:43 +0900 Subject: [PATCH] fix: more robust ping method --- helpers/funcs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/helpers/funcs b/helpers/funcs index 80f45f2..57e87f5 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -784,12 +784,17 @@ logger(){ } test_ping(){ shift + local time + local res local ip="$1" local qport="$2" - local res - res=$(ping -c1 -4 -W0.5 $1 | grep time= | awk -F= '{print $4}') - [[ ! $? -eq 0 ]] && res="Timed out" - printf "%s" "$res" + res=$(a2s $ip $qport info) + if [[ -z $res ]]; then + time="Timed out" + else + time=$(<<< "$res" jq -r '.[].ping') + fi + printf "%s" "$time" } show_server_modlist(){ shift