代码拉取完成,页面将自动刷新
#!/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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。