fix: ash-compatible arithmetic in _cached_speedtest; clean up speedtest null guards

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 03:26:04 +00:00
parent 8ea704f7e3
commit a4ba9f8fcd
@@ -292,8 +292,8 @@ _collect_wan() {
_dl=$(echo "$_st" | awk '{print $1}')
_ul=$(echo "$_st" | awk '{print $2}')
fi
[ -z "$_dl" ] || [ "$_dl" = "0" ] && _dl="0.0"
[ -z "$_ul" ] || [ "$_ul" = "0" ] && _ul="0.0"
[ -n "$_dl" ] || _dl="0.0"
[ -n "$_ul" ] || _ul="0.0"
fi
printf '{"score":%s,"latency_ms":%s,"dl_mbps":%s,"ul_mbps":%s,"jitter_ms":%s,"loss_pct":%s}' \
@@ -416,7 +416,8 @@ _cached_speedtest() {
[ -f "$_f" ] || return 1
_mtime=$(stat -c %Y "$_f" 2>/dev/null || stat -f %m "$_f" 2>/dev/null)
[ -n "$_mtime" ] || return 1
_age=$(( $(date +%s) - _mtime ))
_st_now=$(date +%s)
_age=$(( _st_now - _mtime ))
[ "$_age" -lt 2100 ] || return 1
cat "$_f"
}