1 Star 0 Fork 0

junior/cf-warp-yx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
warp-yx.sh 6.32 KB
一键复制 编辑 原始数据 按行查看 历史
junior 提交于 2023-10-09 14:17 . yx
#!/bin/bash
RED="\033[31m"
GREEN="\033[32m"
YELLOW="\033[33m"
PLAIN='\033[0m'
red() {
echo -e "\033[31m\033[01m$1\033[0m"
}
green() {
echo -e "\033[32m\033[01m$1\033[0m"
}
yellow() {
echo -e "\033[33m\033[01m$1\033[0m"
}
# 选择客户端 CPU 架构
archAffix(){
case "$(uname -m)" in
i386 | i686 ) echo '386' ;;
x86_64 | amd64 ) echo 'amd64' ;;
armv8 | arm64 | aarch64 ) echo 'arm64' ;;
s390x ) echo 's390x' ;;
* ) red "不支持的CPU架构!" && exit 1 ;;
esac
}
endpointyx(){
warp_bin="warp-linux-$(archAffix)"
if [ ! -f "$warp_bin" ]
then
wget "https://gitee.com/ijuniorfu/cf-warp-yx/raw/master/$warp_bin" -O $warp_bin
fi
# 取消 Linux 自带的线程限制,以便生成优选 Endpoint IP
ulimit -n 102400
# 启动 WARP Endpoint IP 优选工具
chmod +x $warp_bin && ./$warp_bin >/dev/null 2>&1
# 显示前十个优选 Endpoint IP 及使用方法
green "当前最优 Endpoint IP 结果如下,并已保存至 result.csv中:"
cat result.csv | awk -F, '$3!="timeout ms" {print} ' | sort -t, -nk2 -nk3 | uniq | head -11 | awk -F, '{print "端点 "$1" 丢包率 "$2" 平均延迟 "$3}'
echo ""
yellow "使用方法如下:"
yellow "1. 将 WireGuard 节点的默认的 Endpoint IP:engage.cloudflareclient.com:2408 替换成本地网络最优的 Endpoint IP"
endpoint=$(cat result.csv | grep ms | head -1 | awk -F, '{print $1}')
yellow "Endpoint IP: $endpoint"
rm -f ip.txt
}
endpoint4(){
# 生成优选 WARP IPv4 Endpoint IP 段列表
n=0
iplist=100
while true; do
temp[$n]=$(echo 162.159.192.$(($RANDOM % 256)))
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
temp[$n]=$(echo 162.159.193.$(($RANDOM % 256)))
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
temp[$n]=$(echo 162.159.195.$(($RANDOM % 256)))
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
temp[$n]=$(echo 162.159.204.$(($RANDOM % 256)))
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
temp[$n]=$(echo 188.114.96.$(($RANDOM % 256)))
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
temp[$n]=$(echo 188.114.97.$(($RANDOM % 256)))
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
temp[$n]=$(echo 188.114.98.$(($RANDOM % 256)))
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
temp[$n]=$(echo 188.114.99.$(($RANDOM % 256)))
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
done
while true; do
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo 162.159.192.$(($RANDOM % 256)))
n=$(($n + 1))
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo 162.159.193.$(($RANDOM % 256)))
n=$(($n + 1))
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo 162.159.195.$(($RANDOM % 256)))
n=$(($n + 1))
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo 162.159.204.$(($RANDOM % 256)))
n=$(($n + 1))
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo 188.114.96.$(($RANDOM % 256)))
n=$(($n + 1))
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo 188.114.97.$(($RANDOM % 256)))
n=$(($n + 1))
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo 188.114.98.$(($RANDOM % 256)))
n=$(($n + 1))
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo 188.114.99.$(($RANDOM % 256)))
n=$(($n + 1))
fi
done
# 将生成的 IP 段列表放到 ip.txt 里,待程序优选
echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u > ip.txt
# 启动优选程序
endpointyx
}
endpoint6(){
# 生成优选 WARP IPv6 Endpoint IP 段列表
n=0
iplist=100
while true; do
temp[$n]=$(echo [2606:4700:d0::$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2)))])
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
temp[$n]=$(echo [2606:4700:d1::$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2)))])
n=$(($n + 1))
if [ $n -ge $iplist ]; then
break
fi
done
while true; do
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo [2606:4700:d0::$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2)))])
n=$(($n + 1))
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]; then
break
else
temp[$n]=$(echo [2606:4700:d1::$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2))):$(printf '%x\n' $(($RANDOM * 2 + $RANDOM % 2)))])
n=$(($n + 1))
fi
done
# 将生成的 IP 段列表放到 ip.txt 里,待程序优选
echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u > ip.txt
# 启动优选程序
endpointyx
}
endpoint4
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ijuniorfu/cf-warp-yx.git
git@gitee.com:ijuniorfu/cf-warp-yx.git
ijuniorfu
cf-warp-yx
cf-warp-yx
master

搜索帮助