XIU2/CloudflareSpeedTest · warning

CFST 测速结果 IP 数量为 0,跳过下面步骤...

Error message

CFST 测速结果 IP 数量为 0,跳过下面步骤...

What it means

In cfst_hosts.sh's _UPDATE(), after ./cfst -o result_hosts.txt the existence check at script/cfst_hosts.sh:38 fires when the output file is absent: CFST writes result_hosts.txt only when at least one IP passes its filters, so 'file missing' is equated with '0 qualifying IPs'. The script then exits 0, leaving /etc/hosts untouched and NOWIP (from nowip_hosts.txt) as the active mapping.

Source

Thrown at script/cfst_hosts.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

  1. Run ./cfst -o result_hosts.txt manually in the script directory and read its output
  2. Verify ./cfst is executable and ip.txt exists; chmod +x cfst if needed
  3. Ease the CFST arguments (higher -t, lower -sl) or update ip.txt and retry
  4. If run from cron, ensure the job cds into the script directory first (or use absolute paths)
  5. To retry instead of skip, follow the file's own comment: replace exit 0 with _UPDATE (guard against tight loops)

Example fix

# script/cfst_hosts.sh (before)
./cfst -o "result_hosts.txt"
[[ ! -e "result_hosts.txt" ]] && echo "CFST 测速结果 IP 数量为 0,跳过下面步骤..." && exit 0
# (after)
./cfst -o "result_hosts.txt" || { echo "cfst run failed" >&2; exit 1; }
Defensive patterns

Strategy: retry

Validate before calling

[ -x ./cfst ] && [ -f ip.txt ] || { echo 'cfst/ip.txt missing' >&2; exit 1; }
[ -f nowip_hosts.txt ] || echo 'first run: nowip_hosts.txt absent, NOWIP will be empty' >&2

Try / catch

./cfst -o result_hosts.txt || { echo "cfst exited $?" >&2; exit 1; }

Prevention

When it happens

Trigger: Every candidate IP failed the latency/download filters; ./cfst did not actually run (missing binary, not executable, or ip.txt absent in the working directory); outbound 443/80 to Cloudflare ranges blocked so CFST found nothing.

Common situations: User tightened -t/-sl/-tl beyond what current Cloudflare IPs satisfy; a cron job whose working directory is not the script directory so ./cfst fails silently; outdated ip.txt after Cloudflare renumbered ranges.

Related errors


AI-assisted analysis of XIU2/CloudflareSpeedTest@1da0c025d7 (2026-08-15). Data as JSON: /api/errors/3e4a7e58bcf0d2a0. Report an issue: GitHub.