Skip to content
This repository was archived by the owner on Aug 22, 2021. It is now read-only.

Commit 135cdd4

Browse files
committed
check_ip; vmess aid; vless uuid
1 parent a946f94 commit 135cdd4

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/v2gun.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,10 @@ build_web() {
152152
checkIP() {
153153
local realIP4="$(curl -s `curl -s https://raw.githubusercontent.com/phlinhng/v2ray-tcp-tls-web/${branch}/custom/ip4_api`)"
154154
local realIP6="$(curl -s `curl -s https://raw.githubusercontent.com/phlinhng/v2ray-tcp-tls-web/${branch}/custom/ip6_api`)"
155-
local resolvedIP44="$(ping $1 -c 1 | head -n 1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)"
156-
local resolvedIP46="$(ping6 $1 -c 1 | head -n 1 | grep -oE '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' | head -n 1)"
157-
local resolvedIP64="$(ping $1 -c 1 | head -n 1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)"
158-
local resolvedIP66="$(ping6 $1 -c 1 | head -n 1 | grep -oE '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' | head -n 1)"
155+
local resolvedIP4="$(ping $1 -c 1 | head -n 1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)"
156+
local resolvedIP6="$(ping6 $1 -c 1 | head -n 1 | grep -oE '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' | head -n 1)"
159157

160-
if [[ "${realIP4}" == "${resolvedIP44}" ]] || [[ "${realIP4}" == "${resolvedIP46}" ]] || [[ "${realIP4}" == "${resolvedIP64}" ]] || [[ "${realIP4}" == "${resolvedIP66}" ]] || [[ "${realIP6}" == "${resolvedIP44}" ]] || [[ "${realIP6}" == "${resolvedIP46}" ]] || [[ "${realIP6}" == "${resolvedIP64}" ]] || [[ "${realIP6}" == "${resolvedIP66}" ]]; then
158+
if [[ "${realIP4}" == "${resolvedIP4}" ]] || [[ "${realIP6}" == "${resolvedIP6}" ]]; then
161159
return 0
162160
else
163161
return 1
@@ -180,8 +178,9 @@ show_links() {
180178
echo ""
181179

182180
colorEcho ${BLUE} "VMess (新版分享格式)"
183-
local uri_vmess_cf="ws+tls:${uuid}@${cf_node}:443/?path=`urlEncode "${path}wss"`&host=${sni}&tlsAllowInsecure=false&tlsServerName=${sni}#`urlEncode "${sni} (WSS)"`"
184-
local uri_vmess="ws+tls:${uuid}@${sni}:443/?path=`urlEncode "${path}wss"`&host=${sni}&tlsAllowInsecure=false&tlsServerName=${sni}#`urlEncode "${sni} (WSS)"`"
181+
# https://github.com/v2ray/discussion/issues/720
182+
local uri_vmess_cf="ws+tls:${uuid}-1@${cf_node}:443/?path=`urlEncode "${path}wss"`&host=${sni}&tlsAllowInsecure=false&tlsServerName=${sni}#`urlEncode "${sni} (WSS)"`"
183+
local uri_vmess="ws+tls:${uuid}-1@${sni}:443/?path=`urlEncode "${path}wss"`&host=${sni}&tlsAllowInsecure=false&tlsServerName=${sni}#`urlEncode "${sni} (WSS)"`"
185184
printf "%s\n%s\n" "vmess://${uri_vmess_cf}" "vmess://${uri_vmess}"
186185
echo ""
187186

@@ -512,10 +511,11 @@ get_v2ray() {
512511
}
513512

514513
set_v2ray() {
515-
# $1: uuid for all (in trojan and ss uuid == passowrd)
514+
# $1: uuid for all except vless ws (in trojan and ss uuid == passowrd)
516515
# $2: base path
517516
# $3: sni
518517
# $4: url of cf node
518+
# $5: uuid for vless ws
519519
# 3564: trojan, 3565: ss, 3566: vmess+wss, 3567: vless+wss, 3568: trojan+ws
520520
${sudoCmd} cat > "/usr/local/etc/v2ray/05_inbounds_vless.json" <<-EOF
521521
{
@@ -552,7 +552,8 @@ set_v2ray() {
552552
},
553553
{
554554
"path": "$2tj",
555-
"dest": 3568
555+
"dest": 3568,
556+
"xver": 1
556557
}
557558
]
558559
},
@@ -648,7 +649,7 @@ EOF
648649
"settings": {
649650
"clients": [
650651
{
651-
"id": "$1"
652+
"id": "$5"
652653
}
653654
],
654655
"decryption": "none"
@@ -885,10 +886,11 @@ install_v2ray() {
885886
(crontab -l 2>/dev/null; echo "0 7 * * * wget -q https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/geosite.dat -O /usr/local/share/v2ray/geosite.dat >/dev/null >/dev/null") | ${sudoCmd} crontab -
886887

887888
local uuid="$(cat '/proc/sys/kernel/random/uuid')"
889+
local uuid_vless_ws="$(cat '/proc/sys/kernel/random/uuid')"
888890
local path="/$(cat '/proc/sys/kernel/random/uuid' | sed -e 's/-//g' | tr '[:upper:]' '[:lower:]' | head -c $((10+$RANDOM%10)))"
889891
local cf_node="$(curl -s https://raw.githubusercontent.com/phlinhng/v2ray-tcp-tls-web/${branch}/custom/cf_node)"
890892

891-
set_v2ray "${uuid}" "${path}" "${V2_DOMAIN}" "${cf_node}"
893+
set_v2ray "${uuid}" "${path}" "${V2_DOMAIN}" "${cf_node}" "${uuid_vless_ws}"
892894

893895
${sudoCmd} $(which mkdir) -p /etc/ssl/v2ray
894896

0 commit comments

Comments
 (0)