feat(脚本): 完善 reality
parent
0f31e59466
commit
f2ec45e6cb
106
install.sh
106
install.sh
|
@ -153,7 +153,8 @@ initVar() {
|
||||||
# v2ray-core、xray-core配置文件的路径
|
# v2ray-core、xray-core配置文件的路径
|
||||||
configPath=
|
configPath=
|
||||||
|
|
||||||
xrayCoreRealityConfigPath=
|
# xray-core reality状态
|
||||||
|
realityStatus=
|
||||||
|
|
||||||
# hysteria 配置文件的路径
|
# hysteria 配置文件的路径
|
||||||
hysteriaConfigPath=
|
hysteriaConfigPath=
|
||||||
|
@ -254,7 +255,7 @@ readAcmeTLS() {
|
||||||
}
|
}
|
||||||
# 读取默认自定义端口
|
# 读取默认自定义端口
|
||||||
readCustomPort() {
|
readCustomPort() {
|
||||||
if [[ -n "${configPath}" ]]; then
|
if [[ -n "${configPath}" && -z "${realityStatus}" ]]; then
|
||||||
local port=
|
local port=
|
||||||
port=$(jq -r .inbounds[0].port "${configPath}${frontingType}.json")
|
port=$(jq -r .inbounds[0].port "${configPath}${frontingType}.json")
|
||||||
if [[ "${port}" != "443" ]]; then
|
if [[ "${port}" != "443" ]]; then
|
||||||
|
@ -283,17 +284,14 @@ readInstallType() {
|
||||||
|
|
||||||
if [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]]; then
|
if [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]]; then
|
||||||
# 这里检测xray-core
|
# 这里检测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
|
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" || -f "/etc/v2ray-agent/xray/conf/02_VLESS_reality_inbounds.json" ]]; then
|
||||||
# xray-core
|
# xray-core
|
||||||
configPath=/etc/v2ray-agent/xray/conf/
|
configPath=/etc/v2ray-agent/xray/conf/
|
||||||
ctlPath=/etc/v2ray-agent/xray/xray
|
ctlPath=/etc/v2ray-agent/xray/xray
|
||||||
coreInstallType=1
|
coreInstallType=1
|
||||||
elif [[ -d "/etc/v2ray-agent/xray/conf" ]] && [[ -f "/etc/v2ray-agent/xray/conf/02_VLESS_reality_inbounds.json" ]]; then
|
if [[ -f "${configPath}02_VLESS_reality_inbounds.json" ]]; then
|
||||||
# xray-core
|
realityStatus=1
|
||||||
# configPath=/etc/v2ray-agent/xray/conf/
|
fi
|
||||||
xrayCoreRealityConfigPath=/etc/v2ray-agent/xray/conf/
|
|
||||||
ctlPath=/etc/v2ray-agent/xray/xray
|
|
||||||
coreInstallType=1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -309,12 +307,6 @@ readInstallType() {
|
||||||
|
|
||||||
# 读取协议类型
|
# 读取协议类型
|
||||||
readInstallProtocolType() {
|
readInstallProtocolType() {
|
||||||
local configPathLocal=
|
|
||||||
if [[ -n "${xrayCoreRealityConfigPath}" ]]; then
|
|
||||||
configPathLocal=${xrayCoreRealityConfigPath}
|
|
||||||
else
|
|
||||||
configPathLocal=${configPath}
|
|
||||||
fi
|
|
||||||
currentInstallProtocolType=
|
currentInstallProtocolType=
|
||||||
|
|
||||||
while read -r row; do
|
while read -r row; do
|
||||||
|
@ -343,9 +335,9 @@ readInstallProtocolType() {
|
||||||
fi
|
fi
|
||||||
if echo "${row}" | grep -q VLESS_reality_inbounds; then
|
if echo "${row}" | grep -q VLESS_reality_inbounds; then
|
||||||
currentInstallProtocolType=${currentInstallProtocolType}'7'
|
currentInstallProtocolType=${currentInstallProtocolType}'7'
|
||||||
frontingType=02_VLESS_reality_inbounds
|
|
||||||
fi
|
fi
|
||||||
done < <(find ${configPathLocal} -name "*inbounds.json" | awk -F "[.]" '{print $1}')
|
|
||||||
|
done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}')
|
||||||
|
|
||||||
if [[ -n "${hysteriaConfigPath}" ]]; then
|
if [[ -n "${hysteriaConfigPath}" ]]; then
|
||||||
currentInstallProtocolType=${currentInstallProtocolType}'6'
|
currentInstallProtocolType=${currentInstallProtocolType}'6'
|
||||||
|
@ -374,7 +366,7 @@ checkBTPanel() {
|
||||||
}
|
}
|
||||||
# 读取当前alpn的顺序
|
# 读取当前alpn的顺序
|
||||||
readInstallAlpn() {
|
readInstallAlpn() {
|
||||||
if [[ -n "${currentInstallProtocolType}" && -n "${configPath}" ]]; then
|
if [[ -n "${currentInstallProtocolType}" && -z "${realityStatus}" ]]; then
|
||||||
local alpn
|
local alpn
|
||||||
alpn=$(jq -r .inbounds[0].streamSettings.tlsSettings.alpn[0] ${configPath}${frontingType}.json)
|
alpn=$(jq -r .inbounds[0].streamSettings.tlsSettings.alpn[0] ${configPath}${frontingType}.json)
|
||||||
if [[ -n ${alpn} ]]; then
|
if [[ -n ${alpn} ]]; then
|
||||||
|
@ -469,10 +461,10 @@ readHysteriaConfig() {
|
||||||
}
|
}
|
||||||
# 读取xray reality配置
|
# 读取xray reality配置
|
||||||
readXrayCoreRealityConfig() {
|
readXrayCoreRealityConfig() {
|
||||||
if [[ -n "${xrayCoreRealityConfigPath}" ]]; then
|
if [[ -n "${realityStatus}" ]]; then
|
||||||
currentRealityServerNames=$(jq -r .inbounds[0].streamSettings.realitySettings.serverNames "${xrayCoreRealityConfigPath}02_VLESS_reality_inbounds.json")
|
currentRealityServerNames=$(jq -r .inbounds[0].streamSettings.realitySettings.serverNames "${configPath}02_VLESS_reality_inbounds.json")
|
||||||
currentRealityPublicKey=$(jq -r .inbounds[0].streamSettings.realitySettings.publicKey "${xrayCoreRealityConfigPath}02_VLESS_reality_inbounds.json")
|
currentRealityPublicKey=$(jq -r .inbounds[0].streamSettings.realitySettings.publicKey "${configPath}02_VLESS_reality_inbounds.json")
|
||||||
currentRealityPort=$(jq -r .inbounds[0].port "${xrayCoreRealityConfigPath}02_VLESS_reality_inbounds.json")
|
currentRealityPort=$(jq -r .inbounds[0].port "${configPath}02_VLESS_reality_inbounds.json")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +477,7 @@ readConfigHostPathUUID() {
|
||||||
currentPort=
|
currentPort=
|
||||||
currentAdd=
|
currentAdd=
|
||||||
# 读取path
|
# 读取path
|
||||||
if [[ -n "${configPath}" ]]; then
|
if [[ -n "${configPath}" && -z "${realityStatus}" ]]; then
|
||||||
local fallback
|
local fallback
|
||||||
fallback=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.path)' ${configPath}${frontingType}.json | head -1)
|
fallback=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.path)' ${configPath}${frontingType}.json | head -1)
|
||||||
|
|
||||||
|
@ -524,7 +516,7 @@ readConfigHostPathUUID() {
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${coreInstallType}" == "1" && -n "${configPath}" ]]; then
|
if [[ "${coreInstallType}" == "1" && -n "${configPath}" && -z "${realityStatus}" ]]; 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}')
|
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}')
|
||||||
currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}${frontingType}.json)
|
currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}${frontingType}.json)
|
||||||
currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json)
|
currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json)
|
||||||
|
@ -532,7 +524,6 @@ readConfigHostPathUUID() {
|
||||||
currentAdd=${currentHost}
|
currentAdd=${currentHost}
|
||||||
fi
|
fi
|
||||||
currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json)
|
currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json)
|
||||||
|
|
||||||
elif [[ "${coreInstallType}" == "2" ]]; then
|
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}')
|
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)
|
currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json)
|
||||||
|
@ -632,6 +623,7 @@ readConfigHostPathUUID
|
||||||
readInstallAlpn
|
readInstallAlpn
|
||||||
readCustomPort
|
readCustomPort
|
||||||
checkBTPanel
|
checkBTPanel
|
||||||
|
readXrayCoreRealityConfig
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
|
|
||||||
# 初始化安装目录
|
# 初始化安装目录
|
||||||
|
@ -1709,11 +1701,16 @@ installHysteria() {
|
||||||
# 安装xray
|
# 安装xray
|
||||||
installXray() {
|
installXray() {
|
||||||
readInstallType
|
readInstallType
|
||||||
|
local prereleaseStatus=false
|
||||||
|
if [[ "$2" == "true" ]]; then
|
||||||
|
prereleaseStatus=true
|
||||||
|
fi
|
||||||
|
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 安装Xray"
|
echoContent skyBlue "\n进度 $1/${totalProgress} : 安装Xray"
|
||||||
|
|
||||||
if [[ "${coreInstallType}" != "1" ]]; then
|
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}"
|
echoContent green " ---> Xray-core版本:${version}"
|
||||||
if wget --help | grep -q show-progress; then
|
if wget --help | grep -q show-progress; then
|
||||||
|
@ -1738,7 +1735,7 @@ installXray() {
|
||||||
read -r -p "是否更新、升级?[y/n]:" reInstallXrayStatus
|
read -r -p "是否更新、升级?[y/n]:" reInstallXrayStatus
|
||||||
if [[ "${reInstallXrayStatus}" == "y" ]]; then
|
if [[ "${reInstallXrayStatus}" == "y" ]]; then
|
||||||
rm -f /etc/v2ray-agent/xray/xray
|
rm -f /etc/v2ray-agent/xray/xray
|
||||||
installXray "$1"
|
installXray "$1" "$2"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -3392,7 +3389,7 @@ showAccounts() {
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 账号"
|
echoContent skyBlue "\n进度 $1/${totalProgress} : 账号"
|
||||||
local show
|
local show
|
||||||
# VLESS TCP
|
# VLESS TCP
|
||||||
if [[ -n "${configPath}" ]]; then
|
if [[ -n "${configPath}" && -z "${realityStatus}" ]]; then
|
||||||
show=1
|
show=1
|
||||||
if echo "${currentInstallProtocolType}" | grep -q trojan; then
|
if echo "${currentInstallProtocolType}" | grep -q trojan; then
|
||||||
echoContent skyBlue "===================== Trojan TCP TLS_Vision ======================\n"
|
echoContent skyBlue "===================== Trojan TCP TLS_Vision ======================\n"
|
||||||
|
@ -3524,7 +3521,7 @@ showAccounts() {
|
||||||
if echo ${currentInstallProtocolType} | grep -q 7; then
|
if echo ${currentInstallProtocolType} | grep -q 7; then
|
||||||
show=1
|
show=1
|
||||||
echoContent skyBlue "================================ VLESS reality =================================\n"
|
echoContent skyBlue "================================ VLESS reality =================================\n"
|
||||||
jq .inbounds[0].settings.clients ${xrayCoreRealityConfigPath}02_VLESS_reality_inbounds.json | jq -c '.[]' | while read -r user; do
|
jq .inbounds[0].settings.clients ${configPath}02_VLESS_reality_inbounds.json | jq -c '.[]' | while read -r user; do
|
||||||
local email=
|
local email=
|
||||||
email=$(echo "${user}" | jq -r .email)
|
email=$(echo "${user}" | jq -r .email)
|
||||||
|
|
||||||
|
@ -4198,7 +4195,7 @@ bbrInstall() {
|
||||||
|
|
||||||
# 查看、检查日志
|
# 查看、检查日志
|
||||||
checkLog() {
|
checkLog() {
|
||||||
if [[ -z "${configPath}" || -z "${xrayCoreRealityConfigPath}" ]]; then
|
if [[ -z "${configPath}" || -z "${realityStatus}" ]]; then
|
||||||
echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容"
|
echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -5526,9 +5523,9 @@ cronRenewTLS() {
|
||||||
}
|
}
|
||||||
# 账号管理
|
# 账号管理
|
||||||
manageAccount() {
|
manageAccount() {
|
||||||
echoContent skyBlue "\n功能
|
echoContent skyBlue "\n功能 1/${totalProgress} : 账号管理"
|
||||||
|
echoContent red "\n=============================================================="
|
||||||
# 每次删除、添加账号后,需要重新查看订阅生成订阅"
|
echoContent yellow "# 每次删除、添加账号后,需要重新查看订阅生成订阅"
|
||||||
echoContent yellow "# 添加单个用户时可自定义email和uuid"
|
echoContent yellow "# 添加单个用户时可自定义email和uuid"
|
||||||
echoContent yellow "# 如安装了Hysteria,账号会同时添加到Hysteria\n"
|
echoContent yellow "# 如安装了Hysteria,账号会同时添加到Hysteria\n"
|
||||||
echoContent yellow "1.查看账号"
|
echoContent yellow "1.查看账号"
|
||||||
|
@ -5632,18 +5629,33 @@ switchAlpn() {
|
||||||
# 初始化 reality 配置
|
# 初始化 reality 配置
|
||||||
initXrayRealityConfig() {
|
initXrayRealityConfig() {
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化 Xray-core reality配置"
|
echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化 Xray-core reality配置"
|
||||||
echoContent skyBlue "\n ---> 生成 reality key\n"
|
echoContent yellow "请输入端口"
|
||||||
|
|
||||||
|
read -r -p "端口:" realityPort
|
||||||
|
|
||||||
|
checkCustomPort "${realityPort}"
|
||||||
|
|
||||||
|
echoContent skyBlue "\n --- reality key\n"
|
||||||
realityX25519Key=$(/etc/v2ray-agent/xray/xray x25519)
|
realityX25519Key=$(/etc/v2ray-agent/xray/xray x25519)
|
||||||
|
|
||||||
realityPrivateKey=$(echo "${realityX25519Key}" | head -1 | awk '{print $3}')
|
realityPrivateKey=$(echo "${realityX25519Key}" | head -1 | awk '{print $3}')
|
||||||
realityPublicKey=$(echo "${realityX25519Key}" | tail -n 1 | awk '{print $3}')
|
realityPublicKey=$(echo "${realityX25519Key}" | tail -n 1 | awk '{print $3}')
|
||||||
|
|
||||||
echoContent skyBlue "\n ---> 配置回落的域名\n"
|
echoContent skyBlue "\n --- \
|
||||||
|
\
|
||||||
|
\
|
||||||
|
--- >生成 \
|
||||||
|
> \
|
||||||
|
\
|
||||||
|
\
|
||||||
|
\
|
||||||
|
\
|
||||||
|
配置回落的域名\n"
|
||||||
read -r -p "请输入:" realityDestDomain
|
read -r -p "请输入:" realityDestDomain
|
||||||
|
|
||||||
echoContent skyBlue "\n ---> 配置客户端可用的serverNames\n"
|
echoContent skyBlue "\n >配置客户端可用的serverNames\n"
|
||||||
echoContent red "\n=============================================================="
|
echoContent red "\n=============================================================="
|
||||||
echoContent yellow "# 注意事项\n"
|
echoContent yellow " # 注意事项\n"
|
||||||
echoContent yellow "录入示例:bing.com,www.bing.com\n"
|
echoContent yellow "录入示例:bing.com,www.bing.com\n"
|
||||||
read -r -p "请输入:" realityServerNames
|
read -r -p "请输入:" realityServerNames
|
||||||
realityServerNames=\"${realityServerNames//,/\",\"}\"
|
realityServerNames=\"${realityServerNames//,/\",\"}\"
|
||||||
|
@ -5656,23 +5668,17 @@ xrayCoreRealityInstall() {
|
||||||
# 下载核心
|
# 下载核心
|
||||||
# prereleaseStatus=true
|
# prereleaseStatus=true
|
||||||
# updateXray
|
# updateXray
|
||||||
# installXray 3
|
installXray 3 true
|
||||||
# 生成 privateKey、配置回落地址、配置serverNames
|
# 生成 privateKey、配置回落地址、配置serverNames
|
||||||
installXrayService 6
|
installXrayService 6
|
||||||
initXrayRealityConfig 5
|
initXrayRealityConfig 5
|
||||||
# 初始化配置
|
# 初始化配置
|
||||||
initXrayConfig custom 7
|
initXrayConfig custom 7
|
||||||
|
handleXray stop
|
||||||
|
cleanUp v2rayClean
|
||||||
|
sleep 2
|
||||||
# 启动
|
# 启动
|
||||||
handleXray start
|
handleXray start
|
||||||
# 展示账号
|
|
||||||
cleanUp v2rayClean
|
|
||||||
selectCustomInstallType=7
|
|
||||||
|
|
||||||
cleanUp v2rayDel
|
|
||||||
handleXray stop
|
|
||||||
sleep 2
|
|
||||||
handleXray start
|
|
||||||
|
|
||||||
# 生成账号
|
# 生成账号
|
||||||
showAccounts 8
|
showAccounts 8
|
||||||
}
|
}
|
||||||
|
@ -5681,11 +5687,10 @@ manageReality() {
|
||||||
|
|
||||||
echoContent skyBlue "\n进度 1/1 : reality管理"
|
echoContent skyBlue "\n进度 1/1 : reality管理"
|
||||||
echoContent red "\n=============================================================="
|
echoContent red "\n=============================================================="
|
||||||
local xrayCoreRealityStatus=
|
|
||||||
if [[ -n "${xrayCoreRealityConfigPath}" ]]; then
|
if [[ -n "${realityStatus}" ]]; then
|
||||||
echoContent yellow "1.重新安装"
|
echoContent yellow "1.重新安装"
|
||||||
echoContent yellow "2.卸载"
|
echoContent yellow "2.卸载"
|
||||||
xrayCoreRealityStatus=true
|
|
||||||
else
|
else
|
||||||
echoContent yellow "1.安装"
|
echoContent yellow "1.安装"
|
||||||
fi
|
fi
|
||||||
|
@ -5702,7 +5707,6 @@ manageReality() {
|
||||||
|
|
||||||
# hysteria管理
|
# hysteria管理
|
||||||
manageHysteria() {
|
manageHysteria() {
|
||||||
|
|
||||||
echoContent skyBlue "\n进度 1/1 : Hysteria管理"
|
echoContent skyBlue "\n进度 1/1 : Hysteria管理"
|
||||||
echoContent red "\n=============================================================="
|
echoContent red "\n=============================================================="
|
||||||
local hysteriaStatus=
|
local hysteriaStatus=
|
||||||
|
|
Loading…
Reference in New Issue