{"record":{"id":"563c5bd0be41b299","repo":"XIU2/CloudflareSpeedTest","slug":"cfst-ip-0-563c5b","errorCode":null,"errorMessage":"CFST 测速结果 IP 数量为 0，跳过下面步骤...","messagePattern":"CFST 测速结果 IP 数量为 0，跳过下面步骤\\.\\.\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"script/cfst_dnsmasq.sh","lineNumber":21,"sourceCode":"export PATH\n# --------------------------------------------------------------\n#\t项目: CloudflareSpeedTest 自动更新 dnsmasq 配置文件\n#\t版本: 1.0.1\n#\t作者: XIU2,Sving1024\n#\t项目: https://github.com/XIU2/CloudflareSpeedTest\n# --------------------------------------------------------------\n\n_UPDATE() {\n\techo -e \"开始测速...\"\n\tBESTIP=\"\"\n\tBESTIP_IPV6=\"::\"\n\t# 这里可以自己添加、修改 CFST 的运行参数\n\t./cfst -o \"result_hosts.txt\"\n\t# 需要测速 IPv6 请取消注释\n\t#./cfst -o \"result_hosts_ipv6.txt\" -f ipv6.txt\n\n\t# 如果需要 \"找不到满足条件的 IP 就一直循环测速下去\"，那么可以将下面的两个 exit 0 改为 _UPDATE 即可\n\t[[ ! -e \"result_hosts.txt\" ]] && echo \"CFST 测速结果 IP 数量为 0，跳过下面步骤...\" && exit 0\n\n\t# 下面这行代码是 \"找不到满足条件的 IP 就一直循环测速下去\" 才需要的代码\n\t# 考虑到当指定了下载速度下限，但一个满足全部条件的 IP 都没找到时，CFST 就会输出所有 IP 结果\n\t# 因此当你指定 -sl 参数时，需要移除下面这段代码开头的 # 井号注释符，来做文件行数判断（比如下载测速数量：10 个，那么下面的值就设在为 11）\n\t#[[ $(cat result_hosts.txt|wc -l) > 11 ]] && echo \"CFST 测速结果没有找到一个完全满足条件的 IP，重新测速...\" && _UPDATE\n\n\tBESTIP=$(sed -n \"2,1p\" result_hosts.txt | awk -F, '{print $1}')\n\t# 需要测速 IPv6 请取消注释\n\t#BESTIP_IPV6=$(sed -n \"2,1p\" result_hosts_ipv6.txt | awk -F, '{print $1}')\n\n\tif [[ -z \"${BESTIP}\" ]]; then\n\t\techo \"CFST 测速结果 IP 数量为 0，跳过下面步骤...\"\n\t\texit 0\n\tfi\n\techo ${BESTIP} > nowip_hosts.txt\n\techo -e \"最优 IPv4 IP 为 ${BESTIP}\\n\"\n\t# 需要测速 IPv6 请取消注释\n\t#echo -e \"最优 IPv6 IP 为 ${BESTIP_IPV6}\\n\"","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/XIU2/CloudflareSpeedTest/blob/1da0c025d7b6f9bf0b2b0cf47a547f65430deab2/script/cfst_dnsmasq.sh#L3-L39","documentation":"In cfst_dnsmasq.sh's _UPDATE(), after ./cfst -o result_hosts.txt the script checks [[ ! -e result_hosts.txt ]] at script/cfst_dnsmasq.sh:21. CFST only creates the output file when at least one IP survives its filters, so a missing file is treated as '0 IPs' and the script exits 0, skipping the dnsmasq cloudflare.conf regeneration from site.conf entirely.","triggerScenarios":"All IPs failed CFST's latency/download filters in the current run; ./cfst could not run (binary missing/not executable, ip.txt absent in the working directory); testing ports blocked so no IP passed.","commonSituations":"Strict -sl/-t arguments added by the user; stale ip.txt; running via cron from the wrong directory so ./cfst resolves to nothing; network behind a firewall that drops Cloudflare 443 traffic.","solutions":["Run ./cfst -o result_hosts.txt by hand in the same directory to see the tester's own output","Confirm cfst is executable (chmod +x cfst) and ip.txt exists next to it","Loosen the CFST parameters or update ip.txt, then re-run the script","For unattended retry, the in-file comment suggests replacing this exit 0 with _UPDATE to loop until a good IP appears (guard against tight infinite loops)"],"exampleFix":"# (before) silent skip when the tester never ran\n[[ ! -e \"result_hosts.txt\" ]] && echo \"CFST 测速结果 IP 数量为 0，跳过下面步骤...\" && exit 0\n# (after) distinguish tester failure from empty result\n./cfst -o \"result_hosts.txt\" || { echo \"cfst failed\" >&2; exit 1; }\n[[ ! -e \"result_hosts.txt\" ]] && echo \"CFST 测速结果 IP 数量为 0，跳过下面步骤...\" && exit 0","handlingStrategy":"retry","validationCode":"[ -x ./cfst ] && [ -f ip.txt ] || { echo 'cfst/ip.txt missing in CWD' >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"./cfst -o result_hosts.txt || { echo \"cfst exited $?\" >&2; exit 1; }","preventionTips":["Always invoke the script from its own directory (cd first in cron entries)","Sanity-run ./cfst by hand after changing -t/-sl/-dn arguments","If enabling the _UPDATE retry loop the comments mention, bound it with a max-attempts counter"],"tags":["shell","bash","dnsmasq","cloudflare","speedtest","empty-result"],"backgroundTag":null,"analyzedSha":"1da0c025d7b6f9bf0b2b0cf47a547f65430deab2","analyzedAt":"2026-08-15T22:22:10.737Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}