diff --git a/menu.sh b/menu.sh index 566a774..3bf3d1b 100644 --- a/menu.sh +++ b/menu.sh @@ -122,8 +122,8 @@ T[E56]="The current Netflix region is \$REGION. Confirm press [y] . If you want T[C56]="当前 Netflix 地区是:\$REGION,需要解锁当前地区请按 y , 如需其他地址请输入两位地区简写 \(如 hk ,sg,默认:\$REGION\):" T[E57]="The target quota you want to get. The unit is GB, the default value is 10:" T[C57]="你希望获取的目标流量值,单位为 GB,输入数字即可,默认值为10:" -T[E58]="WARP+ or Teams account is working now. No need to upgrade." -T[C58]="已经是 WARP+ 或者 Teams 账户,不需要升级" +T[E58]="WARP+ or Teams account is working now. Quota: \${Quota}. No need to upgrade." +T[C58]="已经是 WARP+ 或者 Teams 账户,剩余流量: \${Quota},不需要升级" T[E59]="Cannot find the account file: /etc/wireguard/wgcf-account.toml, you can reinstall with the WARP+ License" T[C59]="找不到账户文件:/etc/wireguard/wgcf-account.toml,可以卸载后重装,输入 WARP+ License" T[E60]="Cannot find the configuration file: /etc/wireguard/wgcf.conf, you can reinstall with the WARP+ License" @@ -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. Quota: \${Quota}. Update is aborted." -T[C97]="已经是 WARP+ 账户,剩余流量: \${Quota},不需要升级" +T[E97]="It is a WARP+ account already. Update is aborted." +T[C97]="已经是 WARP+ 账户,不需要升级" T[E98]="Uninstall WirePorxy was complete." T[C98]="WirePorxy 卸载成功" T[E99]="WireProxy is connected" @@ -1689,10 +1689,19 @@ wireproxy_solution(){ esac } +# 查 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) + [[ $QUOTA -gt 10000000000000 ]] && QUOTA="$((QUOTA/1000000000000)) TB" || QUOTA="$((QUOTA/1000000000)) GB" + } + # 免费 WARP 账户升级 WARP+ 账户 update(){ wgcf_account(){ - [[ $TRACE4$TRACE6 =~ plus ]] && red " ${T[${L}58]} " && exit 1 + [[ $TRACE4$TRACE6 =~ plus ]] && check_quota && red " ${T[${L}58]} " && exit 1 [[ ! -e /etc/wireguard/wgcf-account.toml ]] && red " ${T[${L}59]} " && exit 1 [[ ! -e /etc/wireguard/wgcf.conf ]] && red " ${T[${L}60]} " && exit 1 @@ -1721,14 +1730,7 @@ update(){ client_account(){ [[ $ARCHITECTURE = arm64 ]] && red " ${T[${L}101]} " && exit 1 - if [[ $(warp-cli --accept-tos account) =~ Limited ]]; then - 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) - [[ $QUOTA -gt 10000000000000 ]] && QUOTA="$((QUOTA/1000000000000)) TB" || QUOTA="$((QUOTA/1000000000)) GB" - red " ${T[${L}97]} " && exit 1 - fi + [[ $(warp-cli --accept-tos account) =~ Limited ]] && red " ${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) @@ -1743,7 +1745,7 @@ update(){ } wireproxy_account(){ - [[ $(eval echo "\$(curl -sx socks5h://localhost:$(ss -nltp | grep wireproxy | grep -oP '127.0*\S+' | cut -d: -f2) https://www.cloudflare.com/cdn-cgi/trace)") =~ plus ]] && red " ${T[${L}58]} " && exit 1 + [[ $(eval echo "\$(curl -sx socks5h://localhost:$(ss -nltp | grep wireproxy | grep -oP '127.0*\S+' | cut -d: -f2) https://www.cloudflare.com/cdn-cgi/trace)") =~ plus ]] && check_quota [[ ! -e /etc/wireguard/wgcf-account.toml ]] && red " ${T[${L}59]} " && exit 1 [[ ! -e /etc/wireguard/wgcf.conf ]] && red " ${T[${L}60]} " && exit 1