Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
feat: add xtls-rprx-vision
Browse files Browse the repository at this point in the history
  • Loading branch information
reeceyng committed Dec 4, 2022
1 parent fe8aca4 commit 4a55c2d
Showing 1 changed file with 125 additions and 70 deletions.
195 changes: 125 additions & 70 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ initVar() {

# 1.xray-core安装
# 2.v2ray-core 安装
# 3.v2ray-core[xtls] 安装
# 3.xray-core预览版安装
coreInstallType=

# 核心安装path
Expand Down Expand Up @@ -197,6 +197,9 @@ initVar() {
# 是否为预览版
prereleaseStatus=false

# xtls是否使用vision
xtlsRprxVision=

# ssl类型
sslType=

Expand Down Expand Up @@ -270,31 +273,30 @@ readInstallType() {
# 不带XTLS的v2ray-core
coreInstallType=2
ctlPath=/etc/v2ray-agent/v2ray/v2ctl
elif grep </etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json -q '"security": "xtls"'; then
# 带XTLS的v2ray-core
ctlPath=/etc/v2ray-agent/v2ray/v2ctl
coreInstallType=3
fi
fi
fi

if [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]]; then
# 这里检测xray-core
if [[ -d "/etc/v2ray-agent/xray/conf" ]] && [[ -f "/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json" || -f "/etc/v2ray-agent/xray/conf/02_trojan_TCP_inbounds.json" ]]; then
# xray-core
configPath=/etc/v2ray-agent/xray/conf/
ctlPath=/etc/v2ray-agent/xray/xray
fi

if [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]]; then
# 这里检测xray-core
if [[ -d "/etc/v2ray-agent/xray/conf" ]] && [[ -f "/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json" || -f "/etc/v2ray-agent/xray/conf/02_trojan_TCP_inbounds.json" ]]; then
# xray-core
configPath=/etc/v2ray-agent/xray/conf/
ctlPath=/etc/v2ray-agent/xray/xray
if grep </etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json -q '"security": "xtls"'; then
coreInstallType=1
elif grep </etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json -q '"security": "tls"'; then
coreInstallType=3
fi
fi
fi

if [[ -d "/etc/v2ray-agent/hysteria" && -f "/etc/v2ray-agent/hysteria/hysteria" ]]; then
# 这里检测 hysteria
if [[ -d "/etc/v2ray-agent/hysteria/conf" ]] && [[ -f "/etc/v2ray-agent/hysteria/conf/config.json" ]] && [[ -f "/etc/v2ray-agent/hysteria/conf/client_network.json" ]]; then
hysteriaConfigPath=/etc/v2ray-agent/hysteria/conf/
fi
if [[ -d "/etc/v2ray-agent/hysteria" && -f "/etc/v2ray-agent/hysteria/hysteria" ]]; then
# 这里检测 hysteria
if [[ -d "/etc/v2ray-agent/hysteria/conf" ]] && [[ -f "/etc/v2ray-agent/hysteria/conf/config.json" ]] && [[ -f "/etc/v2ray-agent/hysteria/conf/client_network.json" ]]; then
hysteriaConfigPath=/etc/v2ray-agent/hysteria/conf/
fi

fi
}

Expand Down Expand Up @@ -480,24 +482,22 @@ readConfigHostPathUUID() {
fi

fi
if [[ "${coreInstallType}" == "1" ]]; then
currentHost=$(jq -r .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
if [[ "${coreInstallType}" == "1" || "${coreInstallType}" == "3" ]]; then
if [[ "${coreInstallType}" == "3" ]]; then
currentHost=$(jq -r .inbounds[0].streamSettings.tlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
else
currentHost=$(jq -r .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
fi
currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}${frontingType}.json)
currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json)
if [[ "${currentAdd}" == "null" ]]; then
currentAdd=${currentHost}
fi
currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json)

elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
if [[ "${coreInstallType}" == "3" ]]; then

currentHost=$(jq -r .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
else
currentHost=$(jq -r .inbounds[0].streamSettings.tlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
fi
elif [[ "${coreInstallType}" == "2" ]]; then
currentHost=$(jq -r .inbounds[0].streamSettings.tlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json)

if [[ "${currentAdd}" == "null" ]]; then
currentAdd=${currentHost}
fi
Expand All @@ -509,14 +509,14 @@ readConfigHostPathUUID() {
# 状态展示
showInstallStatus() {
if [[ -n "${coreInstallType}" ]]; then
if [[ "${coreInstallType}" == 1 ]]; then
if [[ "${coreInstallType}" == 1 || "${coreInstallType}" == 3 ]]; then
if [[ -n $(pgrep -f xray/xray) ]]; then
echoContent yellow "\n核心: Xray-core[运行中]"
else
echoContent yellow "\n核心: Xray-core[未运行]"
fi

elif [[ "${coreInstallType}" == 2 || "${coreInstallType}" == 3 ]]; then
elif [[ "${coreInstallType}" == 2 ]]; then
if [[ -n $(pgrep -f v2ray/v2ray) ]]; then
echoContent yellow "\n核心: v2ray-core[运行中]"
else
Expand Down Expand Up @@ -858,8 +858,9 @@ initTLSNginxConfig() {
handleNginx stop
echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化Nginx申请证书配置"
if [[ -n "${currentHost}" ]]; then
echo "读取到上次安装记录,上次安装时的域名: ${currentHost}"
echo
read -r -p "读取到上次安装记录,是否使用上次安装时的域名 ?[y/n]:" historyDomainStatus
read -r -p "请注意检测正确性,是否使用上次安装时的域名 ?[y/n]:" historyDomainStatus
if [[ "${historyDomainStatus}" == "y" ]]; then
domain=${currentHost}
echoContent yellow "\n ---> 域名: ${domain}"
Expand Down Expand Up @@ -1656,7 +1657,7 @@ installXray() {

if [[ "${coreInstallType}" != "1" ]]; then

version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r ".[]|select (.prerelease==${prereleaseStatus})|.tag_name" | head -1)

echoContent green " ---> Xray-core版本:${version}"
if wget --help | grep -q show-progress; then
Expand Down Expand Up @@ -1810,9 +1811,9 @@ updateV2Ray() {
if [[ -n "$1" ]]; then
read -r -p "回退版本为${version},是否继续?[y/n]:" rollbackV2RayStatus
if [[ "${rollbackV2RayStatus}" == "y" ]]; then
if [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
if [[ "${coreInstallType}" == "2" ]]; then
echoContent green " ---> 当前v2ray-core版本:$(/etc/v2ray-agent/v2ray/v2ray --version | awk '{print $2}' | head -1)"
elif [[ "${coreInstallType}" == "1" ]]; then
elif [[ "${coreInstallType}" == "1" || "${coreInstallType}" == "3" ]]; then
echoContent green " ---> 当前Xray-core版本:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
fi

Expand Down Expand Up @@ -1917,9 +1918,9 @@ updateXray() {
checkGFWStatue() {
readInstallType
echoContent skyBlue "\n进度 $1/${totalProgress} : 验证服务启动状态"
if [[ "${coreInstallType}" == "1" ]] && [[ -n $(pgrep -f xray/xray) ]]; then
if [[ "${coreInstallType}" == "1" || "${coreInstallType}" == "3" ]] && [[ -n $(pgrep -f xray/xray) ]]; then
echoContent green " ---> 服务启动成功"
elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]] && [[ -n $(pgrep -f v2ray/v2ray) ]]; then
elif [[ "${coreInstallType}" == "2" ]] && [[ -n $(pgrep -f v2ray/v2ray) ]]; then
echoContent green " ---> 服务启动成功"
else
echoContent red " ---> 服务启动失败,请检查终端是否有日志打印"
Expand Down Expand Up @@ -2701,30 +2702,27 @@ initXrayConfig() {
if [[ -n "${currentUUID}" ]]; then
read -r -p "读取到上次安装记录,是否使用上次安装时的UUID ?[y/n]:" historyUUIDStatus
if [[ "${historyUUIDStatus}" == "y" ]]; then
addClientsStatus=true
uuid=${currentUUID}
echoContent green "\n ---> 使用成功"
fi
fi
else
if [[ -z "${uuid}" ]]; then
echoContent yellow "请输入自定义UUID[需合法],[回车]随机UUID"
read -r -p 'UUID:' customUUID

if [[ -z "${uuid}" ]]; then
echoContent yellow "请输入自定义UUID[需合法],[回车]随机UUID"
read -r -p 'UUID:' customUUID
if [[ -n ${customUUID} ]]; then
uuid=${customUUID}
else
uuid=$(/etc/v2ray-agent/xray/xray uuid)
fi

if [[ -n ${customUUID} ]]; then
uuid=${customUUID}
else
uuid=$(/etc/v2ray-agent/xray/xray uuid)
fi

fi

if [[ -z "${uuid}" ]]; then
addClientsStatus=
echoContent red "\n ---> uuid读取错误,重新生成"
uuid=$(/etc/v2ray-agent/xray/xray uuid)
fi

if [[ -z "${uuid}" ]]; then
echoContent red "\n ---> uuid读取错误,重新生成"
uuid=$(/etc/v2ray-agent/xray/xray uuid)
fi
fi
echoContent yellow "\n ${uuid}"

movePreviousConfig
Expand Down Expand Up @@ -2785,7 +2783,7 @@ EOF
{
"dns": {
"servers": [
"localhost"
"8.8.8.8"
]
}
}
Expand Down Expand Up @@ -2985,8 +2983,53 @@ EOF
if [[ -n "${customPort}" ]]; then
defaultPort=${customPort}
fi

cat <<EOF >/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json
if [ "$xtlsRprxVision" == true ]; then
cat <<EOF >/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json
{
"inbounds":[
{
"port": ${defaultPort},
"protocol": "vless",
"tag":"VLESSTCP",
"settings": {
"clients": [
{
"id": "${uuid}",
"add":"${add}",
"flow":"xtls-rprx-vision",
"email": "${domain}_${uuid}"
}
],
"decryption": "none",
"fallbacks": [
${fallbacksList}
]
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {
"minVersion": "1.2",
"alpn": [
"http/1.1",
"h2"
],
"certificates": [
{
"certificateFile": "/etc/v2ray-agent/tls/${domain}.crt",
"keyFile": "/etc/v2ray-agent/tls/${domain}.key",
"ocspStapling": 3600,
"usage":"encipherment"
}
]
}
}
}
]
}
EOF
else
cat <<EOF >/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json
{
"inbounds":[
{
Expand Down Expand Up @@ -3030,6 +3073,7 @@ EOF
]
}
EOF
fi
addClients "/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json" "${addClientsStatus}"
}

Expand Down Expand Up @@ -3136,7 +3180,7 @@ EOF
echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS/xtls-rprx-splice)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${currentHost}%3A${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dxtls%26type%3Dtcp%26${currentHost}%3D${currentHost}%26headerType%3Dnone%26sni%3D${currentHost}%26flow%3Dxtls-rprx-splice%23${email/direct/splice}\n"

elif [[ "${coreInstallType}" == 2 || "${coreInstallType}" == "3" ]]; then
elif [[ "${coreInstallType}" == 2 ]]; then
echoContent yellow " ---> 通用格式(VLESS+TCP+TLS)"
echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?security=tls&encryption=none&host=${currentHost}&headerType=none&type=tcp#${email}\n"

Expand All @@ -3148,6 +3192,19 @@ vless://${id}@${currentHost}:${currentDefaultPort}?security=tls&encryption=none&
EOF
echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3a%2f%2f${id}%40${currentHost}%3a${currentDefaultPort}%3fsecurity%3dtls%26encryption%3dnone%26host%3d${currentHost}%26headerType%3dnone%26type%3dtcp%23${email}\n"

elif [[ "${coreInstallType}" == 3 ]] && echo "${currentInstallProtocolType}" | grep -q 0; then
echoContent yellow " ---> 通用格式(VLESS+TCP+TLS/xtls-rprx-vision)"
echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=tls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-vision#${email/direct/splice}\n"

echoContent yellow " ---> 格式化明文(VLESS+TCP+TLS/xtls-rprx-vision)"
echoContent green " 协议类型:VLESS,地址:${currentHost},端口:${currentDefaultPort},用户ID:${id},安全:tls,传输方式:tcp,flow:xtls-rprx-vision,账户名:${email/direct/splice}\n"

cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
vless://${id}@${currentHost}:${currentDefaultPort}?security=tls&encryption=none&host=${currentHost}&headerType=none&type=tcp#${email}
EOF
echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${currentHost}%3A${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dtcp%26${currentHost}%3D${currentHost}%26headerType%3Dnone%26sni%3D${currentHost}%26flow%3Dxtls-rprx-vision%23${email/direct/splice}\n"
fi

elif [[ "${type}" == "trojanTCPXTLS" ]]; then
Expand Down Expand Up @@ -3291,7 +3348,7 @@ showAccounts() {
done

else
echoContent skyBlue "===================== VLESS TCP TLS/XTLS-direct/XTLS-splice ======================\n"
echoContent skyBlue "================ VLESS TCP TLS/XTLS-direct/XTLS-splice/XTLS-vision ================\n"
jq .inbounds[0].settings.clients ${configPath}02_VLESS_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
local email=
email=$(echo "${user}" | jq -r .email)
Expand Down Expand Up @@ -3985,7 +4042,7 @@ updateV2RayAgent() {
else
updateV2RayAgent
fi

echoContent skyBlue "\n进度 $1/${totalProgress} : 更新v2ray-agent脚本"
rm -rf /etc/v2ray-agent/install.sh
if wget --help | grep -q show-progress; then
Expand Down Expand Up @@ -4911,10 +4968,10 @@ removeVMessWSTLSUnblockStreamingMedia() {

# 重启核心
reloadCore() {
if [[ "${coreInstallType}" == "1" ]]; then
if [[ "${coreInstallType}" == "1" || "${coreInstallType}" == "3" ]]; then
handleXray stop
handleXray start
elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
elif [[ "${coreInstallType}" == "2" ]]; then
handleV2Ray stop
handleV2Ray start
fi
Expand Down Expand Up @@ -5150,6 +5207,7 @@ selectCoreInstall() {
echoContent red "\n=============================================================="
echoContent yellow "1.Xray-core"
echoContent yellow "2.v2ray-core"
echoContent yellow "3.Xray-core预览版(tcp默认使用xtls-rprx-vision)"
echoContent red "=============================================================="
read -r -p "请选择:" selectCoreType
case ${selectCoreType} in
Expand All @@ -5169,11 +5227,12 @@ selectCoreInstall() {
fi
;;
3)
v2rayCoreVersion=v4.32.1
prereleaseStatus=true
xtlsRprxVision=true
if [[ "${selectInstallType}" == "2" ]]; then
customV2RayInstall
customXrayInstall
else
v2rayCoreInstall
xrayCoreInstall
fi
;;
*)
Expand Down Expand Up @@ -5289,15 +5348,11 @@ coreVersionManageMenu() {
menu
exit 0
fi
if [[ "${coreInstallType}" == "1" ]]; then
if [[ "${coreInstallType}" == "1" || "${coreInstallType}" == "3" ]]; then
xrayVersionManageMenu 1
elif [[ "${coreInstallType}" == "2" ]]; then
v2rayCoreVersion=
v2rayVersionManageMenu 1

elif [[ "${coreInstallType}" == "3" ]]; then
v2rayCoreVersion=v4.32.1
v2rayVersionManageMenu 1
fi
}
# 定时任务检查证书
Expand Down Expand Up @@ -5447,7 +5502,7 @@ menu() {
echoContent red "\n=============================================================="
echoContent green "作者:Reece"
echoContent green "原作者:mack-a"
echoContent green "当前版本:v2.6.15"
echoContent green "当前版本:v2.7.0"
echoContent green "Github:https://github.com/reeceyng/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus
Expand Down

0 comments on commit 4a55c2d

Please sign in to comment.