support fallback website

This commit is contained in:
root
2022-05-22 08:21:04 +00:00
parent 251a7f9e8e
commit 567845db7a
7 changed files with 146 additions and 51 deletions

View File

@@ -1,58 +1,16 @@
#!/bin/sh
cat << EOF > /etc/v2ray/config.json
{
"policy": {
"levels": {
"0": {
"handshake": 5,
"connIdle": 300,
"uplinkOnly": 2,
"downlinkOnly": 5,
"statsUserUplink": false,
"statsUserDownlink": false,
"bufferSize": 10240
}
},
"system": {
"statsInboundUplink": false,
"statsInboundDownlink": false,
"statsOutboundUplink": false,
"statsOutboundDownlink": false
}
},
"inbounds": [
{
"port": $PORT,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "$UUID",
"level": 0
}
],
"decryption": "none"
},
"streamSettings": {
"network": "ws",
"security": "none"
}
}
],
"outbounds": [
{
"protocol": "freedom"
}
]
}
EOF
envsubst < /root/config.json.tp > /root/config.json
envsubst '\$PORT' < /root/nginx.template.conf > /root/nginx.conf
# Run V2Ray
if [[ $TUNNEL_TOKEN ]]; then
echo 'has tunnel token, run cloudflared tunnel'
/usr/bin/v2ray -config /etc/v2ray/config.json & /root/cloudflared tunnel --no-autoupdate run --token $TUNNEL_TOKEN
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O /root/cloudflared
chmod +x /root/cloudflared
/usr/bin/v2ray -config /root/config.json & /root/cloudflared tunnel --no-autoupdate run --token $TUNNEL_TOKEN & nginx -c /root/nginx.conf -g 'daemon off;'
else
/usr/bin/v2ray -config /etc/v2ray/config.json
/usr/bin/v2ray -config /root/config.json & nginx -c /root/nginx.conf -g 'daemon off;'
fi