XIU2/CloudflareSpeedTest · warning
CFST 测速结果 IP 数量为 0,跳过下面步骤...
Error message
CFST 测速结果 IP 数量为 0,跳过下面步骤...
What it means
The macOS twin of cfst_hosts.sh: in _UPDATE(), after ./cfst -o result_hosts.txt the check at script/cfst_hosts_mac.sh:38 fires when the output file is missing. CFST only writes result_hosts.txt when at least one IP passes its filters, so the script reports '0 IPs' and exits 0, leaving /etc/hosts and nowip_hosts.txt unchanged.
Source
Thrown at script/cfst_hosts_mac.sh:38
break
else
echo "该 IP 不能是空!"
fi
else
break
fi
done
}
_UPDATE() {
echo -e "开始测速..."
NOWIP=$(head -1 nowip_hosts.txt)
# 这里可以自己添加、修改 CFST 的运行参数
./cfst -o "result_hosts.txt"
# 如果需要 "找不到满足条件的 IP 就一直循环测速下去",那么可以将下面的两个 exit 0 改为 _UPDATE 即可
[[ ! -e "result_hosts.txt" ]] && echo "CFST 测速结果 IP 数量为 0,跳过下面步骤..." && exit 0
# 下面这行代码是 "找不到满足条件的 IP 就一直循环测速下去" 才需要的代码
# 考虑到当指定了下载速度下限,但一个满足全部条件的 IP 都没找到时,CFST 就会输出所有 IP 结果
# 因此当你指定 -sl 参数时,需要移除下面这段代码开头的 # 井号注释符,来做文件行数判断(比如下载测速数量:10 个,那么下面的值就设在为 11)
#[[ $(cat result_hosts.txt|wc -l) > 11 ]] && echo "CFST 测速结果没有找到一个完全满足条件的 IP,重新测速..." && _UPDATE
BESTIP=$(sed -n "2,1p" result_hosts.txt | awk -F, '{print $1}')
if [[ -z "${BESTIP}" ]]; then
echo "CFST 测速结果 IP 数量为 0,跳过下面步骤..."
exit 0
fi
echo ${BESTIP} > nowip_hosts.txt
echo -e "\n旧 IP 为 ${NOWIP}\n新 IP 为 ${BESTIP}\n"
echo "开始备份 Hosts 文件(hosts_backup)..."
\cp -f /etc/hosts /etc/hosts_backup
View on GitHub (pinned to 1da0c025d7)
Solutions
- Run ./cfst -o result_hosts.txt manually and check it executes at all
- If macOS blocks the binary: xattr -d com.apple.quarantine ./cfst && chmod +x ./cfst
- Relax CFST arguments or refresh ip.txt, then re-run the script
- For launchd/cron, make the job cd into the script directory first
- Optionally replace exit 0 with _UPDATE per the in-file comment to loop until a qualifying IP is found (bound the retries)
Example fix
# script/cfst_hosts_mac.sh (before)
./cfst -o "result_hosts.txt"
# (after)
./cfst -o "result_hosts.txt" || { echo "cfst run failed (exit $?)" >&2; exit 1; } Defensive patterns
Strategy: retry
Validate before calling
[ -x ./cfst ] && [ -f ip.txt ] || { echo 'cfst/ip.txt missing' >&2; exit 1; } Try / catch
./cfst -o result_hosts.txt || { echo "cfst exited $? (Gatekeeper?)" >&2; exit 1; } Prevention
- After downloading cfst on macOS, clear the quarantine bit: xattr -d com.apple.quarantine cfst; chmod +x cfst
- Test ./cfst -h manually before wiring the script into cron/launchd
- For launchd, set the working directory in the plist or cd inside a wrapper script
When it happens
Trigger: All IPs failed CFST's filters this run; ./cfst did not execute (binary missing or not executable — note macOS Gatekeeper quarantines downloaded binaries; or ip.txt absent); Cloudflare test ports blocked by the network.
Common situations: Downloaded cfst blocked by macOS security (needs xattr -d com.apple.quarantine cfst) so no result file is ever produced; strict user-added -sl/-t filters; a cron/launchd job running from the wrong working directory.
Related errors
- CFST 测速结果 IP 数量为 0,跳过下面步骤...
- CFST 测速结果 IP 数量为 0,跳过下面步骤...
- CFST 测速结果 IP 数量为 0,跳过下面步骤...
- Failed to get the preferred IPv4 address.
- Failed to get the preferred IPv6 address.
AI-assisted analysis of XIU2/CloudflareSpeedTest@1da0c025d7 (2026-08-15).
Data as JSON: /api/errors/252c653a749ee001.
Report an issue: GitHub.