Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenWrt 路由器定时测速获得优质 IP 并替换指定 PassWall 节点 IP 的脚本 #156

Closed
likefu40 opened this issue Dec 30, 2021 · 53 comments
Labels
工具教程 辅助工具 或 技巧教程

Comments

@likefu40
Copy link

likefu40 commented Dec 30, 2021

#!/bin/bash

# 进入 CloudflareST 目录(脚本示例中的 CloudflareST 位于 /root/CloudflareST 目录下,不一样的话自己改这里)
# 之所以要进入文件夹去执行,是为了以相对路径运行,对于新手使用来说能避免很多路径方面问题的出现
cd /root/CloudflareST

# 运行 CloudflareST 测速(自行根据需求修改参数)
./CloudflareST -tll 90

# 获取最快 IP(从 result.csv 结果文件中获取第一个 IP)
IP=$(sed -n "2,1p" result.csv | awk -F, '{print $1}')

# 判断一下是否成功获取到了最快 IP(如果没有就退出脚本):
[[ -z "${IP}" ]] && echo "CloudflareST 测速结果 IP 数量为 0,跳过下面步骤..." && exit 0

# 修改 passwall 里对应节点的 IP(XXXXXX 就是节点 ID)
uci set passwall.XXXXXX.address="${IP}"

# 最后再重启一下 passwall
uci commit passwall
/etc/init.d/haproxy restart
/etc/init.d/passwall restart

将这个脚本添加到 crontab 中定时运行即可。

至于 CloudflareST 文件如何下载解压使用可以参考项目说明中写的 Linux 使用示例


# 如何获取 PassWall 节点 ID?

查看 PassWall 配置文件:

cat /etc/config/passwall

每个节点配置顶部都有一行 config nodes 'XXXXXX' ,其中 XXXXXX 就是节点 ID。


上面是我自己鼓捣的,我本人小小白没学过 linux 各种命令,我知道我写的 shell 不对,需要检测上一个 shell 是否完成才能赋值,赋值我也不会(已经帮忙修改)。求助路过的大佬指点迷津。我就是想实现利用脚本定时筛选 IP 替换翻墙用的 IP 节点!
我之前用的是 https://github.com/badafans/better-cloudflare-ip

@XIU2
Copy link
Owner

XIU2 commented Dec 30, 2021

你这是现成的脚本?还是命令步骤?给我看蒙了都。。。颠三倒四的感觉。。。

我以前给一个 openwrt 上用 passwall 的也折腾过,不过我对 openwrt 不熟悉,只是帮写了个脚本,并远程协助配置了下。。。

@XIU2
Copy link
Owner

XIU2 commented Dec 30, 2021

你想要表达的意思是不是这个:

运行 CloudflareST 测速(注意 -tp 默认值就是 443 因此可以省略),

/root/CloudflareST/CloudflareST -tll 90

获取最快 IP,

IP=$(sed -n "2,1p" /root/CloudflareST/result.csv | awk -F, '{print $1}')

然后判断一下是否获取到了最快 IP(如果没有就退出脚本):

[[ -z "${IP}" ]] && echo "CloudflareST 测速结果 IP 数量为 0,跳过下面步骤..." && exit 0

然后这样修改 passwall 里的 IP?

uci set passwall.xxxxxxxxxxxxx.address=IP

最后再重启一下?

uci commit passwall
/etc/init.d/haproxy restart
/etc/init.d/passwall restart

@likefu40
Copy link
Author

感谢大佬,openwrt也是linux系统吧。怎么感觉好像没有测速吧,我试了可以很快就完成替换。还是很感谢你抽时间帮助

@XIU2
Copy link
Owner

XIU2 commented Dec 30, 2021

有需要,我可以提供远程协助帮忙解决一些问题,虽然我对 openwrt 不熟,但是对 Linux、Shell 脚本什么的比较熟。

顺便可以帮你完善一下脚本,这样这个 Issues 也能帮到后来者~


远程协助软件(这个是只有被控功能的单文件版),告诉我你的设备代码、临时密码(我看到后会删除)。
https://dl.todesk.com/windows/ToDesk_Lite.exe

@XIU2
Copy link
Owner

XIU2 commented Dec 30, 2021

你发的是 better-cloudflare-ip 项目的脚本文件呀。。。

@XIU2
Copy link
Owner

XIU2 commented Dec 30, 2021

可是你发的这个脚本我和项目也没啥关系呀。。。
里面压根都没有 CloudflareST。

@likefu40
Copy link
Author

就是用的那位大佬的,直接筛选后借用获取的赋值直接替换 passwall节点ip 用trojan-go 搭配cf的优选节点可以实现本地加速。我是看到你的脚本,想到能不能同样的实现替换ip。没别的意思。

@XIU2
Copy link
Owner

XIU2 commented Dec 30, 2021

只用我的 CloudflareST 的话,脚本不需要这么长,几行代码最多十几行就写完了。

我前面(3L)就已经把需要的脚本核心代码都写出来了,组合起来就差不多能用了。


另外,如果以绝对路径运行 CloudflareST,那么就需要手动指定绝对路径的 -f-o 参数,否则软件会因为找不到 ip.txt 而报错

@likefu40
Copy link
Author

那位大佬的脚本,每次只能测试100个ip。是的我也只是想试试,能不能实现。可是发现我没基础,鼓捣半天也没成功

@likefu40
Copy link
Author

我看到你的项目,确实能更少的代码就能实现,还是多谢您的帮助

@XIU2
Copy link
Owner

XIU2 commented Dec 30, 2021

如果你完全没有 Shell 基础的话,那就别折腾了,我直接远程协助帮你写脚本 + 配置好,节省双方时间(相比直接教你而言)。

Repository owner deleted a comment from likefu40 Dec 30, 2021
@XIU2 XIU2 changed the title openwrt 路由定时筛选优质ip 并替换到到指定passwall 节点ip OpenWrt 路由器定时测速获得优质 IP 并替换指定 PassWall 节点 IP 的脚本 Dec 30, 2021
@XIU2 XIU2 added the 工具教程 辅助工具 或 技巧教程 label Dec 30, 2021
Repository owner deleted a comment from likefu40 Dec 30, 2021
@likefu40
Copy link
Author

likefu40 commented Dec 30, 2021

再次感谢大佬热情执着的帮助,用大佬的脚本,简短的命令就能实现 在openwrt 定时筛选cf本地最优ip 并替换passwall的trojan-go vless ws协议的ip地址,加速。让垃圾,晚高峰获得更优速度!大佬很耐心细心!!!!再次感谢。大佬已经把脚本完善,太贴心了!!!!!

@recmess
Copy link

recmess commented Jan 6, 2022

非常感谢,已用上

@XIU2 XIU2 pinned this issue Jan 6, 2022
@bluewyj
Copy link

bluewyj commented Jan 7, 2022

likefu40,分享一下脚本?

@XIU2
Copy link
Owner

XIU2 commented Jan 8, 2022

@bluewyj 脚本就是 1L 的内容,我已经帮它改好了,并且已经远程协助在他的路由器上运行验证过了。

@bluewyj
Copy link

bluewyj commented Jan 8, 2022

@XIU2 谢谢也用上了

@bluewyj
Copy link

bluewyj commented Jan 8, 2022

#!/bin/bash
sleep 8s

/etc/init.d/haproxy stop
/etc/init.d/passwall stop

# 进入 CloudflareST 目录
cd /root/CloudflareST

# 运行 CloudflareST 测速(脚本示例中的 CloudflareST 位于 /root/CloudflareST 目录下)
./CloudflareST -tll 90

# 获取最快 IP
IP=$(sed -n "2,1p" result.csv | awk -F, '{print $1}')

# 判断一下是否成功获取到了最快 IP(如果没有就退出脚本):
[[ -z "${IP}" ]] && echo "CloudflareST 测速结果 IP 数量为 0,跳过下面步骤..." && exit 0

# 修改 passwall 里对应节点的 IP(XXX 就是节点 ID)
uci set passwall.xxxxxxx.address="${IP}"
uci commit passwall
/etc/init.d/haproxy restart
/etc/init.d/passwall restart
exit

@likefu40
Copy link
Author

#!/bin/bash
sleep 8s

/etc/init.d/haproxy stop
/etc/init.d/passwall stop

# 进入 CloudflareST 目录
cd /root/CloudflareST

# 运行 CloudflareST 测速(脚本示例中的 CloudflareST 位于 /root/CloudflareST 目录下)
./CloudflareST -tll 90

# 获取最快 IP
IP=$(sed -n "2,1p" result.csv | awk -F, '{print $1}')

# 判断一下是否成功获取到了最快 IP(如果没有就退出脚本):
[[ -z "${IP}" ]] && echo "CloudflareST 测速结果 IP 数量为 0,跳过下面步骤..." && exit 0

# 修改 passwall 里对应节点的 IP(XXX 就是节点 ID)
uci set passwall.xxxxxxx.address="${IP}"
uci commit passwall
/etc/init.d/haproxy restart
/etc/init.d/passwall restart
exit

passwall支持路由器自身代理为gfw模式,这样就不用筛选ip时停止passwall了!

@RealKiro
Copy link

RealKiro commented Jan 18, 2022

为什么不用这个?随固件编译进去就完事

@XIU2
Copy link
Owner

XIU2 commented Jan 18, 2022

@RealKiro 估计是没什么人看 discussions 吧。。。大家都习惯用 Issues 了,虽然我也在 Releases 中提到了这个项目链接。

@ramuses
Copy link

ramuses commented Jan 29, 2022

这个很有用,谢谢了

@su2353
Copy link

su2353 commented Feb 5, 2022

SSR-PLUS要怎么弄呢?

@peter2022
Copy link

./CloudflareST -tll 90 -p 30 输出结果没有显示30条测试结果?

@XIU2
Copy link
Owner

XIU2 commented Feb 6, 2022

@peter2022 你的最终测速结果数量 >= 30 条,才能显示出来 30 条。

@peter2022
Copy link

peter2022 commented Feb 14, 2022

/etc/init.d/haproxy stop
/etc/init.d/passwall stop
请问这两个命令,停止pw 和ha后,跑CloudflareST,延迟测速跑得非常快,下载测速测出的速度也就在10-20M之间,pw基本设置-模式-tcp udp的模式选择中国列表以外。
当选择pw的tcp udp的模式(或者路由器自身 TCP UDP代理模式 gfw) 选择gfw列表时,延迟和下载都正常。
请问passwall stop 无效吗? 问题出在哪里?

@XIU2
Copy link
Owner

XIU2 commented Feb 14, 2022

@peter2022 你的意思是:
当代理模式为:中国列表以外 时(白名单),无论是否关闭代理插件都会导致 CloudflareST 测速异常?(请贴出测速结果内容
当代理模式为:GFW 列表 时(黑名单),无论是否关闭代理插件都测速正常?(请贴出测速正常时的结果内容

@peter2022
Copy link

peter2022 commented Feb 14, 2022

当代理模式为:中国列表以外 时(白名单),结果如下:

IP 地址           已发送  已接收  丢包率  平均延迟  下载速度 (MB/s)
162.159.200.254   4       4       0.00    90.08     3.89
162.158.238.42    4       4       0.00    90.29     3.89
104.27.94.153     4       4       0.00    90.26     3.88
104.21.68.180     4       4       0.00    90.09     3.88
162.159.124.188   4       4       0.00    90.04     3.88
198.41.132.146    4       4       0.00    90.14     3.87
104.16.54.124     4       4       0.00    90.30     3.87
162.158.133.103   4       4       0.00    90.06     3.87
198.41.193.203    4       4       0.00    90.15     3.87
104.16.113.204    4       4       0.00    90.13     3.87

但是当使用白名单时,路由的代理模式改为黑名单,就跟下面的效果一样,都好用。

当代理模式为:GFW 列表 时(黑名单), 结果正常,平均延迟 90 ~ 250ms 下载速度也是 30MB/s+

bash /etc/init.d/haproxy stop
bash /etc/init.d/passwall stop

cd /root/CloudflareST
./CloudflareST -tll 90 -tl 250 -dn 15 -url  ***200mb.test  
IP=$(sed -n "2,1p" result.csv | awk -F, '{print $1}')
[[ -z "${IP}" ]] && echo "CloudflareST ${IP} Error" && exit 0

uci set passwall.***.address="${IP}"
uci commit passwall

bash /etc/init.d/haproxy restart
bash /etc/init.d/passwall restart

@XIU2
Copy link
Owner

XIU2 commented Feb 14, 2022

@peter2022 很显然,白名单模式时(中国列表以外)所有名单外的链接全部走代理了。
因此你可能需要把所有 Cloudflare IP 及 下载测速地址的域名都加入白名单中,但是这样可能会导致你访问使用 Cloudflare CDN 的网站时,可能不会走代理?具体我不清楚你用的代理软件逻辑是什么。

对于 PassWall 相关问题,我完全不清楚,无法给予帮助。

@likefu40
Copy link
Author

passwall支持路由器自身代理为gfw模式,这样就不用筛选ip时停止passwall了!

@hoockoo
Copy link

hoockoo commented Jun 24, 2022

#!/usr/bin/python
# -*- coding:utf-8 -*-
import os
import sys
import csv


def get_ip(filecsv):  # 读取CSV文件并转换为字典并将key为'IP 地址'中的IP地址全部读取到一个列表并返回。
    with open(filecsv, 'r', encoding='utf8') as f:
        result = [i['IP 地址'] for i in csv.DictReader(f)]
    return result


def get_nodesid():  # 通过传入参数中输入的节点名称查询该节点在passwalll2中的唯一ID。
    return os.popen(f"uci show passwall2 | grep -w {sys.argv[1]}").readlines()[0][10:42]


def get_bestip(ip):  # 传入一个IP与目前在用的IP进行对比测速,返回最优IP。
    oldip = os.popen(f"uci get passwall2.{get_nodesid()}.address").readlines()[0][:-1]  # 查询节点目前在用的优选IP。
    with open('1.txt', 'w+', encoding='utf8') as f:
        f.write(oldip + '\n' + ip)
    os.system("./CloudflareST -o bestip.csv -f 1.txt >/dev/null 2>&1")
    result = get_ip('bestip.csv')[0]
    return result


def main():
    os.chdir("/root/CloudflareST")  # 修改工作目录
    os.system("uci set passwall2.@global[0].localhost_proxy='0' && uci commit passwall2")  # 关闭'路由器本机代理'功能
    os.system("/etc/init.d/passwall2 restart  && ./CloudflareST -tll 100 >/dev/null 2>&1")
    try:
        os.system(f"uci set passwall2.{get_nodesid()}.address='{get_bestip(get_ip('result.csv')[0])}'")
    except IndexError:
        pass
    finally:
        os.system("uci set passwall2.@global[0].localhost_proxy='1'")
        os.system("uci commit passwall2 && /etc/init.d/passwall2 restart")


if __name__ == '__main__':
    main()

根据上面写了一个python脚本用于passwall2,每次测速后都会对result.csv的第一个IP和目前在用的IP在进行一次对比测速,新IP优于旧IP才会替换掉旧的。
食用步骤:
1.把上面脚本保存为xxx.py,并和作者大大CloudflareST的所有文件一并丢到/root/CloudflareST目录下并chmod +x /root/CloudflareST/CloudflareST
2.运行python xxx.py 节点名称,例如你节点名称是abcd则运行python xxx.py abcd
3.因为作者大大内置的测速地址并不稳定,建议使用自建的测速地址,可以在22和30行处添加 -url https://xxxxx

@sxml
Copy link

sxml commented Jul 16, 2022

SSR怎么写?

@hoockoo
Copy link

hoockoo commented Jul 18, 2022

SSR怎么写?

是passwall2里面用SSR?SSR不能用CDN吧?

@VwEl
Copy link

VwEl commented Jul 23, 2022

SSR怎么写?

是passwall2里面用SSR?SSR不能用CDN吧?

他意思是ShadowSocksR Plus+这个插件要怎么写把

@hoockoo
Copy link

hoockoo commented Sep 5, 2022

SSR怎么写?

SSRP+还没用过,没有写呢,目前只写了passwall、passwall2、openclash的脚本。

@gzafei
Copy link

gzafei commented Sep 10, 2022

SSR怎么写?

SSRP+还没用过,没有写呢,目前只写了passwall、passwall2、openclash的脚本。

请问openclash如何用?

@hoockoo
Copy link

hoockoo commented Sep 11, 2022

SSR怎么写?

SSRP+还没用过,没有写呢,目前只写了passwall、passwall2、openclash的脚本。

请问openclash如何用?

中秋假期出去玩了,我节后给你。

@120318
Copy link

120318 commented Sep 11, 2022

SSR怎么写?

SSRP+还没用过,没有写呢,目前只写了passwall、passwall2、openclash的脚本。

请问openclash如何用?

中秋假期出去玩了,我节后给你。

openclash要是能不停止就好了,不知道有什么办法能让这个测速脚本不走openclash

@hoockoo
Copy link

hoockoo commented Sep 12, 2022

'''

SSR怎么写?

SSRP+还没用过,没有写呢,目前只写了passwall、passwall2、openclash的脚本。

请问openclash如何用?

#!/usr/bin/python
# -*- coding:utf-8 -*-
import os
import sys
import csv
import re


def get_ip(filecsv):
    with open(filecsv, 'r', encoding='utf8') as f:
        result = [i['IP 地址'] for i in csv.DictReader(f)]
    return result


def get_nodesid(name):
    result = re.search(r'\W\d(\d)?\W', os.popen(f"uci show openclash | grep -w {name}").readline()).group()
    return result


def get_bestip():
    cdnip = [os.popen(f"uci show openclash.@servers{get_nodesid(i)} | grep -w server=")
             .readline()[28:-2] for i in sys.argv[1:]] + get_ip('result.csv')[:len(sys.argv[1:])]
    with open('1.txt', 'w+', encoding='utf8') as f:
        for i in cdnip:
            f.write(i + '\n')
    os.system("./CloudflareST -o bestip.csv -f 1.txt >/dev/null 2>&1")
    result = get_ip('bestip.csv')[:len(sys.argv[1:])]
    return result


def main():
    os.system("/etc/init.d/openclash stop >/dev/null 2>&1")
    os.system("./CloudflareST >/dev/null 2>&1")
    for name, ip in zip(sys.argv[1:], get_bestip()):
        os.system(f"uci set openclash.@servers{get_nodesid(name)}.server='{ip}'")
    os.system("uci commit openclash  && /etc/init.d/openclash start >/dev/null 2>&1")


if __name__ == '__main__':
    main()

openclash节点更新cfip脚本食用步骤:
以CloudflareST的目录为/root/CloudflareST,openclash里面有2个节点套了cf的ip,节点名称(别名)分别为s1和s2为例子
1、将上面的脚本保存为CloudflareST_openclash.py并放到CloudflareST文件夹中
2、进入到CloudflareST目录执行chmod +x CloudflareST
3、cd /root/CloudflareST && python CloudflareST_openclash.py s1 s2 执行这个命令进行IP的测速和更新,也可添加到计划任务里
4、建议使用自建测速地址进行测速,可在脚本的27和34行添加-url参数

PS:如果你有多个cf节点例如s1、s2、s3、s4、s5,执行cd /root/CloudflareST && python CloudflareST_openclash.py s1 s2 s3 s4 s5
如果只有一个s1节点就执行cd /root/CloudflareST && python CloudflareST_openclash.py s1
脚本需要配合作者的CloudflareST使用且openwrt上有python3,请下载对应你路由CPU版本的CloudflareST,例如arm、mipsle、amd64等等,openclash里面可以查看路由处理器架构。
脚本原理:根据你输入的节点数量(例如5个)取result.csv里面前5位ip,并和目前在用的5个节点的ip再次进行ip优选,再取结果的前5的IP地址更新到openclash的5个节点。

@hoockoo
Copy link

hoockoo commented Sep 12, 2022

SSR怎么写?

SSRP+还没用过,没有写呢,目前只写了passwall、passwall2、openclash的脚本。

请问openclash如何用?

中秋假期出去玩了,我节后给你。

openclash要是能不停止就好了,不知道有什么办法能让这个测速脚本不走openclash

那估计是openclash的bug了,只能等作者慢慢修复了,笑哭~

@likefu40
Copy link
Author

SSR怎么写?

SSRP+还没用过,没有写呢,目前只写了passwall、passwall2、openclash的脚本。

请问openclash如何用?

中秋假期出去玩了,我节后给你。

openclash要是能不停止就好了,不知道有什么办法能让这个测速脚本不走openclash

那估计是openclash的bug了,只能等作者慢慢修复了,笑哭~

别用这个了,直接上歇斯底里协议,udp速度很快

@hoockoo
Copy link

hoockoo commented Sep 22, 2022

SSR怎么写?

SSRP+还没用过,没有写呢,目前只写了passwall、passwall2、openclash的脚本。

请问openclash如何用?

中秋假期出去玩了,我节后给你。

openclash要是能不停止就好了,不知道有什么办法能让这个测速脚本不走openclash

那估计是openclash的bug了,只能等作者慢慢修复了,笑哭~

别用这个了,直接上歇斯底里协议,udp速度很快

我今年年初才从ssr换到xray,暂时不打算换了。而且hysteria不支持CDN,IP有概率被ban掉,换IP也麻烦。

@Eugenejiang
Copy link

有需要,我可以提供远程协助帮忙解决一些问题,虽然我对 openwrt 不熟,但是对 Linux、Shell 脚本什么的比较熟。

顺便可以帮你完善一下脚本,这样这个 Issues 也能帮到后来者~

远程协助软件(这个是只有被控功能的单文件版),告诉我你的设备代码、临时密码(我看到后会删除)。 https://dl.todesk.com/windows/ToDesk_Lite.exe

我想加你的微信让你协助一下,不知道怎么加。我不懂操作,现在IP每天手动扫描添加真的是太麻烦。

@Eugenejiang
Copy link

如果你完全没有 Shell 基础的话,那就别折腾了,我直接远程协助帮你写脚本 + 配置好,节省双方时间(相比直接教你而言)。

远程也可以,不知道你什么时候有时间?

@Eugenejiang
Copy link

#!/bin/bash

[[ ! -d "/paniy/cloudflare" ]] && mkdir -p /paniy/cloudflare
cd /paniy/cloudflare

opkg install jq

arch=$(uname -m)
if [[ ${arch} =~ "x86" ]]; then
tag="amd"
[[ ${arch} =~ "64" ]] && tag="amd64"
elif [[ ${arch} =~ "aarch" ]]; then
tag="arm"
[[ ${arch} =~ "64" ]] && tag="arm64"
else
exit 1
fi

version=$(curl -s https://api.github.com/repos/XIU2/CloudflareSpeedTest/tags | jq -r .[].name | head -1)
old_version=$(cat CloudflareST_version.txt )

if [[ ! -f "CloudflareST" || ${version} != ${old_version} ]]; then
rm -rf CloudflareST_linux_${tag}.tar.gz
wget -N https://github.com/XIU2/CloudflareSpeedTest/releases/download/${version}/CloudflareST_linux_${tag}.tar.gz
echo "${version}" > CloudflareST_version.txt
tar -xvf CloudflareST_linux_${tag}.tar.gz
chmod +x CloudflareST
fi

##注意修改!!!
/etc/init.d/haproxy stop
/etc/init.d/passwall stop
wait

./CloudflareST -dn 10 -tll 40 -o cf_result.txt
wait
sleep 3

if [[ -f "cf_result.txt" ]]; then
first=$(sed -n '2p' cf_result.txt | awk -F ',' '{print $1}') && echo $first >>ip-all.txt
second=$(sed -n '3p' cf_result.txt | awk -F ',' '{print $1}') && echo $second >>ip-all.txt
third=$(sed -n '4p' cf_result.txt | awk -F ',' '{print $1}') && echo $third >>ip-all.txt
wait
uci commit passwall
wait
##注意修改!!!
sed -i "s/$(uci get passwall.xxxxxxxxxx.address)/${first}/g" /etc/config/passwall
sed -i "s/$(uci get passwall.xxxxxxxxxx.address)/${second}/g" /etc/config/passwall
sed -i "s/$(uci get passwall.xxxxxxxxxx.address)/${third}/g" /etc/config/passwall
wait
uci commit passwall
wait
[[ $(/etc/init.d/haproxy status) != "running" ]] && /etc/init.d/haproxy start
wait
[[ $(/etc/init.d/passwall status) != "running" ]] && /etc/init.d/passwall start
# wait
# if [[ -f "ip-all.txt" ]]; then
# sort -t "." -k4 -n -r ip-all.txt >ip-all-serialize.txt
# uniq -c ip-all.txt ip-mediate.txt
# sort -r ip-mediate.txt >ip-statistics.txt
# rm -rf ip-mediate.txt
# fi
fi

@Eugenejiang
Copy link

CloudflareST这两天测速都是0,但脚本照样替换了PASSWALL的IP,大神有没有解决方法?

@Eugenejiang
Copy link

运行完之后出现:Command failed: Not found
#!/bin/bash
sleep 8s

/etc/init.d/haproxy stop
/etc/init.d/passwall stop

进入 CloudflareST 目录

cd /root/CloudflareST

运行 CloudflareST 测速(脚本示例中的 CloudflareST 位于 /root/CloudflareST 目录下)

./CloudflareST -tll 90

获取最快 IP

IP=$(sed -n "2,1p" result.csv | awk -F, '{print $1}')

判断一下是否成功获取到了最快 IP(如果没有就退出脚本):

[[ -z "${IP}" ]] && echo "CloudflareST 测速结果 IP 数量为 0,跳过下面步骤..." && exit 0

修改 passwall 里对应节点的 IP(XXX 就是节点 ID)

uci set passwall.xxxxxxx.address="${IP}"
uci commit passwall
/etc/init.d/haproxy restart
/etc/init.d/passwall restart
exit

@sxml
Copy link

sxml commented Nov 23, 2022

最后重启代码 /etc/init.d/passwall restart
最近openwrt 发现无法重启 以前正常
不知道怎么修改

@sxml
Copy link

sxml commented Nov 23, 2022

大佬这 两个SED命令 是代表什么意思能不能说下 谢谢!
sed -n "2,1p" awk -F, '{print $1}
2,1p 和 print $1 ??

@likefu40
Copy link
Author

建议大家不必用每天跑测速了,目前本人已使用openclash,meta内核可以使用grpc协议,可以找出大概尽可能快的cf-ip,让clash自动检测IP延迟来切换节点!

@XIU2 XIU2 unpinned this issue Nov 27, 2022
Repository owner locked and limited conversation to collaborators Mar 1, 2023
@XIU2 XIU2 converted this issue into discussion #316 Mar 1, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
工具教程 辅助工具 或 技巧教程
Projects
None yet
Development

No branches or pull requests

15 participants