v3.1.1 Get 1.9 EB plus license from self-built WARP API.

This commit is contained in:
fs carmen
2024-07-25 07:22:41 +00:00
parent c92d6404e6
commit 06a6877d4f
4 changed files with 257 additions and 128 deletions
+9 -5
View File
@@ -20,16 +20,18 @@
* * *
## 更新信息
2024.7.25 menu.sh 3.1.1 / warp-go.sh v1.2.1 1. Support using the self-built WARP API at https://warp.cloudflare.now.cc/?run=pluskey to generate a 1920 PB WARP+ license for upgrading to a Plus account; 2. Client lacks sufficient support for WARP+, only able to use IPv4 and not IPv6; 3. Optimize the installer to further reduce script runtime; 1. 支持使用自建 warp api: https://warp.cloudflare.now.cc/?run=pluskey 生成 1920 PB WARP+ license 升级为 Plus 账户; 2. Client 对 WARP+ 支持不够,只能使用 IPv4,不能使用 IPv6; 3. 优化安装程序,进一步缩短脚本运行时间
2024.7.18 menu.sh 3.1.0 / warp-go.sh v1.2.0 1. Use self-built warp api: https://warp.cloudflare.now.cc/ to upgrade to Teams account, no need to prepare Token in advance, only need to enter organization, email and verification code when the script is running to complete, the efficiency is greatly increased; 2. Because the Client's settings need to be set up in the Cloudflare dashboard, which can cause the vps to lose contact if not handled properly, the Client's is not upgraded to a Teams account, and the user can look up the information to set it up on their own; 1. 使用自建 warp api: https://warp.cloudflare.now.cc/ ,升级为 Teams 账户,不需要提前获取 Token,只须在脚本运行的时候输入组织名、邮箱和验证码即可完成,效率大增; 2. 由于 Client 的设置需要到 Cloudflare 控制后台设置,处理不好会导致 vps 失去联系,所以 Client 并没有升级为 Teams 账户的处理,用户可自行查资料设置
2024.7.8 menu.sh v3.0.10 / warp-go.sh v1.1.9 1. Publish warp api, you can register account, join Zero Trust, check account information and all other operations. Detailed instructions: https://warp.cloudflare.now.cc/ ; 2. Scripts to update the warp api; 1. 发布 warp api,可以注册账户,加入 Zero Trust,查账户信息等所有的操作。详细使用说明: https://warp.cloudflare.now.cc/; 2. 脚本更新 warp api
2024.6.30 menu.sh v3.0.9 1. By multithreading, parallel processing of optimal MTU, optimal endpoint, downloading wireguard-go and installing dependencies, the script runtime is reduced by more than half; 2. Reverse proxy http://ip-api.com/json and https://hits.seeyoufarm.com with cloudflare worker for better dual-stack support and faster fetching; 3. DNS Priority: Cloudflare 1.1.1.1 > Google 8.8.8.8; 1. 通过多线程,并行处理最优 MTU,最优 endpoint,下载 wireguard-go 和安装依赖, 脚本运行时间缩短一半以上; 2. 用 Cloudflare worker 反向代理 http://ip-api.com/json 和 https://hits.seeyoufarm.com,以更好支持双栈及提升获取速度; 3. DNS 优先级: Cloudflare 1.1.1.1 > Google 8.8.8.8
<details>
<summary>历史更新 history(点击即可展开或收起)</summary>
<br>
>2024.7.8 menu.sh v3.0.10 / warp-go.sh v1.1.9 1. Publish warp api, you can register account, join Zero Trust, check account information and all other operations. Detailed instructions: https://warp.cloudflare.now.cc/ ; 2. Scripts to update the warp api; 1. 发布 warp api,可以注册账户,加入 Zero Trust,查账户信息等所有的操作。详细使用说明: https://warp.cloudflare.now.cc/; 2. 脚本更新 warp api
>
>2024.6.30 menu.sh v3.0.9 1. By multithreading, parallel processing of optimal MTU, optimal endpoint, downloading wireguard-go and installing dependencies, the script runtime is reduced by more than half; 2. Reverse proxy http://ip-api.com/json and https://hits.seeyoufarm.com with cloudflare worker for better dual-stack support and faster fetching; 3. DNS Priority: Cloudflare 1.1.1.1 > Google 8.8.8.8; 1. 通过多线程,并行处理最优 MTU,最优 endpoint,下载 wireguard-go 和安装依赖, 脚本运行时间缩短一半以上; 2. 用 Cloudflare worker 反向代理 http://ip-api.com/json 和 https://hits.seeyoufarm.com,以更好支持双栈及提升获取速度; 3. DNS 优先级: Cloudflare 1.1.1.1 > Google 8.8.8.8
>
>2024.6.28 menu.sh v3.0.8 The official WARP Linux Client supports arm64 systems and is available in both socks5 proxy and Warp interface modes; 官方 WARP Linux Client 支持 arm64 系统, Socks5 proxy 模式 和 Warp interface 模式均可用
>
>2024.6.2 menu.sh v3.0.7 Support CentOS 9 / Alma Linux 9 / Rocky Linux 9 system; 支持 CentOS 9 / Alma Linux 9 / Rocky Linux 9 系统
@@ -339,8 +341,9 @@ warp-go [option] [lisence]
| `unbind` | 从帐户中取消绑定设备 | `device_id`, `token` | `https://warp.cloudflare.now.cc/?run=unbind&device_id=<Your-Device-ID>&token=<Your-Token>` |
| `cancel` | 取消设备注册 | `device_id`, `token` | `https://warp.cloudflare.now.cc/?run=cancel&device_id=<Your-Device-ID>&token=<Your-Token>` |
| `id` | Client ID 与 Reserved 转换 | `convert` | `https://warp.cloudflare.now.cc/?run=id&convert=<4-char-string\|Numbers1,Numbers2,Numbers3>` |
| `key` | 生成一对 WireGuard 公私钥 | `format(可选)` | `https://warp.cloudflare.now.cc/?run=key&format=<json\|yaml>` |
| `token` | 获取 Zero Trust token | `organization`, `email`, `code` | step1: `https://warp.cloudflare.now.cc/?organization=<Your-Organization>&email=<Your-Email>` </br> step2: `https://warp.cloudflare.now.cc/?organization=<Your-Organization>&A=<A-Value>&S=<S-Value>&N=<N-Value>&code=<Your-Code>` |
| `pluskey` | 生成指定数量的 1923PB Warp+ license | `num(可选,默认:1,最大:6`, `maxretry(可选,默认:3` | `https://warp.cloudflare.now.cc/?run=pluskey&num=2&maxretry=5` |
| `key` | 生成一对 WireGuard 公私钥 | `format(可选)` | `https://warp.cloudflare.now.cc/?run=key&format=<json\|yaml>` |
| `sum` | 获取总计和 24 小时运行计数 | | `https://warp.cloudflare.now.cc/?run=sum` |
### Shell-API 运行脚本
@@ -651,6 +654,7 @@ https://github.com/acacia233/Project-WARP-Unlock
* valetzx: https://gitlab.com/valetzx/pubfile
* badafans cf api: https://github.com/badafans/warp-reg
* chika0801: https://github.com/chika0801/Xray-examples/
* xXcmd1152Xx: https://github.com/cmd1152/WarpPlusKeyGenerator-NG-lib
* 所有的热心网友们
服务提供(排名不分先后):
+3 -2
View File
@@ -192,14 +192,15 @@ cancle_account() {
[[ -z "$id" && -z "$token" ]] && fetch_account_information
local result=$(curl --request DELETE "https://api.cloudflareclient.com/v0a2158/reg/${id}" \
--head \
--silent \
--location \
--header 'User-Agent: okhttp/3.12.1' \
--header 'CF-Client-Version: a-6.10-2158' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${token}")
--header "Authorization: Bearer ${token}" | awk '/HTTP/{print $(NF-1)}')
[ -z "$result" ] && echo " Success. The account has been cancelled. " || echo " Failure. The account is not available. "
grep -qw '204' <<< "$result" && echo " Success. The account has been cancelled. " || echo " Failure. The account is not available. "
}
# reserved 解码
+80 -40
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# 当前脚本版本号
VERSION='3.1.0'
VERSION='3.1.1'
# 环境变量用于在Debian或Ubuntu操作系统中设置非交互式(noninteractive)安装模式
export DEBIAN_FRONTEND=noninteractive
@@ -9,12 +9,12 @@ export DEBIAN_FRONTEND=noninteractive
# Github 反代加速代理
GH_PROXY='https://ghproxy.lvedong.eu.org/'
trap "rm -f /tmp/{wireguard-go-*,best_mtu,best_endpoint,endpoint,ip}; exit" INT
trap "rm -f /tmp/{wireguard-go-*,best_mtu,best_endpoint,endpoint,ip,license-tmp}; exit" INT
E[0]="\n Language:\n 1. English (default) \n 2. 简体中文"
C[0]="${E[0]}"
E[1]="1. Use self-built warp api: https://warp.cloudflare.now.cc/ to upgrade to Teams account, no need to prepare Token in advance, only need to enter organization, email and verification code when the script is running to complete, the efficiency is greatly increased; 2. Because the Client's settings need to be set up in the Cloudflare dashboard, which can cause the vps to lose contact if not handled properly, the Client's is not upgraded to a Teams account, and the user can look up the information to set it up on their own. Website to get a Zero Trust token: https://token.cloudflare.now.cc/"
C[1]="1. 使用自建 warp api: https://warp.cloudflare.now.cc/ ,升级为 Teams 账户,不需要提前获取 Token,只须在脚本运行的时候输入组织名、邮箱和验证码即可完成,效率大增; 2. 由于 Client 的设置需要到 Cloudflare 控制后台设置,处理不好会导致 vps 失去联系,所以 Client 并没有升级为 Teams 账户的处理,用户可自行查资料设置。获取 Zero Trust token 的网站: https://token.cloudflare.now.cc/"
E[1]="1. Support using the self-built WARP API at https://warp.cloudflare.now.cc/?run=pluskey to generate a 1920 PB WARP+ license for upgrading to a Plus account; 2. Client lacks sufficient support for WARP+, only able to use IPv4 and not IPv6; 3. Optimize the installer to further reduce script runtime."
C[1]="1. 支持使用自建 warp api: https://warp.cloudflare.now.cc/?run=pluskey 生成 1920 PB WARP+ license 升级为 Plus 账户; 2. Client 对 WARP+ 支持不够,只能使用 IPv4,不能使用 IPv6; 3. 优化安装程序,缩短脚本运行时间"
E[2]="The script must be run as root, you can enter sudo -i and then download and run again. Feedback: [https://github.com/fscarmen/warp-sh/issues]"
C[2]="必须以root方式运行脚本,可以输入 sudo -i 后重新下载运行,问题反馈:[https://github.com/fscarmen/warp-sh/issues]"
E[3]="The TUN module is not loaded. You should turn it on in the control panel. Ask the supplier for more help. Feedback: [https://github.com/fscarmen/warp-sh/issues]"
@@ -67,12 +67,12 @@ E[26]="Curren operating system is \$SYS.\\\n The system lower than \$SYSTEM \${M
C[26]="当前操作是 \$SYS\\\n 不支持 \$SYSTEM \${MAJOR[int]} 以下系统,问题反馈:[https://github.com/fscarmen/warp-sh/issues]"
E[27]="Local Socks5"
C[27]="本地 Socks5"
E[28]="If there is a WARP+ License, please enter it, otherwise press Enter to continue:"
C[28]="如有 WARP+ License 请输入,没有可回车继续:"
E[28]="If you have a WARP+ License, please input it. Otherwise, press Enter to use the key generated by the plusKey API:"
C[28]="如果您有 WARP+ License请输入;否则,请按 Enter 键使用由 plusKey API 生成的 license"
E[29]="Input errors up to 5 times.The script is aborted."
C[29]="输入错误达5次,脚本退出"
E[30]="License should be 26 characters, please re-enter WARP+ License. Otherwise press Enter to continue. \(\${i} times remaining\):"
C[30]="License 应为26位字符,请重新输入 WARP+ License没有可回车继续\(剩余\${i}次\):"
E[30]="License should be 26 characters, please re-input WARP+ License. Otherwise, press Enter to use the key generated by the plusKey API. \(\${i} times remaining\):"
C[30]="License 应为26位字符,请重新输入 WARP+ License回车则使用 plusKey api 生成 的 key \(剩余\${i}次\):"
E[31]="The new \$KEY_LICENSE is the same as the one currently in use. Does not need to be replaced."
C[31]="新输入的 \$KEY_LICENSE 与现使用中的一样,不需要更换。"
E[32]="Step 1/3: Install dependencies..."
@@ -133,8 +133,8 @@ E[59]="Cannot find the account file: /etc/wireguard/warp-account.conf, you can r
C[59]="找不到账户文件:/etc/wireguard/warp-account.conf,可以卸载后重装,输入 WARP+ License"
E[60]="Cannot find the configuration file: /etc/wireguard/warp.conf, you can reinstall with the WARP+ License"
C[60]="找不到配置文件: /etc/wireguard/warp.conf,可以卸载后重装,输入 WARP+ License"
E[61]="Please Input WARP+ license:"
C[61]="请输入WARP+ License:"
E[61]="Please Input WARP+ license. Enter to use the key generated by the plusKey api:"
C[61]="请输入WARP+ License,回车则使用 plusKey api 生成 的 key:"
E[62]="Successfully change to a WARP\$TYPE account"
C[62]="已变更为 WARP\$TYPE 账户"
E[63]="WARP+ quota"
@@ -211,12 +211,12 @@ E[98]="Uninstall Wireproxy was complete."
C[98]="Wireproxy 卸载成功"
E[99]="WireProxy is connected"
C[99]="WireProxy 已连接"
E[100]="License should be 26 characters, please re-enter WARP+ License. Otherwise press Enter to continue. \(\${i} times remaining\): "
C[100]="License 应为26位字符,请重新输入 WARP+ License \(剩余\${i}次\): "
E[100]="Generating Plus License..."
C[100]="正在生成 Plus License...."
E[101]="Client support amd64 and arm64 only. Curren architecture \$ARCHITECTURE. Official Support List: [https://pkg.cloudflareclient.com/packages/cloudflare-warp]. The script is aborted. Feedback: [https://github.com/fscarmen/warp-sh/issues]"
C[101]="Client 只支持 amd64 和 arm64 架构,当前架构 \$ARCHITECTURE,官方支持列表: [https://pkg.cloudflareclient.com/packages/cloudflare-warp]。脚本中止,问题反馈:[https://github.com/fscarmen/warp-sh/issues]"
E[102]="Please customize the WARP+ device name \(Default is \$(hostname)\):"
C[102]="请自定义 WARP+ 设备名 \(默认为 \$(hostname)\):"
E[102]="License: \$LICENSE\\\n Please customize the WARP+ device name \(Default is \$(hostname)\):"
C[102]="License: \$LICENSE\\\n 请自定义 WARP+ 设备名 \(默认为 \$(hostname)\):"
E[103]="Port \$PORT is in use. Please input another Port\(\${i} times remaining\):"
C[103]="\$PORT 端口占用中,请使用另一端口\(剩余\${i}次\):"
E[104]="Please customize the Client port (1000-65535. Default to 40000 if it is blank):"
@@ -267,8 +267,8 @@ E[126]="\$(date +'%F %T') Try \${i}. Failed. IPv\$NF: \$WAN \$COUNTRY \$ASNORG
C[126]="\$(date +'%F %T') 尝试第\${i}次,解锁失败,IPv\$NF: \$WAN \$COUNTRY \$ASNORG\${j}秒后重新测试,刷 IP 运行时长: \$DAY 天 \$HOUR 时 \$MIN 分 \$SEC 秒"
E[127]="1. with URL file\n 2. input the organization and email verification code\n 3. manual input private key, IPv6 and Client id\n 4. share teams account (default)"
C[127]="1. 通过在线文件\n 2. 输入组织名和邮箱验证码获取\n 3. 手动输入 private key IPv6 和 Client id\n 4. 共享 teams 账户 (默认)"
E[128]="Organization does not exist, please re-enter:"
C[128]="组织名不存在,请重新输入:"
E[128]="Is there a WARP+ account?\n 1. Use free account (default)\n 2. WARP+"
C[128]="账户请选择:\n 1. 使用免费账户 (默认)\n 2. WARP+"
E[129]="The current Teams account is unavailable, automatically switch back to the free account"
C[129]="当前 Teams 账户不可用,自动切换回免费账户"
E[130]="Please confirm\\\n Private key\\\t: \$PRIVATEKEY \${MATCH[0]}\\\n Address IPv6\\\t: \$ADDRESS6/128 \${MATCH[1]}\\\n Client id\\\t: \$CLIENT_ID \${MATCH[2]}"
@@ -276,7 +276,7 @@ C[130]="请确认Teams 信息\\\n Private key\\\t: \$PRIVATEKEY \${MATCH[0]}\\\n
E[131]="comfirm please enter [y] , and other keys to use free account:"
C[131]="确认请按 [y],其他按键则使用免费账户:"
E[132]="Is there a WARP+ or Teams account?\n 1. Use free account (default)\n 2. WARP+\n 3. Teams"
C[132]="如有 WARP+ 或 Teams 账户请选择\n 1. 使用免费账户 (默认)\n 2. WARP+\n 3. Teams"
C[132]="如有 WARP+ 或 Teams 账户请选择:\n 1. 使用免费账户 (默认)\n 2. WARP+\n 3. Teams"
E[133]="Device name: \$(grep -s 'Device name' /etc/wireguard/info.log | awk '{ print \$NF }')\\\n Quota: \$QUOTA"
C[133]="设备名: \$(grep -s 'Device name' /etc/wireguard/info.log | awk '{ print \$NF }')\\\n 剩余流量: \$QUOTA"
E[134]="Curren architecture \$(uname -m) is not supported. Feedback: [https://github.com/fscarmen/warp-sh/issues]"
@@ -401,6 +401,10 @@ E[193]="E-mail address to receive the verification code:"
C[193]="接收验证码的邮箱:"
E[194]="Verification code:"
C[194]="验证码:"
E[195]="Organization does not exist, please re-enter:"
C[195]="组织名不存在,请重新输入:"
E[196]="// Official Client bug: If using a WARP+ license, IPv6 cannot be used. For more details, see the community discussion: https://community.cloudflare.com/t/losing-ipv6-connectivity-with-warp/568971"
C[196]="// 官方 Client bug,如使用 WARP+ license,不能使用 IPv6,详见社区:https://community.cloudflare.com/t/losing-ipv6-connectivity-with-warp/568971"
# 自定义字体彩色,read 函数
warning() { echo -e "\033[31m\033[01m$*\033[0m"; } # 红色
@@ -563,13 +567,13 @@ warp_api(){
# wgcf 文件,默认存放路径为 /etc/wireguard/wgcf-account.toml
elif grep -q 'access_token' $FILE_PATH; then
id=$(grep 'device_id' "$FILE_PATH" | cut -d\' -f2)
token=$(grep 'access_token' "$FILE_PATH" | cut -d\' -f2)
local WARP_DEVICE_ID=$(grep 'device_id' "$FILE_PATH" | cut -d\' -f2)
local WARP_TOKEN=$(grep 'access_token' "$FILE_PATH" | cut -d\' -f2)
# warp-go 文件,默认存放路径为 /opt/warp-go/warp.conf
elif grep -q 'PrivateKey' $FILE_PATH; then
id=$(awk -F' *= *' '/^Device/{print $2}' "$FILE_PATH")
token=$(awk -F' *= *' '/^Token/{print $2}' "$FILE_PATH")
local WARP_DEVICE_ID=$(awk -F' *= *' '/^Device/{print $2}' "$FILE_PATH")
local WARP_TOKEN=$(awk -F' *= *' '/^Token/{print $2}' "$FILE_PATH")
fi
fi
@@ -615,9 +619,18 @@ warp_api(){
curl -m5 -sL "https://${WARP_API_URL}/?run=token&organization=${TEAM_ORGANIZATION}&A=${A}&S=${S}&N=${N}&code=${TEAM_CODE}"
;;
pluskey )
curl -m30 -sL "https://${WARP_API_URL}/?run=pluskey"
;;
esac
}
# 通过 warp api 生成 plusKey
generate_pluskey() {
local FILE_PATH="$1"
[ -n "$FILE_PATH" ] && warp_api pluskey | awk -F '"' '/licenseCode/{print $4}' > $FILE_PATH || warp_api pluskey | awk -F '"' '/licenseCode/{print $4}'
}
# 聚合 IP api 函数
ip_info() {
local CHECK_46="$1"
@@ -1227,7 +1240,7 @@ uninstall() {
# 删除本脚本安装在 /etc/wireguard/ 下的所有文件,如果删除后目录为空,一并把目录删除
rm -f /usr/bin/wg-quick.{origin,reserved}
rm -f /tmp/{best_mtu,/tmp/best_endpoint,wireguard-go-*}
rm -f /tmp/{best_mtu,best_endpoint,wireguard-go-*,license-tmp}
rm -f /etc/wireguard/{wgcf-account.conf,warp-temp.conf,warp-account.conf,warp_unlock.sh,warp.conf.bak,warp.conf,up,proxy.conf.bak,proxy.conf,menu.sh,license,language,info-temp.log,info.log,down,account-temp.conf,NonGlobalUp.sh,NonGlobalDown.sh}
[[ -e /etc/wireguard && -z "$(ls -A /etc/wireguard/)" ]] && rmdir /etc/wireguard
@@ -1653,13 +1666,24 @@ rule_del() {
# 输入 WARP+ 账户(如有),限制位数为空或者26位以防输入错误
input_license() {
local WARP_OR_CLIENT="$1"
[ -z "$LICENSE" ] && reading " $(text 28) " LICENSE
if [ -z "$LICENSE" ]; then
hint " $(text 100) "
wait
[ -s /tmp/license-tmp ] && LICENSE=$(cat /tmp/license-tmp) && rm -f /tmp/license-tmp
fi
i=5
until [[ -z "$LICENSE" || "$LICENSE" =~ ^[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}$ ]]; do
until [[ "$LICENSE" =~ ^[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}$ ]]; do
(( i-- )) || true
[ "$i" = 0 ] && error " $(text 29) " || reading " $(text 30) " LICENSE
if [ -z "$LICENSE" ]; then
hint " $(text 100) "
wait
[ -s /tmp/license-tmp ] && LICENSE=$(cat /tmp/license-tmp) && rm -f /tmp/license-tmp
fi
done
if [ "$INPUT_LICENSE" = 1 ]; then
if [ "$WARP_OR_CLIENT" = is_warp ]; then
[[ -n "$LICENSE" && -z "$NAME" ]] && reading " $(text 102) " NAME
[ -n "$NAME" ] && NAME="${NAME//[[:space:]]/_}" || NAME=${NAME:-"$(hostname)"}
fi
@@ -1691,7 +1715,7 @@ input_url_token() {
if [[ "$ERROR_TIMES" > 5 ]]; then
error "\n $(text 29) \n"
else
[ "$ERROR_TIMES" = 1 ] && reading "\n $(text 192) " TEAM_ORGANIZATION || reading "\n $(text 128) " TEAM_ORGANIZATION
[ "$ERROR_TIMES" = 1 ] && reading "\n $(text 192) " TEAM_ORGANIZATION || reading "\n $(text 195) " TEAM_ORGANIZATION
[[ -n "$TEAM_ORGANIZATION" && -z "$TEAM_EMAIL" ]] && reading " $(text 193) " TEAM_EMAIL
[ -n "$TEAM_EMAIL" ] && local TEAM_AUTH=$(warp_api "token-step1" "" "" "" "" "" "" "" "$TEAM_ORGANIZATION" "$TEAM_EMAIL")
fi
@@ -1748,10 +1772,16 @@ input_url_token() {
# 升级 WARP+ 账户(如有),限制位数为空或者26位以防输入错误,WARP interface 可以自定义设备名(不允许字符串间有空格,如遇到将会以_代替)
update_license() {
[ -z "$LICENSE" ] && reading " $(text 61) " LICENSE
hint " $(text 100) "
wait
[ -z "$LICENSE" ] && [ -s /tmp/license-tmp ] && LICENSE=$(cat /tmp/license-tmp) && rm -f /tmp/license-tmp
i=5
until [[ "$LICENSE" =~ ^[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}$ ]]; do
(( i-- )) || true
[ "$i" = 0 ] && error " $(text 29) " || reading " $(text 100) " LICENSE
[ "$i" = 0 ] && error " $(text 29) " || reading " $(text 30) " LICENSE
hint " $(text 100) "
wait
[ -z "$LICENSE" ] && [ -s /tmp/license-tmp ] && LICENSE=$(cat /tmp/license-tmp) && rm -f /tmp/license-tmp
done
[[ -z "$CLIENT_ACCOUNT" && "$CHOOSE_TYPE" = 2 && -n "$LICENSE" && -z "$NAME" ]] && reading " $(text 102) " NAME
[ -n "$NAME" ] && NAME="${NAME//[[:space:]]/_}" || NAME=${NAME:-"$(hostname)"}
@@ -1982,11 +2012,6 @@ best_endpoint() {
# WARP 或 WireProxy 安装
install() {
# 后台优选最佳 MTU
{ best_mtu; }&
# 后台优选优选 WARP Endpoint
{ best_endpoint; }&
# 后台下载 wireguard-go 两个版本
{ wget --no-check-certificate $STACK -qO /tmp/wireguard-go-20230223 https://gitlab.com/fscarmen/warp/-/raw/main/wireguard-go/wireguard-go-linux-$ARCHITECTURE-20230223 && chmod +x /tmp/wireguard-go-20230223; }&
@@ -2036,7 +2061,7 @@ install() {
[ -z "$CHOOSE_TYPE" ] && hint "\n $(text 132) \n" && reading " $(text 50) " CHOOSE_TYPE
case "$CHOOSE_TYPE" in
2 )
INPUT_LICENSE=1 && input_license
input_license is_warp
;;
3 )
[ -z "$CHOOSE_TEAMS" ] && hint "\n $(text 127) \n" && reading " $(text 50) " CHOOSE_TEAMS
@@ -2516,12 +2541,14 @@ client_install() {
[[ ! "$ARCHITECTURE" =~ ^(arm64|amd64)$ ]] && error " $(text 101) "
[[ ! "$SYSTEM" =~ Ubuntu|Debian|CentOS ]] && error " $(text 191) "
# 后台优选 WARP Endpoint
{ best_endpoint; }&
# CentOS 7 及以下的系统安装不了 Client
[[ "$SYSTEM" = 'CentOS' && "$(expr "$SYS" : '.*\s\([0-9]\{1,\}\)\.*')" -le 7 ]] && error " $(text 145) "
# 询问是否有 WARP+ 或 Teams 账户
[ -z "$CHOOSE_TYPE" ] && warning "\n $(text 196) " && hint "\n $(text 128) \n" && reading " $(text 50) " CHOOSE_TYPE
grep -qw '2' <<< "$CHOOSE_TYPE" && input_license is_client
# 安装 WARP Linux Client
[[ "$SYSTEM" = 'CentOS' && "$(expr "$SYS" : '.*\s\([0-9]\{1,\}\)\.*')" -le 7 ]] && error " $(text 145) "
input_license
[ "$IS_LUBAN" != 'is_luban' ] && input_port
start=$(date +%s)
mkdir -p /etc/wireguard/ >/dev/null 2>&1
@@ -2804,7 +2831,7 @@ change_to_plus() {
# 流程4:如成功则删除原账户信息文件,保存 license 并显示结果; 如失败则看原账户有没有 License 用于还原
if [ "$LICENSE_STATUS" = Success ]; then
backup_restore_delete del
backup_restore_delete delete
echo "$LICENSE" > /etc/wireguard/license
else
case "$LICENSE_STATUS" in
@@ -3040,7 +3067,7 @@ update() {
client_account() {
UPDATE_ACCOUNT=client
[ "$ARCHITECTURE" = arm64 ] && error " $(text 101) "
[[ ! "$ARCHITECTURE" =~ ^(arm64|amd64)$ ]] && error " $(text 101) "
[ -n "$URL" ] && unset CHOOSE_TYPE && warning "\n $(text 9) "
CHANGE_DO[0]() { menu; }
@@ -3053,7 +3080,7 @@ update() {
[ "$CLIENT_ACCOUNT" = Limited ] && ACCOUNT_TYPE='+' && CHANGE_TYPE=$(text 178) && check_quota client && PLUS_QUOTA="$(text 63): $QUOTA"
if [ -z "$CHOOSE_TYPE" ]; then
hint "\n $(text 173) "
warning "\n $(text 196) " && hint " $(text 173) "
[ "$OPTION" != a ] && hint " 0. $(text 49) \n" || hint " 0. $(text 76) \n"
reading " $(text 50) " CHOOSE_TYPE
fi
@@ -3167,7 +3194,7 @@ menu_setting() {
# 显示菜单
menu() {
clear
hint " $(text 16) "
# hint " $(text 16) "
echo -e "======================================================================================================================\n"
info " $(text 17):$VERSION\n $(text 18):$(text 1)\n $(text 19):\n\t $(text 20):$SYS\n\t $(text 21):$(uname -r)\n\t $(text 22):$ARCHITECTURE\n\t $(text 23):$VIRT "
info "\t IPv4: $WAN4 $COUNTRY4 $ASNORG4 "
@@ -3236,7 +3263,11 @@ fi
# 自定义 WARP+ 设备名
NAME=$3
# 后台生成 plus key
{ generate_pluskey /tmp/license-tmp; }&
# 主程序运行 1/3
check_cdn
statistics_of_run-times
select_language
@@ -3288,6 +3319,15 @@ esac
check_dependencies
check_virt $SYSTEM
check_system_info
# 提前准备最佳 MTU 和优选 Endpoint
if [[ ${CLIENT} = 0 && ${WIREPROXY} = 0 && ! -s /etc/wireguard/warp.conf ]]; then
# 后台优选最佳 MTU
{ best_mtu; }&
# 后台优选优选 WARP Endpoint
{ best_endpoint; }&
fi
menu_setting
# 设置部分后缀 3/3
+165 -81
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# 当前脚本版本号和新增功能
VERSION='1.2.0'
VERSION='1.2.1'
# 判断 Teams token 最少字符数
TOKEN_LENGTH=800
@@ -16,8 +16,8 @@ trap "rm -f /tmp/warp-go*; exit" INT
E[0]="Language:\n 1.English (default) \n 2.简体中文"
C[0]="${E[0]}"
E[1]="1. Use self-built warp api: https://warp.cloudflare.now.cc/ to upgrade to Teams account, no need to prepare Token in advance, only need to enter organization, email and verification code when the script is running to complete, the efficiency is greatly increased; 2. Because the Client's settings need to be set up in the Cloudflare dashboard, which can cause the vps to lose contact if not handled properly, the Client's is not upgraded to a Teams account, and the user can look up the information to set it up on their own. Website to get a Zero Trust token: https://token.cloudflare.now.cc/"
C[1]="1. 使用自建 warp api: https://warp.cloudflare.now.cc/ ,升级为 Teams 账户,不需要提前获取 Token,只须在脚本运行的时候输入组织名、邮箱和验证码即可完成,效率大增; 2. 由于 Client 的设置需要到 Cloudflare 控制后台设置,处理不好会导致 vps 失去联系,所以 Client 并没有升级为 Teams 账户的处理,用户可自行查资料设置。获取 Zero Trust token 的网站: https://token.cloudflare.now.cc/"
E[1]="1. Support using the self-built WARP API at https://warp.cloudflare.now.cc/?run=pluskey to generate a 1920 PB WARP+ license for upgrading to a Plus account; 2. Client lacks sufficient support for WARP+, only able to use IPv4 and not IPv6; 3. Optimize the installer to further reduce script runtime."
C[1]="1. 支持使用自建 warp api: https://warp.cloudflare.now.cc/?run=pluskey 生成 1920 PB WARP+ license 升级为 Plus 账户; 2. Client 对 WARP+ 支持不够,只能使用 IPv4,不能使用 IPv6; 3. 优化安装程序,缩短脚本运行时间"
E[2]="warp-go h (help)\n warp-go o (temporary warp-go switch)\n warp-go u (uninstall WARP web interface and warp-go)\n warp-go v (sync script to latest version)\n warp-go i (replace IP with Netflix support)\n warp-go 4/6 ( WARP IPv4/IPv6 single-stack)\n warp-go d (WARP dual-stack)\n warp-go n (WARP IPv4 non-global)\n warp-go g (WARP global/non-global switching)\n warp-go e (output wireguard and sing-box configuration file)\n warp-go a (Change to Free, WARP+ or Teams account)"
C[2]="warp-go h (帮助)\n warp-go o (临时 warp-go 开关)\n warp-go u (卸载 WARP 网络接口和 warp-go)\n warp-go v (同步脚本至最新版本)\n warp-go i (更换支持 Netflix 的IP)\n warp-go 4/6 (WARP IPv4/IPv6 单栈)\n warp-go d (WARP 双栈)\n warp-go n (WARP IPv4 非全局)\n warp-go g (WARP 全局 / 非全局相互切换)\n warp-go e (输出 wireguard 和 sing-box 配置文件)\n warp-go a (更换到 FreeWARP+ 或 Teams 账户)"
E[3]="This project is designed to add WARP network interface for VPS, using warp-go core, using various interfaces of CloudFlare-WARP, integrated wireguard-go, can completely replace WGCF. Save Hong Kong, Toronto and other VPS, can also get WARP IP. Thanks again @CoiaPrant and his team. Project address: https://gitlab.com/ProjectWARP/warp-go/-/tree/master/"
@@ -90,18 +90,18 @@ E[36]="The TUN module is not loaded. You should turn it on in the control panel.
C[36]="没有加载 TUN 模块,请在管理后台开启或联系供应商了解如何开启,问题反馈:[https://github.com/fscarmen/warp-sh/issues]"
E[37]="Curren architecture \$(uname -m) is not supported. Feedback: [https://github.com/fscarmen/warp-sh/issues]"
C[37]="当前架构 \$(uname -m) 暂不支持,问题反馈:[https://github.com/fscarmen/warp-sh/issues]"
E[38]="If there is a WARP+ License, please enter it, otherwise press Enter to continue:"
C[38]="如有 WARP+ License 请输入,没有可回车继续:"
E[38]="If you have a WARP+ License, please input it. Otherwise, press Enter to use the key generated by the plusKey API:"
C[38]="如果您有 WARP+ License请输入;否则,请按 Enter 键使用由 plusKey API 生成的 license"
E[39]="Input errors up to 5 times.The script is aborted."
C[39]="输入错误达5次,脚本退出"
E[40]="License should be 26 characters, please re-enter WARP+ License. Otherwise press Enter to continue. \(\${i} times remaining\):"
C[40]="License 应为26位字符,请重新输入 WARP+ License没有可回车继续\(剩余\${i}次\):"
E[40]="License should be 26 characters, please re-input WARP+ License. Otherwise, press Enter to use the key generated by the plusKey API. \(\${i} times remaining\):"
C[40]="License 应为26位字符,请重新输入 WARP+ License回车则使用 plusKey api 生成 的 key \(剩余\${i}次\):"
E[41]="Please customize the device name (Default is [warp-go] if left blank):"
C[41]="请自定义设备名 (如果不输入,默认为 [warp-go]):"
E[42]="Please Input WARP+ license:"
C[42]="请输入WARP+ License:"
E[43]="License should be 26 characters, please re-enter WARP+ License. Otherwise press Enter to continue. \(\${i} times remaining\): "
C[43]="License 应为26位字符,请重新输入 WARP+ License \(剩余\${i}次\): "
E[42]="Please Input WARP+ license. Enter to use the key generated by the plusKey api:"
C[42]="请输入WARP+ License,回车则使用 plusKey api 生成 的 key:"
E[43]="Generating Plus License..."
C[43]="正在生成 Plus License...."
E[44]="Your organization"
C[44]="组织名:"
E[45]="Token error, please re-enter Teams token \(remaining \${i} times\):"
@@ -240,6 +240,8 @@ E[111]="Organization does not exist, please re-enter:"
C[111]="组织名不存在,请重新输入:"
E[112]="The verification code is wrong, please re-enter:"
C[112]="验证码错误,请重新输入:"
E[113]="1. input the organization and email verification code\n 2. share teams account (default)"
C[113]="1. 输入组织名和邮箱验证码获取\n 2. 共享 teams 账户 (默认)"
# 自定义字体彩色,read 函数
warning() { echo -e "\033[31m\033[01m$*\033[0m"; } # 红色
@@ -399,6 +401,12 @@ check_dependencies() {
PING6='ping -6' && [ $(type -p ping6) ] && PING6='ping6'
}
# 通过 warp api 生成 plusKey
generate_pluskey() {
local FILE_PATH="$1"
[ -n "$FILE_PATH" ] && warp_api pluskey | awk -F '"' '/licenseCode/{print $4}' > $FILE_PATH || warp_api pluskey | awk -F '"' '/licenseCode/{print $4}'
}
# 获取 warp 账户信息
warp_api(){
local WARP_API_URL="warp.cloudflare.now.cc"
@@ -434,13 +442,13 @@ warp_api(){
# wgcf 文件,默认存放路径为 /etc/wireguard/wgcf-account.toml
elif grep -q 'access_token' $FILE_PATH; then
id=$(grep 'device_id' "$FILE_PATH" | cut -d\' -f2)
token=$(grep 'access_token' "$FILE_PATH" | cut -d\' -f2)
local WARP_DEVICE_ID=$(grep 'device_id' "$FILE_PATH" | cut -d\' -f2)
local WARP_TOKEN=$(grep 'access_token' "$FILE_PATH" | cut -d\' -f2)
# warp-go 文件,默认存放路径为 /opt/warp-go/warp.conf
elif grep -q 'PrivateKey' $FILE_PATH; then
id=$(awk -F' *= *' '/^Device/{print $2}' "$FILE_PATH")
token=$(awk -F' *= *' '/^Token/{print $2}' "$FILE_PATH")
local WARP_DEVICE_ID=$(awk -F' *= *' '/^Device/{print $2}' "$FILE_PATH")
local WARP_TOKEN=$(awk -F' *= *' '/^Token/{print $2}' "$FILE_PATH")
fi
fi
@@ -486,6 +494,9 @@ warp_api(){
curl -m5 -sL "https://${WARP_API_URL}/?run=token&organization=${TEAM_ORGANIZATION}&A=${A}&S=${S}&N=${N}&code=${TEAM_CODE}"
;;
pluskey )
curl -m30 -sL "https://${WARP_API_URL}/?run=pluskey"
;;
esac
}
@@ -502,6 +513,52 @@ check_install() {
wget --no-check-certificate -T5 -qO- /tmp/warp-go.tar.gz https://gitlab.com/fscarmen/warp/-/raw/main/warp-go/warp-go_"$latest"_linux_"$ARCHITECTURE".tar.gz | tar xz -C /tmp/ warp-go
chmod +x /tmp/warp-go
}&
# 后台优选最佳 MTU
{
# 反复测试最佳 MTU。 Wireguard Header:IPv4=60 bytes,IPv6=80 bytes1280 ≤ MTU ≤ 1420。 ping = 8(ICMP回显示请求和回显应答报文格式长度) + 20(IP首部) 。
# 详细说明:<[WireGuard] Header / MTU sizes for Wireguard>:https://lists.zx2c4.com/pipermail/wireguard/2017-December/002201.html
MTU=$((1500-28))
[ "$IPV4$IPV6" = 01 ] && $PING6 -c1 -W1 -s $MTU -Mdo 2606:4700:d0::a29f:c001 >/dev/null 2>&1 || ping -c1 -W1 -s $MTU -Mdo 162.159.193.10 >/dev/null 2>&1
until [[ $? = 0 || $MTU -le $((1280+80-28)) ]]; do
MTU=$((MTU-10))
[ "$IPV4$IPV6" = 01 ] && $PING6 -c1 -W1 -s $MTU -Mdo 2606:4700:d0::a29f:c001 >/dev/null 2>&1 || ping -c1 -W1 -s $MTU -Mdo 162.159.193.10 >/dev/null 2>&1
done
if [ "$MTU" -eq $((1500-28)) ]; then
MTU=$MTU
elif [ "$MTU" -le $((1280+80-28)) ]; then
MTU=$((1280+80-28))
else
for i in {0..8}; do
(( MTU++ ))
( [ "$IPV4$IPV6" = 01 ] && $PING6 -c1 -W1 -s $MTU -Mdo 2606:4700:d0::a29f:c001 >/dev/null 2>&1 || ping -c1 -W1 -s $MTU -Mdo 162.159.193.10 >/dev/null 2>&1 ) || break
done
(( MTU-- ))
fi
MTU=$((MTU+28-80))
echo "$MTU" > /tmp/warp-go-mtu
}&
# 后台优选优选 WARP Endpoint
{
wget $STACK -qO /tmp/endpoint https://gitlab.com/fscarmen/warp/-/raw/main/endpoint/warp-linux-${ARCHITECTURE//amd64*/amd64} && chmod +x /tmp/endpoint
[ "$IPV4$IPV6" = 01 ] && wget $STACK -qO /tmp/ip https://gitlab.com/fscarmen/warp/-/raw/main/endpoint/ipv6 || wget $STACK -qO /tmp/ip https://gitlab.com/fscarmen/warp/-/raw/main/endpoint/ipv4
if [[ -s /tmp/endpoint && -s /tmp/ip ]]; then
/tmp/endpoint -file /tmp/ip -output /tmp/endpoint_result >/dev/null 2>&1
# 如果全部是数据包丢失,LOSS = 100%,说明 UDP 被禁止,生成标志 /tmp/noudp
[ "$(grep -sE '[0-9]+[ ]+ms$' /tmp/endpoint_result | awk -F, 'NR==1 {print $2}')" = '100.00%' ] && touch /tmp/noudp || ENDPOINT=$(grep -sE '[0-9]+[ ]+ms$' /tmp/endpoint_result | awk -F, 'NR==1 {print $1}')
rm -f /tmp/{endpoint,ip,endpoint_result}
fi
# 如果失败,会有默认值 162.159.193.10:2408 或 [2606:4700:d0::a29f:c001]:2408
[ "$IPV4$IPV6" = 01 ] && ENDPOINT=${ENDPOINT:-'[2606:4700:d0::a29f:c001]:2408'} || ENDPOINT=${ENDPOINT:-'162.159.193.10:2408'}
echo "$ENDPOINT" > /tmp/warp-go-endpoint
}&
fi
}
@@ -811,7 +868,7 @@ EOF
if grep -sq 'Account' /opt/warp-go/$REGISTER_FILE; then
echo -e "\n[Script]\nPostUp =\nPostDown =" >> /opt/warp-go/$REGISTER_FILE && sed -i 's/\r//' /opt/warp-go/$REGISTER_FILE
if [ -n "$LICENSE" ]; then
local RESULT=$(warp_api "license" "/opt/warp-go/$REGISTER_FILE" "$LICENSE" >/dev/null 2>&1)
local RESULT=$(warp_api "license" "/opt/warp-go/$REGISTER_FILE" "$LICENSE")
if [[ "$RESULT" =~ '"warp_plus": true' ]]; then
warp_api "name" "/opt/warp-go/$REGISTER_FILE" "" "$NAME" >/dev/null 2>&1
echo "$LICENSE" > /opt/warp-go/License
@@ -1046,27 +1103,89 @@ EOF
[ "$IPV6" = 1 ] && ip6_info
}
# 寻找最佳 MTU
best_mtu() {
# 反复测试最佳 MTU。 Wireguard Header:IPv4=60 bytes,IPv6=80 bytes1280 ≤ MTU ≤ 1420。 ping = 8(ICMP回显示请求和回显应答报文格式长度) + 20(IP首部) 。
# 详细说明:<[WireGuard] Header / MTU sizes for Wireguard>:https://lists.zx2c4.com/pipermail/wireguard/2017-December/002201.html
MTU=$((1500-28))
[ "$IPV4$IPV6" = 01 ] && $PING6 -c1 -W1 -s $MTU -Mdo 2606:4700:d0::a29f:c001 >/dev/null 2>&1 || ping -c1 -W1 -s $MTU -Mdo 162.159.193.10 >/dev/null 2>&1
until [[ $? = 0 || $MTU -le $((1280+80-28)) ]]; do
MTU=$((MTU-10))
[ "$IPV4$IPV6" = 01 ] && $PING6 -c1 -W1 -s $MTU -Mdo 2606:4700:d0::a29f:c001 >/dev/null 2>&1 || ping -c1 -W1 -s $MTU -Mdo 162.159.193.10 >/dev/null 2>&1
done
if [ "$MTU" -eq $((1500-28)) ]; then
MTU=$MTU
elif [ "$MTU" -le $((1280+80-28)) ]; then
MTU=$((1280+80-28))
else
for i in {0..8}; do
(( MTU++ ))
( [ "$IPV4$IPV6" = 01 ] && $PING6 -c1 -W1 -s $MTU -Mdo 2606:4700:d0::a29f:c001 >/dev/null 2>&1 || ping -c1 -W1 -s $MTU -Mdo 162.159.193.10 >/dev/null 2>&1 ) || break
done
(( MTU-- ))
fi
MTU=$((MTU+28-80))
echo "$MTU" > /tmp/warp-go-mtu
}
# 寻找最佳 Endpoint,根据 v4 / v6 情况下载 endpoint 库
best_endpoint() {
wget $STACK -qO /tmp/endpoint https://gitlab.com/fscarmen/warp/-/raw/main/endpoint/warp-linux-${ARCHITECTURE//amd64*/amd64} && chmod +x /tmp/endpoint
[ "$IPV4$IPV6" = 01 ] && wget $STACK -qO /tmp/ip https://gitlab.com/fscarmen/warp/-/raw/main/endpoint/ipv6 || wget $STACK -qO /tmp/ip https://gitlab.com/fscarmen/warp/-/raw/main/endpoint/ipv4
if [[ -s /tmp/endpoint && -s /tmp/ip ]]; then
/tmp/endpoint -file /tmp/ip -output /tmp/endpoint_result >/dev/null 2>&1
# 如果全部是数据包丢失,LOSS = 100%,说明 UDP 被禁止,生成标志 /tmp/noudp
[ "$(grep -sE '[0-9]+[ ]+ms$' /tmp/endpoint_result | awk -F, 'NR==1 {print $2}')" = '100.00%' ] && touch /tmp/noudp || ENDPOINT=$(grep -sE '[0-9]+[ ]+ms$' /tmp/endpoint_result | awk -F, 'NR==1 {print $1}')
rm -f /tmp/{endpoint,ip,endpoint_result}
fi
# 如果失败,会有默认值 162.159.193.10:2408 或 [2606:4700:d0::a29f:c001]:2408
[ "$IPV4$IPV6" = 01 ] && ENDPOINT=${ENDPOINT:-'[2606:4700:d0::a29f:c001]:2408'} || ENDPOINT=${ENDPOINT:-'162.159.193.10:2408'}
echo "$ENDPOINT" > /tmp/warp-go-endpoint
}
# 输入 WARP+ 账户(如有),限制位数为空或者26位以防输入错误
input_license() {
[ -z "$LICENSE" ] && reading " $(text 38) " LICENSE
if [ -z "$LICENSE" ]; then
hint " $(text 43) "
wait
[ -s /tmp/warp-go-license ] && LICENSE=$(cat /tmp/warp-go-license) && rm -f /tmp/warp-go-license
fi
i=5
until [[ -z "$LICENSE" || "$LICENSE" =~ ^[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}$ ]]; do
until [[ "$LICENSE" =~ ^[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}$ ]]; do
(( i-- )) || true
[ "$i" = 0 ] && error "$(text 39)" || reading " $(text_eval 40) " LICENSE
if [ -z "$LICENSE" ]; then
hint " $(text 43) "
wait
[ -s /tmp/warp-go-license ] && LICENSE=$(cat /tmp/warp-go-license) && rm -f /tmp/warp-go-license
fi
done
[[ -n "$LICENSE" && -z "$NAME" ]] && reading " $(text 41) " NAME
[[ -n "$LICENSE" && -z "$NAME" ]] && hint " WARP+ license: $LICENSE " && reading " $(text 41) " NAME
[ -n "$NAME" ] && NAME="${NAME//[[:space:]]/_}" || NAME="${NAME:-warp-go}"
}
# 升级 WARP+ 账户(如有),限制位数为空或者26位以防输入错误,WARP interface 可以自定义设备名(不允许字符串间有空格,如遇到将会以_代替)
update_license() {
[ -z "$LICENSE" ] && reading " $(text 42) " LICENSE
hint " $(text 43) "
wait
[ -z "$LICENSE" ] && [ -s /tmp/warp-go-license ] && LICENSE=$(cat /tmp/warp-go-license) && rm -f /tmp/warp-go-license
i=5
until [[ "$LICENSE" =~ ^[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}$ ]]; do
(( i-- )) || true
[ "$i" = 0 ] && error "$(text 39)" || reading " $(text_eval 43) " LICENSE
(( i-- )) || true
[ "$i" = 0 ] && error "$(text 39)" || reading " $(text_eval 40) " LICENSE
hint " $(text 43) "
wait
[ -z "$LICENSE" ] && [ -s /tmp/warp-go-license ] && LICENSE=$(cat /tmp/warp-go-license) && rm -f /tmp/warp-go-license
done
[[ -n "$LICENSE" && -z "$NAME" ]] && reading " $(text 41) " NAME
[[ -n "$LICENSE" && -z "$NAME" ]] && hint " WARP+ license: $LICENSE " && reading " $(text 41) " NAME
[ -n "$NAME" ] && NAME="${NAME//[[:space:]]/_}" || NAME="${NAME:-warp-go}"
}
@@ -1091,7 +1210,7 @@ get_token() {
unset TEAM_CODE TOKEN
(( ERROR_TIMES++ ))
if [[ "$ERROR_TIMES" > 5 ]]; then
error "\n $(text 39) \n"
error "\n $(text 39) \n"
else
[ "$ERROR_TIMES" = 1 ] && reading " $(text 110) " TEAM_CODE || reading " $(text 112) " TEAM_CODE
[[ "$TEAM_CODE" =~ ^[0-9]{6}$ ]] && local TEAM_TOKEN=$(warp_api "token-step2" "" "" "" "" "" "" "$TEAM_AUTH" "" "" "$TEAM_CODE")
@@ -1122,11 +1241,11 @@ update() {
[[ "$QUOTA" =~ '.' ]] && PLUS_QUOTA="\\n $(text 26): $QUOTA"
esac
[ -z "$LICENSETYPE" ] && hint "\n $(text_eval 46) \n" && reading " $(text 4) " LICENSETYPE
case "$LICENSETYPE" in
[ -z "$LICENSE_TYPE" ] && hint "\n $(text_eval 46) \n" && reading " $(text 4) " LICENSE_TYPE
case "$LICENSE_TYPE" in
1|2 )
unset QUOTA
case "$LICENSETYPE" in
case "$LICENSE_TYPE" in
1 )
k=' free'
[ "$ACCOUNT_TYPE" = free ] && KEEP_FREE='1'
@@ -1152,26 +1271,29 @@ update() {
;;
3 )
unset QUOTA
get_token
hint " $(text 113) " && reading " $(text 4) " TEAMS_TYPE
grep -qw "1" <<< "$TEAMS_TYPE" && get_token
if [ -n "$TOKEN" ]; then
k=' teams'
register_api warp.conf.tmp 58 59
for a in {2..5}; do
sed -i "${a}s#.*#$(sed -ne ${a}p /opt/warp-go/warp.conf.tmp)#" /opt/warp-go/warp.conf
done
[ -n "$NAME" ] && echo "$NAME" > /opt/warp-go/Device_Name && warp_api "name" "/opt/warp-go/warp.conf" "" "$NAME" >/dev/null 2>&1
rm -f /opt/warp-go/warp.conf.tmp
else
sed -i "s#^Device.*#Device = FSCARMEN-WARP-SHARE-TEAM#g; s#.*PrivateKey.*#PrivateKey = SHVqHEGI7k2+OQ/oWMmWY2EQObbRQjRBdDPimh0h1WY=#g; s#.*Token.*#Token = PROTECTED_PLACEHOLDER#g; s#.*Type.*#Type = team#g" /opt/warp-go/warp.conf
echo 'SHARE' > /opt/warp-go/Device_Name
fi
grep -qE 'Type[ ]+=[ ]+team' /opt/warp-go/warp.conf && echo "$NAME" > /opt/warp-go/Device_Name
OPTION=o && net
;;
0 )
unset LICENSETYPE
unset LICENSE_TYPE
menu
;;
* )
warning " $(text 34) [0-3] "; sleep 1; unset LICENSETYPE; update
warning " $(text 34) [0-3] "; sleep 1; unset LICENSE_TYPE; update
esac
}
@@ -1209,13 +1331,15 @@ install() {
rm -rf /opt/warp-go/warp-go /opt/warp-go/warp.conf
# 询问是否有 WARP+ 或 Teams 账户
[ -z "$LICENSETYPE" ] && hint "\n $(text 54) \n" && reading " $(text 4) " LICENSETYPE
case "$LICENSETYPE" in
[ -z "$LICENSE_TYPE" ] && hint "\n $(text 54) \n" && reading " $(text 4) " LICENSE_TYPE
case "$LICENSE_TYPE" in
1 )
input_license
;;
2 )
get_token
hint " $(text 113) " && reading " $(text 4) " TEAMS_TYPE
grep -qw "1" <<< "$TEAMS_TYPE" && get_token
;;
esac
# 选择优先使用 IPv4 /IPv6 网络
@@ -1224,51 +1348,6 @@ install() {
# 脚本开始时间
start=$(date +%s)
# 寻找最佳 MTU 和 Endpoint 值
{
# 详细说明:<[WireGuard] Header / MTU sizes for Wireguard>:https://lists.zx2c4.com/pipermail/wireguard/2017-December/002201.html
MTU=$((1500-28))
[ "$IPV4$IPV6" = 01 ] && $PING6 -c1 -W1 -s $MTU -Mdo 2606:4700:d0::a29f:c001 >/dev/null 2>&1 || ping -c1 -W1 -s $MTU -Mdo 162.159.193.10 >/dev/null 2>&1
until [[ $? = 0 || $MTU -le $((1280+80-28)) ]]; do
MTU=$((MTU-10))
[ "$IPV4$IPV6" = 01 ] && $PING6 -c1 -W1 -s $MTU -Mdo 2606:4700:d0::a29f:c001 >/dev/null 2>&1 || ping -c1 -W1 -s $MTU -Mdo 162.159.193.10 >/dev/null 2>&1
done
if [ "$MTU" -eq $((1500-28)) ]; then
MTU=$MTU
elif [ "$MTU" -le $((1280+80-28)) ]; then
MTU=$((1280+80-28))
else
for i in {0..8}; do
(( MTU++ ))
( [ "$IPV4$IPV6" = 01 ] && $PING6 -c1 -W1 -s $MTU -Mdo 2606:4700:d0::a29f:c001 >/dev/null 2>&1 || ping -c1 -W1 -s $MTU -Mdo 162.159.193.10 >/dev/null 2>&1 ) || break
done
(( MTU-- ))
fi
MTU=$((MTU+28-80))
echo "$MTU" > /tmp/warp-go-mtu
# 寻找最佳 Endpoint,根据 v4 / v6 情况下载 endpoint 库
wget $STACK -qO /tmp/endpoint https://gitlab.com/fscarmen/warp/-/raw/main/endpoint/warp-linux-${ARCHITECTURE//amd64*/amd64} && chmod +x /tmp/endpoint
[ "$IPV4$IPV6" = 01 ] && wget $STACK -qO /tmp/ip https://gitlab.com/fscarmen/warp/-/raw/main/endpoint/ipv6 || wget $STACK -qO /tmp/ip https://gitlab.com/fscarmen/warp/-/raw/main/endpoint/ipv4
if [[ -s /tmp/endpoint && -s /tmp/ip ]]; then
/tmp/endpoint -file /tmp/ip -output /tmp/endpoint_result >/dev/null 2>&1
# 如果全部是数据包丢失,LOSS = 100%,说明 UDP 被禁止,生成标志 /tmp/noudp
[ "$(grep -sE '[0-9]+[ ]+ms$' /tmp/endpoint_result | awk -F, 'NR==1 {print $2}')" = '100.00%' ] && touch /tmp/noudp || ENDPOINT=$(grep -sE '[0-9]+[ ]+ms$' /tmp/endpoint_result | awk -F, 'NR==1 {print $1}')
rm -f /tmp/{endpoint,ip,endpoint_result}
fi
# 如果失败,会有默认值 162.159.193.10:2408 或 [2606:4700:d0::a29f:c001]:2408
[ "$IPV4$IPV6" = 01 ] && ENDPOINT=${ENDPOINT:-'[2606:4700:d0::a29f:c001]:2408'} || ENDPOINT=${ENDPOINT:-'162.159.193.10:2408'}
echo "$ENDPOINT" > /tmp/warp-go-endpoint
info "\n $(text 9) \n"
}&
# 注册 Teams 账户 (将生成 warp 文件保存账户信息)
{
mkdir -p /opt/warp-go/ >/dev/null 2>&1
@@ -1277,7 +1356,7 @@ install() {
[ ! -s /opt/warp-go/warp-go ] && error "$(text 57)"
# 注册用户自定义 token 的 Teams 账户
if [ "$LICENSETYPE" = 2 ]; then
if [ "$LICENSE_TYPE" = 2 ]; then
if [ -n "$TOKEN" ]; then
k=' teams'
register_api warp.conf 58
@@ -1306,6 +1385,7 @@ KeepAlive = 30
#PostUp =
#PostDown =
EOF
echo 'SHARE' > /opt/warp-go/Device_Name
fi
# 注册免费和 Plus 账户
@@ -1315,8 +1395,8 @@ EOF
fi
# 如为 Plus 或 Team 账户,把设备名记录到文件 /opt/warp-go/Device_Name; Plus 账户的话,把 License 保存到 /opt/warp-go/License;
grep -qE 'Type[ ]+=[ ]+plus' /opt/warp-go/warp.conf && echo "$NAME" > /opt/warp-go/Device_Name && echo "$LICENSE" > /opt/warp-go/License
grep -qE 'Type[ ]+=[ ]+team' /opt/warp-go/warp.conf && echo "$NAME" > /opt/warp-go/Device_Name
grep -qE 'Type[ ]+=[ ]+plus' /opt/warp-go/warp.conf && [ -n "$NAME" ] && echo "$NAME" > /opt/warp-go/Device_Name && echo "$LICENSE" > /opt/warp-go/License
grep -qE 'Type[ ]+=[ ]+team' /opt/warp-go/warp.conf && [ -n "$NAME" ] && echo "$NAME" > /opt/warp-go/Device_Name && warp_api "name" "/opt/warp-go/warp.conf" "" "$NAME" >/dev/null 2>&1
# 生成非全局执行文件并赋权
cat > /opt/warp-go/NonGlobalUp.sh << EOF
@@ -1364,6 +1444,7 @@ EOF
esac
wait
info "\n $(text 9) \n"
# 如有所有 endpoint 都不能连通的情况,脚本中止
if [ -e /tmp/noudp ]; then
@@ -1557,8 +1638,8 @@ menu() {
# 参数选项 URL 或 License 或转换 WARP 单双栈
if [ "$2" != '[lisence]' ]; then
if [[ "$2" =~ ^[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}$ ]]; then
LICENSETYPE='2' && LICENSE="$2"
elif [[ "${#2}" -ge "$TOKEN_LENGTH" ]]; then LICENSETYPE='3' && TOKEN="$2"
LICENSE_TYPE='2' && LICENSE="$2"
elif [[ "${#2}" -ge "$TOKEN_LENGTH" ]]; then LICENSE_TYPE='3' && TOKEN="$2"
elif [[ "$2" =~ ^[A-Za-z]{2}$ ]]; then EXPECT="$2"
elif [[ "$1" = s && "$2" = [46Dd] ]]; then PRIORITY_SWITCH=$(tr 'A-Z' 'a-z' <<< "$2")
fi
@@ -1567,6 +1648,9 @@ fi
# 自定义 WARP+ 设备名
NAME="$3"
# 后台生成 plus key
{ generate_pluskey /tmp/warp-go-license; }&
# 主程序运行 1/3
check_cdn
statistics_of_run-times