diff --git a/menu.sh b/menu.sh index 17aa0d6..5a9bdc1 100644 --- a/menu.sh +++ b/menu.sh @@ -200,8 +200,8 @@ T[E95]="Client works with non-WARP IPv4. The script is aborted. Feedback: [https T[C95]="Client 在非 WARP IPv4 下才能工作正常,脚本中止,问题反馈:[https://github.com/fscarmen/warp/issues]" T[E96]="Client connecting failure. It may be a CloudFlare IPv4." T[C96]="Client 连接失败,可能是 CloudFlare IPv4." -T[E97]="It is a WARP+ account already. Update is aborted." -T[C97]="已经是 WARP+ 账户,不需要升级" +T[E97]="It is a WARP+ account already. Quota: \${Quota}. Update is aborted." +T[C97]="已经是 WARP+ 账户,剩余流量: \${Quota},不需要升级" T[E98]="Uninstall WirePorxy was complete." T[C98]="WirePorxy 卸载成功" T[E99]="WireProxy is connected" @@ -1691,10 +1691,14 @@ wireproxy_solution(){ # 查 WARP+ 余额流量接口 check_quota(){ - ACCESS_TOKEN=$(grep 'access_token' /etc/wireguard/wgcf-account.toml | cut -d \" -f2) - DEVICE_ID=$(grep 'device_id' /etc/wireguard/wgcf-account.toml | cut -d \" -f2) - API=$(curl -s "https://api.cloudflareclient.com/v0a884/reg/$DEVICE_ID" -H "User-Agent: okhttp/3.12.1" -H "Authorization: Bearer $ACCESS_TOKEN") - QUOTA=$(grep -oP '"quota":\K\d+' <<< $API) + if [ $CHECK_TYPE = 1 ]; then + QUOTA=$(grep -oP 'Quota: \K\d+' <<< $CLI_ACCOUNT) + else + ACCESS_TOKEN=$(grep 'access_token' /etc/wireguard/wgcf-account.toml | cut -d \" -f2) + DEVICE_ID=$(grep 'device_id' /etc/wireguard/wgcf-account.toml | cut -d \" -f2) + API=$(curl -s "https://api.cloudflareclient.com/v0a884/reg/$DEVICE_ID" -H "User-Agent: okhttp/3.12.1" -H "Authorization: Bearer $ACCESS_TOKEN") + QUOTA=$(grep -oP '"quota":\K\d+' <<< $API) + fi [[ $QUOTA -gt 10000000000000 ]] && QUOTA="$((QUOTA/1000000000000)) TB" || QUOTA="$((QUOTA/1000000000)) GB" } @@ -1730,7 +1734,8 @@ update(){ client_account(){ [[ $ARCHITECTURE = arm64 ]] && red " ${T[${L}101]} " && exit 1 - [[ $(warp-cli --accept-tos account) =~ Limited ]] && red " ${T[${L}97]} " && exit 1 + CLI_ACCOUNT=$(warp-cli --accept-tos account) + [[ $CLI_ACCOUNT =~ Limited ]] && CHECK_TYPE=1 && check_quota && red " $(eval echo ${T[${L}97]}) " && exit 1 update_license warp-cli --accept-tos set-license "$LICENSE" >/dev/null 2>&1; sleep 1 ACCOUNT=$(warp-cli --accept-tos account 2>/dev/null)