mirror of
https://gitlab.com/fscarmen/warp.git
synced 2026-06-15 03:25:42 +08:00
Dealing with ip being restricted from registering.
Former-commit-id: cbd866a9993895e53583fe2ebd61a7d904d2ff51
This commit is contained in:
+3
-3
@@ -31,7 +31,7 @@ Synchronize applications:
|
||||
- echo "Synchronize wgcf"
|
||||
- |
|
||||
WGCF_NOW=$(wget -qO- https://gitlab.com/$CI_PROJECT_PATH/-/raw/main/docker.sh | grep 'latest=${latest' | cut -d \' -f2)
|
||||
WGCF_LATEST=$(wget -qO- "https://api.github.com/repos/ViRb3/wgcf/releases/latest" | grep "tag_name" | head -n 1 | cut -d : -f2 | sed 's/[ \"v,]//g')
|
||||
WGCF_LATEST=$(wget -qO- "https://api.github.com/repos/ViRb3/wgcf/releases/latest" | awk -F [v\"] '/tag_name/{print $5}')
|
||||
|
||||
if [ "$WGCF_LATEST" != "$WGCF_NOW" ]; then
|
||||
[ ! -d $WGCF_DIR ] && mkdir -p $WGCF_DIR
|
||||
@@ -153,11 +153,11 @@ Mirror to Bitbucket:
|
||||
|
||||
# Mirror to Gitlab group:
|
||||
# stage: Mirror to others git repositories
|
||||
#
|
||||
#
|
||||
# variables:
|
||||
# GIT_USER_NAME: $GITLAB_USER_NAME
|
||||
# GIT_SSH_COMMAND: "ssh -v -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -l $GIT_USER_NAME"
|
||||
# GIT_REPO: "Gitlab group"
|
||||
# TARGET_REPO_URL: git@gitlab.com:ProjectWARP/warp-script.git
|
||||
#
|
||||
#
|
||||
# <<: *mirror_script
|
||||
@@ -67,27 +67,34 @@ registe_account() {
|
||||
public_key=$(wg pubkey <<< "$private_key")
|
||||
else
|
||||
wg_api=$(curl -sSL https://fscarmen.cloudflare.now.cc/wg)
|
||||
private_key=$(echo "$wg_api" | awk 'NR==2 {print $2}')
|
||||
public_key=$(echo "$wg_api" | awk 'NR==1 {print $2}')
|
||||
private_key=$(awk 'NR==2 {print $2}' <<< "$wg_api")
|
||||
public_key=$(awk 'NR==1 {print $2}' <<< "$wg_api")
|
||||
fi
|
||||
|
||||
registe_path=${registe_path:-warp-account.conf}
|
||||
[[ "$(dirname "$registe_path")" != '.' ]] && mkdir -p $(dirname "$registe_path")
|
||||
install_id=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 22)
|
||||
fcm_token="${install_id}:APA91b$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 134)"
|
||||
|
||||
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' \
|
||||
--header "Cf-Access-Jwt-Assertion: ${team_token}" \
|
||||
--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"}' \
|
||||
| python3 -m json.tool | sed "/\"account_type\"/i\ \"private_key\": \"$private_key\"," > $registe_path
|
||||
if [[ -n "$private_key" && -n "$public_key" ]]; then
|
||||
install_id=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 22)
|
||||
fcm_token="${install_id}:APA91b$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 134)"
|
||||
|
||||
[[ ! -s $registe_path || $(grep 'error' $registe_path) ]] && { rm -f $registe_path; exit 1; } || { cat $registe_path; exit 0; }
|
||||
# 由于某些 IP 存在被限制注册,所以使用不停的注册来处理
|
||||
until grep -q 'account' <<< "$account"; do
|
||||
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' \
|
||||
--header "Cf-Access-Jwt-Assertion: ${team_token}" \
|
||||
--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
|
||||
|
||||
account=$(python3 -m json.tool <<< "$account" 2>&1 | sed "/\"account_type\"/i\ \"private_key\": \"$private_key\",")
|
||||
echo "$account" > $registe_path 2>&1
|
||||
fi
|
||||
[[ ! -s $registe_path || $(grep 'error' $registe_path) ]] && { rm -f $registe_path; exit 1; } || { cat $registe_path; exit 0; }
|
||||
}
|
||||
|
||||
# 获取设备信息
|
||||
@@ -101,7 +108,7 @@ device_information() {
|
||||
--header 'CF-Client-Version: a-6.10-2158' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header "Authorization: Bearer ${token}" \
|
||||
| python3 -m json.tool
|
||||
| python3 -m json.tool | sed "/\"warp_enabled\"/i\ \"token\": \"${token}\","
|
||||
}
|
||||
|
||||
# 获取账户APP信息
|
||||
|
||||
@@ -1171,7 +1171,7 @@ net() {
|
||||
local NO_OUTPUT="$1"
|
||||
unset IP4 IP6 WAN4 WAN6 COUNTRY4 COUNTRY6 ASNORG4 ASNORG6 WARPSTATUS4 WARPSTATUS6 TYPE QUOTA
|
||||
[[ ! $(type -p wg-quick) || ! -e /etc/wireguard/warp.conf ]] && error " $(text 10) "
|
||||
local i=1; local j=3
|
||||
local i=1; local j=5
|
||||
hint " $(text 11)\n $(text 12) "
|
||||
[ "$SYSTEM" != Alpine ] && [[ $(systemctl is-active wg-quick@warp) != 'active' ]] && wg-quick down warp >/dev/null 2>&1
|
||||
${SYSTEMCTL_START[int]} >/dev/null 2>&1
|
||||
@@ -1941,7 +1941,7 @@ install() {
|
||||
{
|
||||
# 如安装 WireProxy ,尽量下载官方的最新版本,如官方 WireProxy 下载不成功,将使用 cdn,以更好的支持双栈和大陆 VPS。并添加执行权限
|
||||
if [ "$PUFFERFFISH" = 1 ]; then
|
||||
wireproxy_latest=$(wget --no-check-certificate -qO- -T1 -t1 $STACK "https://api.github.com/repos/pufferffish/wireproxy/releases/latest" | grep "tag_name" | head -n 1 | cut -d : -f2 | sed 's/[ \"v,]//g')
|
||||
wireproxy_latest=$(wget --no-check-certificate -qO- -T1 -t1 $STACK "https://api.github.com/repos/pufferffish/wireproxy/releases/latest" | awk -F [v\"] '/tag_name/{print $5; exit}')
|
||||
wireproxy_latest=${wireproxy_latest:-'1.0.6'}
|
||||
wget --no-check-certificate -T10 -t1 $STACK -O wireproxy.tar.gz https://${CDN}github.com/pufferffish/wireproxy/releases/download/v"$wireproxy_latest"/wireproxy_linux_"$ARCHITECTURE".tar.gz ||
|
||||
wget --no-check-certificate $STACK -O wireproxy.tar.gz https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/wireproxy/wireproxy_linux_"$ARCHITECTURE".tar.gz
|
||||
@@ -1951,57 +1951,26 @@ install() {
|
||||
|
||||
# 注册 WARP 账户 ( warp-account.conf 使用默认值加快速度)。如有 WARP+ 账户,修改 license 并升级,并把设备名等信息保存到 /etc/wireguard/info.log
|
||||
mkdir -p /etc/wireguard/ >/dev/null 2>&1
|
||||
local REGISTE_TIME=0
|
||||
until [[ -e /etc/wireguard/warp-account.conf || "$REGISTE_TIME" -eq 50 ]]; do
|
||||
bash <(curl -m5 -sSL https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/api.sh | sed 's#cat $registe_path; ##') --registe --file /etc/wireguard/warp-account.conf 2>/dev/null && break
|
||||
(( REGISTE_TIME++ ))
|
||||
done
|
||||
bash <(curl -m5 -sSL https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/api.sh | sed 's#cat $registe_path; ##') --registe --file /etc/wireguard/warp-account.conf 2>/dev/null
|
||||
|
||||
# 注册失败达 50 次,给予一个免费账户。否则根据是否有 License 来升级
|
||||
if [ "$REGISTE_TIME" -eq 100 ]; then
|
||||
[ ! -d /etc/wireguard ] && mkdir -p /etc/wireguard
|
||||
cat > /etc/wireguard/warp-account.conf <<EOF
|
||||
{
|
||||
"id":"317b5a76-3da1-469f-88d6-c3b261da9f10",
|
||||
"name":"",
|
||||
"account":{
|
||||
"private_key":"CNUysnWWJmFGTkqYtg/wpDfURUWvHB8+U1FLlVAIB0Q=",
|
||||
"account_type":"free",
|
||||
"license":"n01H3Cf4-3Za40C7b-5qOs0c42"
|
||||
},
|
||||
"config":{
|
||||
"client_id":"9URL",
|
||||
"interface":{
|
||||
"addresses":{
|
||||
"v4":"172.16.0.2",
|
||||
"v6":"2606:4700:110:8d4e:cef9:30c2:6d4a:f97b"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
[ -s /etc/wireguard/warp-account.conf ] && warning "\n $(text 107) \n"
|
||||
elif [ -n "$LICENSE" ]; then
|
||||
if [ -s /etc/wireguard/warp-account.conf ]; then
|
||||
local UPDATE_RESULT=$(bash <(curl -m5 -sSL https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/api.sh) --file /etc/wireguard/warp-account.conf --license $LICENSE)
|
||||
if grep -q '"warp_plus": true' <<< "$UPDATE_RESULT"; then
|
||||
[ -n "$NAME" ] && bash <(curl -m5 -sSL https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/api.sh) --file /etc/wireguard/warp-account.conf --name $NAME >/dev/null 2>&1
|
||||
sed -i "s#\([ ]\+\"license\": \"\).*#\1$LICENSE\"#g; s#\"account_type\".*#\"account_type\": \"limited\",#g; s#\([ ]\+\"name\": \"\).*#\1$NAME\"#g" /etc/wireguard/warp-account.conf
|
||||
echo "$LICENSE" > /etc/wireguard/license
|
||||
echo -e "Device name : $NAME" > /etc/wireguard/info.log
|
||||
elif grep -q 'Invalid license' <<< "$UPDATE_RESULT"; then
|
||||
warning "\n $(text 169) \n"
|
||||
elif grep -q 'Too many connected devices.' <<< "$UPDATE_RESULT"; then
|
||||
warning "\n $(text 36) \n"
|
||||
else
|
||||
warning "\n $(text 42) \n"
|
||||
fi
|
||||
# 有 License 来升级账户
|
||||
if [ -n "$LICENSE" ]; then
|
||||
local UPDATE_RESULT=$(bash <(curl -m5 -sSL https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/api.sh) --file /etc/wireguard/warp-account.conf --license $LICENSE)
|
||||
if grep -q '"warp_plus": true' <<< "$UPDATE_RESULT"; then
|
||||
[ -n "$NAME" ] && bash <(curl -m5 -sSL https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/api.sh) --file /etc/wireguard/warp-account.conf --name $NAME >/dev/null 2>&1
|
||||
sed -i "s#\([ ]\+\"license\": \"\).*#\1$LICENSE\"#g; s#\"account_type\".*#\"account_type\": \"limited\",#g; s#\([ ]\+\"name\": \"\).*#\1$NAME\"#g" /etc/wireguard/warp-account.conf
|
||||
echo "$LICENSE" > /etc/wireguard/license
|
||||
echo -e "Device name : $NAME" > /etc/wireguard/info.log
|
||||
elif grep -q 'Invalid license' <<< "$UPDATE_RESULT"; then
|
||||
warning "\n $(text 169) \n"
|
||||
elif grep -q 'Too many connected devices.' <<< "$UPDATE_RESULT"; then
|
||||
warning "\n $(text 36) \n"
|
||||
else
|
||||
warning " $(text 106) "
|
||||
warning "\n $(text 42) \n"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 生成 WireGuard 配置文件 (warp.conf),如果注册一直不成功,即使用共享账户
|
||||
# 生成 WireGuard 配置文件 (warp.conf)
|
||||
if [ -s /etc/wireguard/warp-account.conf ]; then
|
||||
cat > /etc/wireguard/warp.conf <<EOF
|
||||
[Interface]
|
||||
@@ -3225,4 +3194,4 @@ g )
|
||||
;;
|
||||
* )
|
||||
menu
|
||||
esac
|
||||
esac
|
||||
+4
-6
@@ -402,12 +402,10 @@ check_install() {
|
||||
STATUS=0
|
||||
{
|
||||
# 预下载 warp-go,并添加执行权限,如因 gitlab 接口问题未能获取,默认 v1.0.8
|
||||
latest=$(wget -qO- -T1 -t1 https://gitlab.com/api/v4/projects/ProjectWARP%2Fwarp-go/releases | awk -F '"' '{for (i=0; i<NF; i++) if ($i=="tag_name") {print $(i+2); exit}}' | sed "s/v//")
|
||||
latest=$(wget -qO- -T2 -t1 https://gitlab.com/api/v4/projects/ProjectWARP%2Fwarp-go/releases | awk -F '"' '{for (i=0; i<NF; i++) if ($i=="tag_name") {print $(i+2); exit}}' | sed "s/v//")
|
||||
latest=${latest:-'1.0.8'}
|
||||
wget --no-check-certificate -qO /tmp/warp-go.tar.gz https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/warp-go/warp-go_"$latest"_linux_"$ARCHITECTURE".tar.gz
|
||||
tar xzf /tmp/warp-go.tar.gz -C /tmp/ warp-go
|
||||
wget --no-check-certificate -T5 -qO- /tmp/warp-go.tar.gz https://${CDN}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
|
||||
rm -f /tmp/warp-go.tar.gz
|
||||
}&
|
||||
fi
|
||||
}
|
||||
@@ -624,7 +622,7 @@ uninstall() {
|
||||
# 同步脚本至最新版本
|
||||
ver() {
|
||||
mkdir -p /tmp; rm -f /tmp/warp-go.sh
|
||||
wget -O /tmp/warp-go.sh https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/warp-go.sh
|
||||
wget -T2 -O /tmp/warp-go.sh https://${CDN}gitlab.com/fscarmen/warp/-/raw/main/warp-go.sh
|
||||
if [ -s /tmp/warp-go.sh ]; then
|
||||
mv /tmp/warp-go.sh /opt/warp-go/
|
||||
chmod +x /opt/warp-go/warp-go.sh
|
||||
@@ -1226,7 +1224,7 @@ EOF
|
||||
chmod +x /opt/warp-go/NonGlobalUp.sh /opt/warp-go/NonGlobalDown.sh
|
||||
|
||||
info "\n $(text 61) \n"
|
||||
}&
|
||||
}
|
||||
|
||||
# 对于 IPv4 only VPS 开启 IPv6 支持
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user