mirror of
https://gitlab.com/fscarmen/warp.git
synced 2026-06-15 03:25:42 +08:00
refactor(api): migrate endpoint and remove cryptographic dependencies
Migrate WARP API from warp.cloudflare.now.cc to warp.cloudflare.nyc.mn and simplify registration by delegating key generation to API service. Changes: - Update API endpoint across all scripts and documentation - Remove openssl, xxd, jq from required dependencies (-173 lines) - Replace local WireGuard key pair generation with API call - Simplify registration from 30-retry loop to single API request - Move JSON tool detection to export function where needed - Fix wg-quick backup restoration during uninstallation - Update installation progress from 3-step to 2-step flow Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -42,9 +42,9 @@
|
||||
>
|
||||
>2024.9.14 menu.sh v3.1.2 / warp-go.sh v1.2.2 1. 由于官方禁止了克隆 Warp+ license,故去掉生成 license 的功能; 2. 去掉不必要的依赖 python3
|
||||
>
|
||||
>2024.7.25 menu.sh v3.1.1 / warp-go.sh v1.2.1 1. 支持使用自建 warp api: https://warp.cloudflare.now.cc/?run=pluskey,生成 1920 PB WARP+ license 升级为 Plus 账户; 2. Client 对 WARP+ 支持不够,只能使用 IPv4,不能使用 IPv6; 3. 优化安装程序,缩短脚本运行时间
|
||||
>2024.7.25 menu.sh v3.1.1 / warp-go.sh v1.2.1 1. 支持使用自建 warp api: https://warp.cloudflare.nyc.mn/?run=pluskey,生成 1920 PB WARP+ license 升级为 Plus 账户; 2. Client 对 WARP+ 支持不够,只能使用 IPv4,不能使用 IPv6; 3. 优化安装程序,缩短脚本运行时间
|
||||
>
|
||||
>2024.7.18 menu.sh v3.1.0 / warp-go.sh v1.2.0 1. 使用自建 warp api: https://warp.cloudflare.now.cc/ ,升级为 Teams 账户,不需要提前获取 Token; 2. 由于 Client 的设置需要到 Cloudflare 控制后台设置,处理不好会导致 vps 失去联系,所以 Client 并没有升级为 Teams 账户的处理
|
||||
>2024.7.18 menu.sh v3.1.0 / warp-go.sh v1.2.0 1. 使用自建 warp api: https://warp.cloudflare.nyc.mn/ ,升级为 Teams 账户,不需要提前获取 Token; 2. 由于 Client 的设置需要到 Cloudflare 控制后台设置,处理不好会导致 vps 失去联系,所以 Client 并没有升级为 Teams 账户的处理
|
||||
>
|
||||
>2024.7.8 menu.sh v3.0.10 / warp-go.sh v1.1.9 1. 发布 warp api,可以注册账户,加入 Zero Trust,查账户信息等所有的操作; 2. 脚本更新 warp api
|
||||
>
|
||||
@@ -292,18 +292,18 @@ warp-go [option] [lisence]
|
||||
|
||||
| run 参数 | 作用描述 | 参数 | 示例 |
|
||||
|---|---|---|---|
|
||||
| | 使用指南 | | `https://warp.cloudflare.now.cc/` |
|
||||
| `register` | 注册新设备 | `team_token(可选)`, `format(可选)` | `https://warp.cloudflare.now.cc/?run=register&team_token=<Your-Team-Token>&format=<json\|yaml\|client\|wireguard\|warp-go\|\|clash\|xray\|sing-box\|qrencode>` |
|
||||
| `device` | 获取特定设备的详细信息 | `device_id`, `token` | `https://warp.cloudflare.now.cc/?run=device&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `app` | 获取客户端配置 | `token` | `https://warp.cloudflare.now.cc/?run=app&token=<Your-Token>` |
|
||||
| `bind` | 将设备绑定到帐户 | `device_id`, `token` | `https://warp.cloudflare.now.cc/?run=bind&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `name` | 设置设备名称 | `device_id`, `token`, `device_name` | `https://warp.cloudflare.now.cc/?run=name&device_id=<Your-Device-ID>&token=<Your-Token>&device_name=<Your-Device-Name>` |
|
||||
| `license` | 设置设备许可证 | `device_id`, `token`, `license` | `https://warp.cloudflare.now.cc/?run=license&device_id=<Your-Device-ID>&token=<Your-Token>&license=<Your-License>` |
|
||||
| `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>` |
|
||||
| `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>` |
|
||||
| `key` | 生成一对 WireGuard 公私钥 | `format(可选)` | `https://warp.cloudflare.now.cc/?run=key&format=<json\|yaml>` |
|
||||
| | 使用指南 | | `https://warp.cloudflare.nyc.mn/` |
|
||||
| `register` | 注册新设备 | `team_token(可选)`, `format(可选)` | `https://warp.cloudflare.nyc.mn/?run=register&team_token=<Your-Team-Token>&format=<json\|yaml\|client\|wireguard\|warp-go\|\|clash\|xray\|sing-box\|qrencode>` |
|
||||
| `device` | 获取特定设备的详细信息 | `device_id`, `token` | `https://warp.cloudflare.nyc.mn/?run=device&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `app` | 获取客户端配置 | `token` | `https://warp.cloudflare.nyc.mn/?run=app&token=<Your-Token>` |
|
||||
| `bind` | 将设备绑定到帐户 | `device_id`, `token` | `https://warp.cloudflare.nyc.mn/?run=bind&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `name` | 设置设备名称 | `device_id`, `token`, `device_name` | `https://warp.cloudflare.nyc.mn/?run=name&device_id=<Your-Device-ID>&token=<Your-Token>&device_name=<Your-Device-Name>` |
|
||||
| `license` | 设置设备许可证 | `device_id`, `token`, `license` | `https://warp.cloudflare.nyc.mn/?run=license&device_id=<Your-Device-ID>&token=<Your-Token>&license=<Your-License>` |
|
||||
| `unbind` | 从帐户中取消绑定设备 | `device_id`, `token` | `https://warp.cloudflare.nyc.mn/?run=unbind&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `cancel` | 取消设备注册 | `device_id`, `token` | `https://warp.cloudflare.nyc.mn/?run=cancel&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `id` | Client ID 与 Reserved 转换 | `convert` | `https://warp.cloudflare.nyc.mn/?run=id&convert=<4-char-string\|Numbers1,Numbers2,Numbers3>` |
|
||||
| `token` | 获取 Zero Trust token | `organization`, `email`, `code` | step1: `https://warp.cloudflare.nyc.mn/?organization=<Your-Organization>&email=<Your-Email>` </br> step2: `https://warp.cloudflare.nyc.mn/?organization=<Your-Organization>&A=<A-Value>&S=<S-Value>&N=<N-Value>&code=<Your-Code>` |
|
||||
| `key` | 生成一对 WireGuard 公私钥 | `format(可选)` | `https://warp.cloudflare.nyc.mn/?run=key&format=<json\|yaml>` |
|
||||
|
||||
### Shell-API 运行脚本
|
||||
```
|
||||
@@ -619,7 +619,7 @@ https://github.com/acacia233/Project-WARP-Unlock
|
||||
* 所有的热心网友们
|
||||
|
||||
服务提供(排名不分先后):
|
||||
* fscarmen 的 Warp API: https://warp.cloudflare.now.cc/
|
||||
* fscarmen 的 Warp API: https://warp.cloudflare.nyc.mn/
|
||||
* fscarmen 的 Zero Trust Token API: https://warp-token.cloudflare.now.cc/
|
||||
* CloudFlare Warp(+): https://1.1.1.1/
|
||||
* WGCF 项目原作者: https://github.com/ViRb3/wgcf/
|
||||
|
||||
+18
-18
@@ -42,11 +42,11 @@ English | [中文](README.md)
|
||||
>
|
||||
>2024.9.14 menu.sh v3.1.2 / warp-go.sh v1.2.2 1. Remove the function of generating licenses from the previous version because cloning Warp+ licenses is officially prohibited; 2. Remove unnecessary dependencies on python3;
|
||||
>
|
||||
>2024.7.25 menu.sh v3.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;
|
||||
>2024.7.25 menu.sh v3.1.1 / warp-go.sh v1.2.1 1. Support using the self-built WARP API at https://warp.cloudflare.nyc.mn/?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;
|
||||
>
|
||||
>2024.7.18 menu.sh v3.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;
|
||||
>2024.7.18 menu.sh v3.1.0 / warp-go.sh v1.2.0 1. Use self-built warp api: https://warp.cloudflare.nyc.mn/ 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;
|
||||
>
|
||||
>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;
|
||||
>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.nyc.mn/ ; 2. Scripts to update the 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;
|
||||
>
|
||||
@@ -327,18 +327,18 @@ warp-go [option] [lisence]
|
||||
|
||||
| run parameter | Description | Parameters | Example |
|
||||
|---|---|---|---|
|
||||
| | User Guide | | `https://warp.cloudflare.now.cc/` |
|
||||
| `register` | Register new device | `team_token (optional)`, `format (optional)` | `https://warp.cloudflare.now.cc/?run=register&team_token=<Your-Team-Token>&format=<json\|yaml\|client\|wireguard\|warp-go\|\|clash\|xray\|sing-box\|qrencode>` |
|
||||
| `device` | Get detailed information of a specific device | `device_id`, `token` | `https://warp.cloudflare.now.cc/?run=device&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `app` | Get client configuration | `token` | `https://warp.cloudflare.now.cc/?run=app&token=<Your-Token>` |
|
||||
| `bind` | Bind device to account | `device_id`, `token` | `https://warp.cloudflare.now.cc/?run=bind&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `name` | Set device name | `device_id`, `token`, `device_name` | `https://warp.cloudflare.now.cc/?run=name&device_id=<Your-Device-ID>&token=<Your-Token>&device_name=<Your-Device-Name>` |
|
||||
| `license` | Set device license | `device_id`, `token`, `license` | `https://warp.cloudflare.now.cc/?run=license&device_id=<Your-Device-ID>&token=<Your-Token>&license=<Your-License>` |
|
||||
| `unbind` | Unbind device from account | `device_id`, `token` | `https://warp.cloudflare.now.cc/?run=unbind&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `cancel` | Cancel device registration | `device_id`, `token` | `https://warp.cloudflare.now.cc/?run=cancel&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `id` | Client ID and Reserved conversion | `convert` | `https://warp.cloudflare.now.cc/?run=id&convert=<4-char-string\|Numbers1,Numbers2,Numbers3>` |
|
||||
| `token` | Get 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>` |
|
||||
| `key` | Generate a pair of WireGuard public and private keys | `format (optional)` | `https://warp.cloudflare.now.cc/?run=key&format=<json\|yaml>` |
|
||||
| | User Guide | | `https://warp.cloudflare.nyc.mn/` |
|
||||
| `register` | Register new device | `team_token (optional)`, `format (optional)` | `https://warp.cloudflare.nyc.mn/?run=register&team_token=<Your-Team-Token>&format=<json\|yaml\|client\|wireguard\|warp-go\|\|clash\|xray\|sing-box\|qrencode>` |
|
||||
| `device` | Get detailed information of a specific device | `device_id`, `token` | `https://warp.cloudflare.nyc.mn/?run=device&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `app` | Get client configuration | `token` | `https://warp.cloudflare.nyc.mn/?run=app&token=<Your-Token>` |
|
||||
| `bind` | Bind device to account | `device_id`, `token` | `https://warp.cloudflare.nyc.mn/?run=bind&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `name` | Set device name | `device_id`, `token`, `device_name` | `https://warp.cloudflare.nyc.mn/?run=name&device_id=<Your-Device-ID>&token=<Your-Token>&device_name=<Your-Device-Name>` |
|
||||
| `license` | Set device license | `device_id`, `token`, `license` | `https://warp.cloudflare.nyc.mn/?run=license&device_id=<Your-Device-ID>&token=<Your-Token>&license=<Your-License>` |
|
||||
| `unbind` | Unbind device from account | `device_id`, `token` | `https://warp.cloudflare.nyc.mn/?run=unbind&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `cancel` | Cancel device registration | `device_id`, `token` | `https://warp.cloudflare.nyc.mn/?run=cancel&device_id=<Your-Device-ID>&token=<Your-Token>` |
|
||||
| `id` | Client ID and Reserved conversion | `convert` | `https://warp.cloudflare.nyc.mn/?run=id&convert=<4-char-string\|Numbers1,Numbers2,Numbers3>` |
|
||||
| `token` | Get Zero Trust token | `organization`, `email`, `code` | step1: `https://warp.cloudflare.nyc.mn/?organization=<Your-Organization>&email=<Your-Email>` </br> step2: `https://warp.cloudflare.nyc.mn/?organization=<Your-Organization>&A=<A-Value>&S=<S-Value>&N=<N-Value>&code=<Your-Code>` |
|
||||
| `key` | Generate a pair of WireGuard public and private keys | `format (optional)` | `https://warp.cloudflare.nyc.mn/?run=key&format=<json\|yaml>` |
|
||||
|
||||
### Shell-API Script Usage
|
||||
```
|
||||
@@ -594,7 +594,7 @@ Quote from Luminous: Actual tests show that WARP+ has no difference from the fre
|
||||
|
||||
## How to Obtain and Use WARP Teams for Linux
|
||||
|
||||
* https://warp-token.cloudflare.now.cc/ , through fscarmen's website
|
||||
* https://warp-token.cloudflare.nyc.mn/ , through fscarmen's website
|
||||
|
||||
* https://web--public--warp-team-api--coia-mfs4.code.run/, through Coia's website
|
||||
|
||||
@@ -650,8 +650,8 @@ https://github.com/acacia233/Project-WARP-Unlock
|
||||
* All enthusiastic netizens
|
||||
|
||||
Service providers (in no particular order):
|
||||
* fscarmen's Warp API: https://warp.cloudflare.now.cc/
|
||||
* fscarmen's Zero Trust Token API: https://warp-token.cloudflare.now.cc/
|
||||
* fscarmen's Warp API: https://warp.cloudflare.nyc.mn/
|
||||
* fscarmen's Zero Trust Token API: https://warp-token.cloudflare.nyc.mn/
|
||||
* CloudFlare Warp(+): https://1.1.1.1/
|
||||
* Original author of WGCF project: https://github.com/ViRb3/wgcf/
|
||||
* Coia and warp-go team: https://gitlab.com/ProjectWARP/warp-go
|
||||
|
||||
@@ -70,7 +70,7 @@ register_account() {
|
||||
PRIVATE_KEY=$(echo $KEY_PAIR | sed 's/.*priv:\(.*\)pub.*/\1/' | xxd -r -p | base64)
|
||||
PUBLIC_KEY=$(echo $KEY_PAIR | sed 's/.*pub://' | xxd -r -p | base64)
|
||||
else
|
||||
WG_API=$(curl -m5 -sSL https://wg-key.forvps.gq/)
|
||||
WG_API=$(curl -m5 -sSL "https://warp.cloudflare.nyc.mn/?run=key&format=yaml")
|
||||
PRIVATE_KEY=$(awk 'NR==2 {print $2}' <<<"$WG_API")
|
||||
PUBLIC_KEY=$(awk 'NR==1 {print $2}' <<<"$WG_API")
|
||||
fi
|
||||
|
||||
@@ -410,30 +410,18 @@ check_dependencies() {
|
||||
if [ "$SYSTEM" = 'Alpine' ]; then
|
||||
CHECK_WGET=$(wget 2>&1 | head -n 1)
|
||||
grep -qi 'busybox' <<< "$CHECK_WGET" && ${PACKAGE_INSTALL[int]} wget >/dev/null 2>&1
|
||||
DEPS_CHECK=("ping" "curl" "grep" "bash" "ip" "virt-what" "xxd" "openssl")
|
||||
DEPS_INSTALL=("iputils-ping" "curl" "grep" "bash" "iproute2" "virt-what" "xxd" "openssl")
|
||||
DEPS_CHECK=("ping" "curl" "grep" "bash" "ip" "virt-what")
|
||||
DEPS_INSTALL=("iputils-ping" "curl" "grep" "bash" "iproute2" "virt-what")
|
||||
else
|
||||
# 对于三大系统需要的依赖
|
||||
DEPS_CHECK=("ping" "wget" "curl" "systemctl" "ip" "xxd" "openssl")
|
||||
DEPS_INSTALL=("iputils-ping" "wget" "curl" "systemctl" "iproute2" "xxd" "openssl")
|
||||
DEPS_CHECK=("ping" "wget" "curl" "systemctl" "ip")
|
||||
DEPS_INSTALL=("iputils-ping" "wget" "curl" "systemctl" "iproute2")
|
||||
fi
|
||||
|
||||
for g in "${!DEPS_CHECK[@]}"; do
|
||||
[ ! -x "$(type -p ${DEPS_CHECK[g]})" ] && [[ ! "${DEPS[@]}" =~ "${DEPS_INSTALL[g]}" ]] && DEPS+=(${DEPS_INSTALL[g]})
|
||||
done
|
||||
|
||||
# 检查 JSON 格式化工具
|
||||
if [ -x "$(type -p python3)" ]; then
|
||||
JSON_TOOL="python3 -m json.tool"
|
||||
elif [ -x "$(type -p python)" ]; then
|
||||
JSON_TOOL="python -m json.tool"
|
||||
elif [ -x "$(type -p jq)" ]; then
|
||||
JSON_TOOL="jq"
|
||||
else
|
||||
JSON_TOOL="jq"
|
||||
DEPS+=("jq")
|
||||
fi
|
||||
|
||||
if [ "${#DEPS[@]}" -ge 1 ]; then
|
||||
info "\n $(text 7) ${DEPS[@]} \n"
|
||||
${PACKAGE_UPDATE[int]} >/dev/null 2>&1
|
||||
@@ -481,47 +469,10 @@ warp_api(){
|
||||
fi
|
||||
|
||||
case "$RUN" in
|
||||
register )
|
||||
# 生成 wireguard 公私钥,并且补上 private key
|
||||
if [[ -x "$(type -p openssl)" && -x "$(type -p xxd)" && -x "$(type -p base64)" ]]; then
|
||||
local KEY_PAIR=$(openssl genpkey -algorithm X25519 | openssl pkey -text -noout)
|
||||
local PRIVATE_KEY=$(echo $KEY_PAIR | sed 's/.*priv:\(.*\)pub.*/\1/; s/ //g' | xxd -r -p | base64)
|
||||
local PUBLIC_KEY=$(echo $KEY_PAIR | sed 's/.*pub://; s/ //g'| xxd -r -p | base64)
|
||||
else
|
||||
local WG_API=$(curl -m5 -sSL "https://warp.cloudflare.now.cc/?run=key&format=yaml")
|
||||
local PRIVATE_KEY=$(awk 'NR==2 {print $2}' <<< "$WG_API")
|
||||
local PUBLIC_KEY=$(awk 'NR==1 {print $2}' <<< "$WG_API")
|
||||
fi
|
||||
|
||||
if grep -q '.' <<< "$PRIVATE_KEY" && grep -q '.' <<< "$PUBLIC_KEY"; then
|
||||
local INSTALL_ID=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 22)
|
||||
local FCM_TOKEN="${INSTALL_ID}:APA91b$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 134)"
|
||||
|
||||
# 由于某些 IP 存在被限制注册,所以使用不停的注册来处理,超过一定次数则使用预设账户
|
||||
until grep -q 'account' <<< "$ACCOUNT"; do
|
||||
((REGISTER_ERROR_TIME++))
|
||||
if [ "$REGISTER_ERROR_TIME" -gt 30 ]; then
|
||||
break
|
||||
elif [ "$REGISTER_ERROR_TIME" -gt 1 ]; then
|
||||
sleep 5
|
||||
fi
|
||||
local ACCOUNT=$(curl --request POST 'https://api.cloudflareclient.com/v0a2158/reg' \
|
||||
--silent \
|
||||
--location \
|
||||
--tlsv1.3 \
|
||||
--header 'User-Agent: okhttp/3.12.1' \
|
||||
--header 'CF-Client-Version: a-6.10-2158' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{"key":"'${PUBLIC_KEY}'","install_id":"'${INSTALL_ID}'","fcm_token":"'${FCM_TOKEN}'","tos":"'$(date +"%Y-%m-%dT%H:%M:%S.000Z")'","model":"PC","serial_number":"'${INSTALL_ID}'","locale":"zh_CN"}')
|
||||
done
|
||||
|
||||
if grep -q 'account' <<< "$ACCOUNT"; then
|
||||
local CLIENT_ID=$(sed 's/.*"client_id":"\([^\"]\+\)\".*/\1/' <<<"$ACCOUNT")
|
||||
local RESERVED=$(echo "$CLIENT_ID" | base64 -d | xxd -p | fold -w2 | while read HEX; do printf '%d ' "0x${HEX}"; done | awk '{print "["$1", "$2", "$3"]"}')
|
||||
|
||||
$JSON_TOOL <<< "$ACCOUNT" 2>&1 | sed "/\"key\"/a\ \"private_key\": \"$PRIVATE_KEY\"," | sed "/\"client_id\"/a\ \"reserved\": $RESERVED,"
|
||||
else
|
||||
echo '{
|
||||
register )
|
||||
local ACCOUNT=$(curl --retry 50 --retry-delay 1 --max-time 2 --silent --location --fail "https://warp.cloudflare.nyc.mn/?run=register")
|
||||
grep -q '"id"' <<< "$ACCOUNT" && echo "$ACCOUNT" ||
|
||||
echo '{
|
||||
"id": "b0fe9b24-3396-486e-a12d-c194dbbb7bfb",
|
||||
"type": "a",
|
||||
"model": "PC",
|
||||
@@ -609,8 +560,6 @@ warp_api(){
|
||||
"tunnel_protocol": "masque"
|
||||
}
|
||||
}'
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
cancel )
|
||||
# 只保留 Teams 或者预设账户,删除其他账户
|
||||
@@ -1170,6 +1119,11 @@ uninstall() {
|
||||
done
|
||||
|
||||
# 删除本脚本安装在 /etc/wireguard/ 下的所有文件,如果删除后目录为空,一并把目录删除
|
||||
if [ -s /usr/bin/wg-quick.origin ]; then
|
||||
# 检查是否需要还原wg-quick.origin文件
|
||||
grep -q '^#[[:space:]]\+add_if$' /usr/bin/wg-quick.origin && sed 's/#\([[:space:]]\+add_if\)/\1/; /wireguard-go "$INTERFACE"/d' /usr/bin/wg-quick
|
||||
mv -f /usr/bin/wg-quick.origin /usr/bin/wg-quick
|
||||
fi
|
||||
rm -f /usr/bin/wg-quick.{origin,reserved}
|
||||
rm -f /tmp/{best_mtu,wireguard-go-*}
|
||||
rm -f /etc/wireguard/{warp-account.conf,warp_unlock.sh,warp.conf,up,down,proxy.conf,menu.sh,language,NonGlobalUp.sh,NonGlobalDown.sh}
|
||||
@@ -2028,13 +1982,14 @@ EOF
|
||||
grep -q "Arch" <<< "$SYSTEM" && ! grep -q 'cmd resolvconf -u' /usr/bin/wg-quick && sed -i '/\[\[ \${#DNS\[@\]} -gt 0 \]\] || return 0/a\ cmd resolvconf -u' /usr/bin/wg-quick
|
||||
|
||||
# 如果用户选择使用 wireguard-go reserved 版本,则修改 wg-quick 文件
|
||||
cp -f /usr/bin/wg-quick{,.origin}
|
||||
if [ "$KERNEL_ENABLE" = '1' ]; then
|
||||
cp -f /usr/bin/wg-quick{,.origin}
|
||||
mv -f /usr/bin/wg-quick /usr/bin/wg-quick.reserved
|
||||
grep -q '^#[[:space:]]*add_if' /usr/bin/wg-quick.reserved || sed -i '/add_if$/ {s/^/# /; N; s/\n/&\twireguard-go "$INTERFACE"\n/}' /usr/bin/wg-quick.reserved
|
||||
[ "$KERNEL_OR_WIREGUARD_GO" = 'wireguard-go with reserved' ] && ln -sf /usr/bin/wg-quick.reserved /usr/bin/wg-quick || ln -sf /usr/bin/wg-quick.origin /usr/bin/wg-quick
|
||||
else
|
||||
grep -q '^#[[:space:]]*add_if' /usr/bin/wg-quick || sed -i '/add_if$/ {s/^/# /; N; s/\n/&\twireguard-go "$INTERFACE"\n/}' /usr/bin/wg-quick
|
||||
grep -q '^#[[:space:]]*add_if' /usr/bin/wg-quick.origin || sed -i '/add_if$/ {s/^/# /; N; s/\n/&\twireguard-go "$INTERFACE"\n/}' /usr/bin/wg-quick.origin
|
||||
ln -sf /usr/bin/wg-quick.origin /usr/bin/wg-quick
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
+37
-165
@@ -29,8 +29,8 @@ E[7]="Curren operating system is \$SYS.\\\n The system lower than \$SYSTEM \${MA
|
||||
C[7]="当前操作是 \$SYS\\\n 不支持 \$SYSTEM \${MAJOR[int]} 以下系统,问题反馈:[https://github.com/fscarmen/warp-sh/issues]"
|
||||
E[8]="Install dependence-list:"
|
||||
C[8]="安装依赖列表:"
|
||||
E[9]="Step 3/3: Best MTU found."
|
||||
C[9]="进度 3/3: 已找到最佳 MTU"
|
||||
E[9]="Best MTU found."
|
||||
C[9]="已找到最佳 MTU"
|
||||
E[10]="No suitable solution was found for modifying the warp-go configuration file warp.conf and the script aborted. When you see this message, please send feedback on the bug to:[https://github.com/fscarmen/warp-sh/issues]"
|
||||
C[10]="没有找到适合的方案用于修改 warp-go 配置文件 warp.conf,脚本中止。当你看到此信息,请把该 bug 反馈至:[https://github.com/fscarmen/warp-sh/issues]"
|
||||
E[11]="Warp-go is not installed yet."
|
||||
@@ -131,10 +131,10 @@ E[58]="Attempts to register WARP account..."
|
||||
C[58]="注册 WARP 账户中……"
|
||||
E[59]="Try \${i}"
|
||||
C[59]="第\${i}次尝试"
|
||||
E[60]="Step 1/3: Install dependencies..."
|
||||
C[60]="进度 1/3: 安装系统依赖……"
|
||||
E[61]="Step 2/3: Install warp-go..."
|
||||
C[61]="进度 2/3: 已安装 warp-go"
|
||||
E[60]=""
|
||||
C[60]=""
|
||||
E[61]="Install warp-go..."
|
||||
C[61]="已安装 warp-go"
|
||||
E[62]="Congratulations! WARP \$ACCOUNT_TYPE has been turn on. Total time spent:\$(( end - start )) seconds.\\\n Number of script runs in the day: \$TODAY. Total number of runs: \$TOTAL."
|
||||
C[62]="恭喜!WARP \$ACCOUNT_TYPE 已开启,总耗时: \$(( end - start ))秒\\\n 脚本当天运行次数: \$TODAY,累计运行次数: \$TOTAL"
|
||||
E[63]="Warp-go installation failed. Feedback: [https://github.com/fscarmen/warp-sh/issues]"
|
||||
@@ -332,31 +332,30 @@ check_arch() {
|
||||
check_dependencies() {
|
||||
# 对于 Alpine 和 OpenWrt 系统,升级库并重新安装依赖
|
||||
if [[ "$SYSTEM" =~ Alpine|OpenWrt ]]; then
|
||||
DEPS_CHECK=("ping" "curl" "wget" "grep" "bash" "ip" "tar" "virt-what" "xxd" "openssl")
|
||||
DEPS_INSTALL=("iputils-ping" "curl" "wget" "grep" "bash" "iproute2" "tar" "virt-what" "xxd" "openssl")
|
||||
DEPS_CHECK=("ping" "curl" "wget" "grep" "bash" "ip" "tar" "virt-what")
|
||||
DEPS_INSTALL=("iputils-ping" "curl" "wget" "grep" "bash" "iproute2" "tar" "virt-what")
|
||||
else
|
||||
# 对于三大系统需要的依赖
|
||||
[ "${SYSTEM}" = 'CentOS' ] && ${PACKAGE_INSTALL[int]} vim-common
|
||||
DEPS_CHECK=("ping" "wget" "curl" "systemctl" "ip" "xxd" "openssl")
|
||||
DEPS_INSTALL=("iputils-ping" "wget" "curl" "systemctl" "iproute2" "xxd" "openssl")
|
||||
[ "${SYSTEM}" = 'CentOS' ] && DEPS_INSTALL+=("vim-common") && DEPS_CHECK+=("vim")
|
||||
DEPS_CHECK=("ping" "wget" "curl" "systemctl" "ip")
|
||||
DEPS_INSTALL=("iputils-ping" "wget" "curl" "systemctl" "iproute2")
|
||||
fi
|
||||
|
||||
# 根据系统添加特定的依赖
|
||||
case "$SYSTEM" in
|
||||
Alpine )
|
||||
DEPS_CHECK+=("openrc")
|
||||
DEPS_INSTALL+=("openrc")
|
||||
;;
|
||||
Arch )
|
||||
DEPS_CHECK+=("resolvconf")
|
||||
DEPS_INSTALL+=("openresolv")
|
||||
esac
|
||||
|
||||
for c in "${!DEPS_CHECK[@]}"; do
|
||||
[ ! $(type -p ${DEPS_CHECK[c]}) ] && [[ ! "${DEPS[@]}" =~ "${DEPS_INSTALL[c]}" ]] && DEPS+=(${DEPS_INSTALL[c]})
|
||||
done
|
||||
|
||||
# 检查 JSON 格式化工具
|
||||
if [ -x "$(type -p python3)" ]; then
|
||||
JSON_TOOL="python3 -m json.tool"
|
||||
elif [ -x "$(type -p python)" ]; then
|
||||
JSON_TOOL="python -m json.tool"
|
||||
elif [ -x "$(type -p jq)" ]; then
|
||||
JSON_TOOL="jq"
|
||||
else
|
||||
JSON_TOOL="jq"
|
||||
DEPS+=("jq")
|
||||
fi
|
||||
|
||||
if [ "${#DEPS[@]}" -ge 1 ]; then
|
||||
info "\n $(text 8) ${DEPS[@]} \n"
|
||||
${PACKAGE_UPDATE[int]} >/dev/null 2>&1
|
||||
@@ -402,136 +401,9 @@ warp_api(){
|
||||
fi
|
||||
|
||||
case "$RUN" in
|
||||
register )
|
||||
# 生成 wireguard 公私钥,并且补上 private key
|
||||
if [[ -x "$(type -p openssl)" && -x "$(type -p xxd)" && -x "$(type -p base64)" ]]; then
|
||||
local KEY_PAIR=$(openssl genpkey -algorithm X25519 | openssl pkey -text -noout)
|
||||
local PRIVATE_KEY=$(echo $KEY_PAIR | sed 's/.*priv:\(.*\)pub.*/\1/; s/ //g' | xxd -r -p | base64)
|
||||
local PUBLIC_KEY=$(echo $KEY_PAIR | sed 's/.*pub://; s/ //g'| xxd -r -p | base64)
|
||||
else
|
||||
local WG_API=$(curl -m5 -sSL "https://warp.cloudflare.now.cc/?run=key&format=yaml")
|
||||
local PRIVATE_KEY=$(awk 'NR==2 {print $2}' <<< "$WG_API")
|
||||
local PUBLIC_KEY=$(awk 'NR==1 {print $2}' <<< "$WG_API")
|
||||
fi
|
||||
|
||||
if grep -q '.' <<< "$PRIVATE_KEY" && grep -q '.' <<< "$PUBLIC_KEY"; then
|
||||
local INSTALL_ID=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 22)
|
||||
local FCM_TOKEN="${INSTALL_ID}:APA91b$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 134)"
|
||||
|
||||
# 由于某些 IP 存在被限制注册,所以使用不停的注册来处理,超过一定次数则使用预设账户
|
||||
until grep -q 'account' <<< "$ACCOUNT"; do
|
||||
((REGISTER_ERROR_TIME++))
|
||||
if [ "$REGISTER_ERROR_TIME" -gt 30 ]; then
|
||||
break
|
||||
elif [ "$REGISTER_ERROR_TIME" -gt 1 ]; then
|
||||
sleep 5
|
||||
fi
|
||||
local ACCOUNT=$(curl --request POST 'https://api.cloudflareclient.com/v0a2158/reg' \
|
||||
--silent \
|
||||
--location \
|
||||
--tlsv1.3 \
|
||||
--header 'User-Agent: okhttp/3.12.1' \
|
||||
--header 'CF-Client-Version: a-6.10-2158' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{"key":"'${PUBLIC_KEY}'","install_id":"'${INSTALL_ID}'","fcm_token":"'${FCM_TOKEN}'","tos":"'$(date +"%Y-%m-%dT%H:%M:%S.000Z")'","model":"PC","serial_number":"'${INSTALL_ID}'","locale":"zh_CN"}')
|
||||
done
|
||||
|
||||
if grep -q 'account' <<< "$ACCOUNT"; then
|
||||
local CLIENT_ID=$(sed 's/.*"client_id":"\([^\"]\+\)\".*/\1/' <<<"$ACCOUNT")
|
||||
local RESERVED=$(echo "$CLIENT_ID" | base64 -d | xxd -p | fold -w2 | while read HEX; do printf '%d ' "0x${HEX}"; done | awk '{print "["$1", "$2", "$3"]"}')
|
||||
|
||||
$JSON_TOOL <<< "$ACCOUNT" 2>&1 | sed "/\"key\"/a\ \"private_key\": \"$PRIVATE_KEY\"," | sed "/\"client_id\"/a\ \"reserved\": $RESERVED,"
|
||||
else
|
||||
echo '{
|
||||
"id": "b0fe9b24-3396-486e-a12d-c194dbbb7bfb",
|
||||
"type": "a",
|
||||
"model": "PC",
|
||||
"name": "",
|
||||
"key": "rizJSrjeCO51ck8Rmj9YwstFnf6M9rJKZIXFQo3y8j8=",
|
||||
"private_key": "hTk06uwwXhZx3RVqtug3MQ0RSodzdM/U5z/M5NIbh4c=",
|
||||
"account": {
|
||||
"id": "5a43e4b3-2e13-46b9-9437-2abe55cd5f4b",
|
||||
"account_type": "free",
|
||||
"created": "2025-12-02T16:44:10.752518443Z",
|
||||
"updated": "2025-12-02T16:44:10.752518443Z",
|
||||
"premium_data": 0,
|
||||
"quota": 0,
|
||||
"usage": 0,
|
||||
"warp_plus": true,
|
||||
"referral_count": 0,
|
||||
"referral_renewal_countdown": 0,
|
||||
"role": "child",
|
||||
"license": "36L7Pg9E-j6Jp2x04-I40UQ39C",
|
||||
"ttl": "2026-03-02T16:44:10.752514723Z"
|
||||
},
|
||||
"config": {
|
||||
"client_id": "lzaY",
|
||||
"reserved": [
|
||||
151,
|
||||
54,
|
||||
152
|
||||
],
|
||||
"peers": [
|
||||
{
|
||||
"public_key": "bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=",
|
||||
"endpoint": {
|
||||
"v4": "162.159.192.5:0",
|
||||
"v6": "[2606:4700:d0::a29f:c005]:0",
|
||||
"host": "engage.cloudflareclient.com:2408",
|
||||
"ports": [
|
||||
2408,
|
||||
500,
|
||||
1701,
|
||||
4500
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"interface": {
|
||||
"addresses": {
|
||||
"v4": "172.16.0.2",
|
||||
"v6": "2606:4700:110:8921:bf06:c4d7:40b7:8afd"
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"http_proxy": "172.16.0.1:2480"
|
||||
}
|
||||
},
|
||||
"token": "50d988c2-b5fb-c829-42dd-a33a960ea734",
|
||||
"warp_enabled": false,
|
||||
"waitlist_enabled": false,
|
||||
"created": "2025-12-02T16:44:10.327083841Z",
|
||||
"updated": "2025-12-02T16:44:10.327083841Z",
|
||||
"tos": "2025-12-02T16:44:10.272Z",
|
||||
"place": 0,
|
||||
"locale": "zh-CN",
|
||||
"enabled": true,
|
||||
"install_id": "095iylvdl1trz7ukonr00g",
|
||||
"fcm_token": "095iylvdl1trz7ukonr00g:APA91ba32nwi5zphdi3ercafxodyjr6iwlrrgb919l2gcm4h5irun8y8nsuhbdmc0kufcxhopvonqql4gllld8nsjaavi17hf7yfl5qhdpz03oq4u69ngu0s5hyo6wxiy4luk8xeenf1",
|
||||
"serial_number": "095iylvdl1trz7ukonr00g",
|
||||
"policy": {
|
||||
"always_include": [
|
||||
{
|
||||
"ip": "162.159.197.4"
|
||||
},
|
||||
{
|
||||
"ip": "2606:4700:102::4"
|
||||
}
|
||||
],
|
||||
"always_exclude": [
|
||||
{
|
||||
"ip": "162.159.197.3"
|
||||
},
|
||||
{
|
||||
"ip": "2606:4700:102::3"
|
||||
}
|
||||
],
|
||||
"post_quantum": "enabled_with_downgrades",
|
||||
"tunnel_protocol": "masque"
|
||||
}
|
||||
}'
|
||||
fi
|
||||
fi
|
||||
register )
|
||||
local ACCOUNT=$(curl --retry 500 --retry-delay 1 --max-time 2 --silent --location --fail "https://warp.cloudflare.nyc.mn/?run=register")
|
||||
grep -q '"id"' <<< "$ACCOUNT" && echo "$ACCOUNT"
|
||||
;;
|
||||
cancel )
|
||||
# 只保留 Teams 或者预设账户,删除其他账户
|
||||
@@ -1106,8 +978,19 @@ export_file() {
|
||||
cat /opt/warp-go/wgcf.conf
|
||||
echo -e "\n\n"
|
||||
|
||||
# 检查 JSON 格式化工具
|
||||
if [ -x "$(type -p python3)" ]; then
|
||||
local JSON_TOOL="| python3 -m json.tool"
|
||||
elif [ -x "$(type -p python)" ]; then
|
||||
local JSON_TOOL="| python -m json.tool"
|
||||
elif [ -x "$(type -p json_pp)" ]; then
|
||||
local JSON_TOOL="| json_pp"
|
||||
elif [ -x "$(type -p jq)" ]; then
|
||||
local JSON_TOOL="| jq"
|
||||
fi
|
||||
|
||||
info " $(text 54) "
|
||||
cat /opt/warp-go/singbox.json | $JSON_TOOL
|
||||
eval "cat /opt/warp-go/singbox.json $JSON_TOOL"
|
||||
echo -e "\n\n"
|
||||
}
|
||||
|
||||
@@ -1229,17 +1112,6 @@ EOF
|
||||
# 优先使用 IPv4 /IPv6 网络
|
||||
{ stack_priority; }&
|
||||
|
||||
# 根据系统选择需要安装的依赖, 安装一些必要的网络工具包
|
||||
info "\n $(text 60) \n"
|
||||
|
||||
case "$SYSTEM" in
|
||||
Alpine )
|
||||
${PACKAGE_INSTALL[int]} openrc
|
||||
;;
|
||||
Arch )
|
||||
${PACKAGE_INSTALL[int]} openresolv
|
||||
esac
|
||||
|
||||
wait
|
||||
info "\n $(text 9) \n"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user