CloudflareSpeedTest icon indicating copy to clipboard operation
CloudflareSpeedTest copied to clipboard

大佬,能不能把这个 ip-scanner/cloudflare 里面的中转 CF IP 每天自动同步到自己托管到 CF 的域名解析里

Open AtoiX opened this issue 2 years ago • 8 comments

大佬,我想把这个https://github.com/ip-scanner/cloudflare 里面的中转CFip每天自动同步到自己托管到cf的域名解析里,这些中转ip经常变,能不能搞一个github Action定时任务 比如把https://github.com/ip-scanner/cloudflare/blob/daily/Alibaba%20Cloud%20-%20中国%20香港.txt 每天自动更新到自己的alihk.cfip.xxx域名解析。这样使用smartdns surge QX这种客户端就可以自动获取连接最快的ip,大佬能不能搞一搞

AtoiX avatar Apr 05 '22 05:04 AtoiX

我对 Github Action 不熟,都没用过。

XIU2 avatar Apr 05 '22 06:04 XIU2

大佬,我想把这个https://github.com/ip-scanner/cloudflare 里面的中转CFip每天自动同步到自己托管到cf的域名解析里,这些中转ip经常变,能不能搞一个github Action定时任务 比如把https://github.com/ip-scanner/cloudflare/blob/daily/Alibaba%20Cloud%20-%20中国%20香港.txt 每天自动更新到自己的alihk.cfip.xxx域名解析。这样使用smartdns surge QX这种客户端就可以自动获取连接最快的ip,大佬能不能搞一搞

我测了几个,确实很快,问题是,稳定吗?要是不稳定,,也没用啊;

技术方案确实可行。

xianshenglu avatar May 02 '22 12:05 xianshenglu

的alihk.cfip

话说,知道那些数据哪来的吗?

xianshenglu avatar May 02 '22 12:05 xianshenglu

@xianshenglu 这些 IP 显然都是扫描来的,针对一些 VPS 的 IP 段扫描 443 端口(甚至用我的 CloudflareST 都能扫描,不过毕竟不是设计干这个的,所以效率太低)。 这些 IP 其实都是个人自建的 SNI 反向代理(或 端口转发),因此无法保证稳定性,用的人多了,可能就发现异常就给关了。。

XIU2 avatar May 03 '22 01:05 XIU2

我猜,你的问题是,如果使用工具找出了高速的Cloudflare的IP节点,如何更新到自己的v2ray这类节点上。

在这里我是这样做的

1.申请一个changeip.com的服务,免费搞几个DDNS域名。 2.你的节点地址就用这几个DDNS域名。 3.找出的Cloudflare高速IP就影射到这些域名上就行了,这方案我用了好几年了。 bat脚本例子: call curl "https://nic.changeip.com/nic/update?cmd=update&u=%DDNS_UID%&p=%DDNS_PWD%&hostname=%node_Current.DDNS_Name%&ip=!lastip!"

DDNS_UID = changeip.com user id DDNS_PWD = changeip.com password node_Current.DDNS_Name = ddns name lastip = Cloudflare IP address

issacqin avatar May 08 '22 15:05 issacqin

感谢这位大兄弟推荐了这么好的项目,同样对github aciton不太熟,用shell脚本写出来了,方便给使用openwrt的兄弟提供个参考。 具体功能是 获取ip-scanner/cloudflare项目并整合所有ip -> 通过CFST测速导出结果 -> Cloudflare域名解析优选IP

#!/usr/bin/env bash
#测速前自行修改代码停用openwrt的科学上网插件,如无安装请删除下面这行带stop的代码
/etc/init.d/shadowsocksr stop
echo -e "清除旧版本ip-scanner/cloudflare项目..."
rm -rf ./ip/cloudflare-daily
echo -e "获取ip-scanner/cloudflare项目并整合ip..."
#自选下载链接,第一个是github源站,后面两个是方便墙内的反代加速下载链接(网络搜集而来)
	#https://github.com/ip-scanner/cloudflare/archive/refs/heads/daily.zip
	#https://gh.api.99988866.xyz/https://github.com/ip-scanner/cloudflare/archive/refs/heads/daily.zip
	#https://github.91chi.fun/https://github.com/ip-scanner/cloudflare/archive/refs/heads/daily.zip
wget -N -P ./ip https://github.com/ip-scanner/cloudflare/archive/refs/heads/daily.zip
unzip ./ip/daily.zip -d ./ip
cat ./ip/cloudflare-daily/*.txt > ./ip/all.txt
echo -e "开始测速..."
# 这里根据自己需求添加、修改 CloudflareST 的运行参数
./CloudflareST -sl 5 -dn 3 -dt 5 -tl 200 -f ./ip/all.txt -url https://cdn.cloudflare.steamstatic.com/steam/apps/256843155/movie_max.mp4 -o result.csv
FIRSTIP=$(sed -n "2,1p" result.csv | awk -F, '{print $1}')  #提取下载测速列表第一行的ip
#SECIP=$(sed -n "3,1p" result.csv | awk -F, '{print $1}')  #提取下载测速列表第二行的ip
#THIRDIP=$(sed -n "4,1p" result.csv | awk -F, '{print $1}')  #提取下载测速列表第三行的ip
#开始更新Cloudflare域名解析
zoneid="ZoneIdxxxxxxxxxxxxx"               ##### Cloudflare's Zone ID
proxied="false"                 ##### 是否使用Cloudflare小云朵,此项目不需要开启
ttl=1                         ##### 120-7200 秒或 1=自动
cloudflare_api_token="xxxxxxxxxxxxxxxxxxxxxxxx" ##### Cloudflare API Token 请勿暴露自己token
useremail="[email protected]"
dns_record="xxx.xxx.com"
dns_record_id="DnsRecordIdxxxxxxxxxxxx" 
update=$(curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records/$dns_record_id" \
	  -H "X-Auth-Email: $useremail" \
	  -H "X-Auth-Key: $cloudflare_api_token" \
	  -H "Content-Type: application/json" \
	  --data "{\"type\":\"A\",\"name\":\"$dns_record\",\"content\":\"$FIRSTIP\",\"ttl\":$ttl,\"proxied\":$proxied}")

if [[ $update == *"\"success\":false"* ]]; then
	echo -e "==> $dns_record FAILED:\n$update"
	exit 1
else
	echo "==> $dns_record DNS Record Updated To: $FIRSTIP"
fi
/etc/init.d/shadowsocksr restart #根据自身使用插件修改,若无科学上网插件则直接删除本行代码

RealSlakey avatar May 12 '22 03:05 RealSlakey

有这类项目 优选ip 自动替换到域名解析中 https://github.com/ddgth/cf2dns

sxml avatar Jul 07 '22 08:07 sxml