feat(脚本): 增加Reality xhttp

master
mack-a 2025-01-04 17:02:29 +08:00
parent c9f911e599
commit ffd339365b
1 changed files with 90 additions and 71 deletions

View File

@ -201,7 +201,8 @@ initVar() {
# xray-core reality serverName publicKey # xray-core reality serverName publicKey
xrayVLESSRealityServerName= xrayVLESSRealityServerName=
xrayVLESSRealityPort= xrayVLESSRealityPort=
xrayVLESSSplitHTTPort= xrayVLESSRealityXHTTPServerName=
xrayVLESSRealityXHTTPort=
# xrayVLESSRealityPublicKey= # xrayVLESSRealityPublicKey=
# interfaceName= # interfaceName=
@ -415,6 +416,12 @@ readInstallProtocolType() {
xrayVLESSRealityPort= xrayVLESSRealityPort=
xrayVLESSRealityServerName= xrayVLESSRealityServerName=
xrayVLESSRealityXHTTPort=
xrayVLESSRealityXHTTPServerName=
# currentRealityXHTTPPrivateKey=
currentRealityXHTTPPublicKey=
currentRealityPrivateKey= currentRealityPrivateKey=
currentRealityPublicKey= currentRealityPublicKey=
@ -447,9 +454,15 @@ readInstallProtocolType() {
singBoxVLESSWSPort=$(jq .inbounds[0].listen_port "${row}.json") singBoxVLESSWSPort=$(jq .inbounds[0].listen_port "${row}.json")
fi fi
fi fi
if echo "${row}" | grep -q VLESS_SplitHTTP_inbounds; then if echo "${row}" | grep -q VLESS_XHTTP_inbounds; then
currentInstallProtocolType="${currentInstallProtocolType}12," currentInstallProtocolType="${currentInstallProtocolType}12,"
xrayVLESSSplitHTTPort=$(jq -r .inbounds[0].port "${row}.json") xrayVLESSRealityXHTTPort=$(jq -r .inbounds[0].port "${row}.json")
xrayVLESSRealityXHTTPServerName=$(jq -r .inbounds[0].streamSettings.realitySettings.serverNames[0] "${row}.json")
currentRealityXHTTPPublicKey=$(jq -r .inbounds[0].streamSettings.realitySettings.publicKey "${row}.json")
# currentRealityXHTTPPrivateKey=$(jq -r .inbounds[0].streamSettings.realitySettings.privateKey "${row}.json")
# if [[ "${coreInstallType}" == "2" ]]; then # if [[ "${coreInstallType}" == "2" ]]; then
# frontingType=03_VLESS_WS_inbounds # frontingType=03_VLESS_WS_inbounds
# singBoxVLESSWSPort=$(jq .inbounds[0].listen_port "${row}.json") # singBoxVLESSWSPort=$(jq .inbounds[0].listen_port "${row}.json")
@ -887,8 +900,8 @@ readConfigHostPathUUID() {
fi fi
fi fi
fi fi
if [[ -z "${currentPath}" && -f "${configPath}12_VLESS_SplitHTTP_inbounds.json" ]]; then if [[ -z "${currentPath}" && -f "${configPath}12_VLESS_XHTTP_inbounds.json" ]]; then
currentPath=$(jq -r .inbounds[0].streamSettings.splithttpSettings.path "${configPath}12_VLESS_SplitHTTP_inbounds.json" | awk -F "[s][p][l][i][t]" '{print $1}' | awk -F "[/]" '{print $2}') currentPath=$(jq -r .inbounds[0].streamSettings.xhttpSettings.path "${configPath}12_VLESS_XHTTP_inbounds.json" | awk -F "[x][H][T][T][P]" '{print $1}' | awk -F "[/]" '{print $2}')
fi fi
elif [[ "${coreInstallType}" == "2" && -f "${singBoxConfigPath}05_VMess_WS_inbounds.json" ]]; then elif [[ "${coreInstallType}" == "2" && -f "${singBoxConfigPath}05_VMess_WS_inbounds.json" ]]; then
singBoxVMessWSPath=$(jq -r .inbounds[0].transport.path "${singBoxConfigPath}05_VMess_WS_inbounds.json") singBoxVMessWSPath=$(jq -r .inbounds[0].transport.path "${singBoxConfigPath}05_VMess_WS_inbounds.json")
@ -2981,9 +2994,9 @@ initXrayClients() {
currentUser="{\"id\":\"${uuid}\",\"email\":\"${email}-VLESS_WS\"}" currentUser="{\"id\":\"${uuid}\",\"email\":\"${email}-VLESS_WS\"}"
users=$(echo "${users}" | jq -r ". +=[${currentUser}]") users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
fi fi
# VLESS SplitHTTP # VLESS XHTTP
if echo "${type}" | grep -q ",12,"; then if echo "${type}" | grep -q ",12,"; then
currentUser="{\"id\":\"${uuid}\",\"email\":\"${email}-VLESS_SplitHTTP\"}" currentUser="{\"id\":\"${uuid}\",\"email\":\"${email}-VLESS_XHTTP\"}"
users=$(echo "${users}" | jq -r ". +=[${currentUser}]") users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
fi fi
# trojan grpc # trojan grpc
@ -4227,41 +4240,45 @@ EOF
elif [[ -z "$3" ]]; then elif [[ -z "$3" ]]; then
rm /etc/v2ray-agent/xray/conf/03_VLESS_WS_inbounds.json >/dev/null 2>&1 rm /etc/v2ray-agent/xray/conf/03_VLESS_WS_inbounds.json >/dev/null 2>&1
fi fi
# VLESS_SplitHTTP_TLS # VLESS_XHTTP_TLS
if echo "${selectCustomInstallType}" | grep -q ",12," || [[ "$1" == "all" ]]; then if echo "${selectCustomInstallType}" | grep -q ",12," || [[ "$1" == "all" ]]; then
initXraySplitPort initXrayXHTTPort
cat <<EOF >/etc/v2ray-agent/xray/conf/12_VLESS_SplitHTTP_inbounds.json initRealityClientServersName
initRealityKey
cat <<EOF >/etc/v2ray-agent/xray/conf/12_VLESS_XHTTP_inbounds.json
{ {
"inbounds":[ "inbounds":[
{ {
"port": ${splitHTTPort}, "port": ${xHTTPort},
"listen": "0.0.0.0", "listen": "0.0.0.0",
"protocol": "vless", "protocol": "vless",
"tag":"VLESSSplit", "tag":"VLESSRealityXHTTP",
"settings": { "settings": {
"clients": $(initXrayClients 12), "clients": $(initXrayClients 12),
"decryption": "none" "decryption": "none"
}, },
"streamSettings": { "streamSettings": {
"network": "splithttp", "network": "xhttp",
"security": "tls", "security": "reality",
"splithttpSettings": { "realitySettings": {
"path": "/${customPath}split", "show": false,
"host":"${domain}" "dest": "${realityServerName}:${realityDomainPort}",
}, "xver": 0,
"tlsSettings": { "serverNames": [
"rejectUnknownSni": true, "${realityServerName}"
"alpn":[ ],
"h2", "privateKey": "${realityPrivateKey}",
"http/1.1" "publicKey": "${realityPublicKey}",
], "maxTimeDiff": 70000,
"certificates": [ "shortIds": [
{ "",
"certificateFile": "/etc/v2ray-agent/tls/${domain}.crt", "6ba85179e30d4fc2"
"keyFile": "/etc/v2ray-agent/tls/${domain}.key", ]
"ocspStapling": 3600 },
} "xhttpSettings": {
] "host": "${realityServerName}",
"path": "/${customPath}xHTTP",
"mode": "auto"
} }
} }
} }
@ -4269,7 +4286,7 @@ EOF
} }
EOF EOF
elif [[ -z "$3" ]]; then elif [[ -z "$3" ]]; then
rm /etc/v2ray-agent/xray/conf/12_VLESS_SplitHTTP_inbounds.json >/dev/null 2>&1 rm /etc/v2ray-agent/xray/conf/12_VLESS_XHTTP_inbounds.json >/dev/null 2>&1
fi fi
# trojan_grpc # trojan_grpc
if echo "${selectCustomInstallType}" | grep -q ",2," || [[ "$1" == "all" ]]; then if echo "${selectCustomInstallType}" | grep -q ",2," || [[ "$1" == "all" ]]; then
@ -5065,20 +5082,22 @@ EOF
echoContent yellow " ---> 二维码 VLESS(VLESS+WS+TLS)" echoContent yellow " ---> 二维码 VLESS(VLESS+WS+TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dws%26host%3D${currentHost}%26fp%3Dchrome%26sni%3D${currentHost}%26path%3D${path}%23${email}" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dws%26host%3D${currentHost}%26fp%3Dchrome%26sni%3D${currentHost}%26path%3D${path}%23${email}"
elif [[ "${type}" == "vlessSplitHTTP" ]]; then elif [[ "${type}" == "vlessXHTTP" ]]; then
echoContent yellow " ---> 通用格式(VLESS+SplitHTTP+TLS)" echoContent yellow " ---> 通用格式(VLESS+reality+XHTTP)"
echoContent green " vless://${id}@${add}:${port}?encryption=none&security=tls&type=splithttp&host=${currentHost}&alpn=h3,h2,http/1.1&sni=${currentHost}&fp=chrome&path=${path}#${email}\n" echoContent green " vless://${id}@$(getPublicIP):${port}?encryption=none&security=reality&type=xhttp&sni=${xrayVLESSRealityXHTTPServerName}&host=${xrayVLESSRealityXHTTPServerName}&fp=chrome&path=${path}&pbk=${currentRealityXHTTPPublicKey}&sid=6ba85179e30d4fc2#${email}\n"
echoContent yellow " ---> 格式化明文(VLESS+WS+TLS)"
echoContent green " 协议类型:VLESS地址:${add},伪装域名/SNI:${currentHost},端口:${port}client-fingerprint: chrome,用户ID:${id},安全:tls传输方式:splithttpalpn:h3,h2,http/1.1,路径:${path},账户名:${email}\n"
echoContent yellow " ---> 格式化明文(VLESS+reality+XHTTP)"
echoContent green "协议类型:VLESS reality地址:$(getPublicIP)publicKey:${currentRealityXHTTPPublicKey}shortId: 6ba85179e30d4fc2,serverNames${xrayVLESSRealityXHTTPServerName},端口:${port},路径:${path}SNI:${xrayVLESSRealityXHTTPServerName},伪装域名:${xrayVLESSRealityXHTTPServerName}用户ID:${id},传输方式:xhttp账户名:${email}\n"
cat <<EOF >>"/etc/v2ray-agent/subscribe_local/default/${user}" cat <<EOF >>"/etc/v2ray-agent/subscribe_local/default/${user}"
vless://${id}@${add}:${port}?encryption=none&security=tls&type=splithttp&host=${currentHost}&sni=${currentHost}&alpn=h3,h2,http/1.1&fp=chrome&path=${path}#${email} vless://${id}@$(getPublicIP):${port}?encryption=none&security=reality&type=xhttp&sni=${xrayVLESSRealityXHTTPServerName}&fp=chrome&path=${path}&pbk=${currentRealityXHTTPPublicKey}&sid=6ba85179e30d4fc2#${email}
EOF EOF
echoContent yellow " ---> 二维码 VLESS(VLESS+SplitHTTP+TLS)" echoContent yellow " ---> 二维码 VLESS(VLESS+reality+XHTTP)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dsplithttp%26host%3D${currentHost}%26fp%3Dchrome%26sni%3D${currentHost}%26alpn%3Dh3%2Ch2%2Chttp/1.1%26path%3D${path}%23${email}" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${port}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dtcp%26sni%3D${xrayVLESSRealityXHTTPServerName}%26fp%3Dchrome%26path%3D${path}%26host%3D${xrayVLESSRealityXHTTPServerName}%26pbk%3D${currentRealityXHTTPPublicKey}%26sid%3D6ba85179e30d4fc2%23${email}\n"
elif [[ "${type}" == "vlessgrpc" ]]; then
elif
[[ "${type}" == "vlessgrpc" ]]
then
echoContent yellow " ---> 通用格式(VLESS+gRPC+TLS)" echoContent yellow " ---> 通用格式(VLESS+gRPC+TLS)"
echoContent green " vless://${id}@${add}:${port}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&fp=chrome&serviceName=${currentPath}grpc&alpn=h2&sni=${currentHost}#${email}\n" echoContent green " vless://${id}@${add}:${port}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&fp=chrome&serviceName=${currentPath}grpc&alpn=h2&sni=${currentHost}#${email}\n"
@ -5426,20 +5445,20 @@ showAccounts() {
done < <(echo "${currentCDNAddress}" | tr ',' '\n') done < <(echo "${currentCDNAddress}" | tr ',' '\n')
done done
fi fi
# VLESS SplitHTTP # VLESS XHTTP
if echo ${currentInstallProtocolType} | grep -q ",12,"; then if echo ${currentInstallProtocolType} | grep -q ",12,"; then
echoContent skyBlue "\n================================ VLESS SplitHTTP TLS [仅CDN推荐] ================================\n" echoContent skyBlue "\n================================ VLESS XHTTP TLS [仅CDN推荐] ================================\n"
jq .inbounds[0].settings.clients//.inbounds[0].users ${configPath}12_VLESS_SplitHTTP_inbounds.json | jq -c '.[]' | while read -r user; do jq .inbounds[0].settings.clients//.inbounds[0].users ${configPath}12_VLESS_XHTTP_inbounds.json | jq -c '.[]' | while read -r user; do
local email= local email=
email=$(echo "${user}" | jq -r .email//.name) email=$(echo "${user}" | jq -r .email//.name)
# local vlessSplitHTTPPort=${xrayVLESSSplitHTTPort} # local vlessXHTTPPort=${xrayVLESSRealityXHTTPort}
# if [[ "${coreInstallType}" == "2" ]]; then # if [[ "${coreInstallType}" == "2" ]]; then
# vlessSplitHTTPPort="${singBoxVLESSWSPort}" # vlessXHTTPPort="${singBoxVLESSWSPort}"
# fi # fi
echo echo
local path="${currentPath}split" local path="${currentPath}xHTTP"
# if [[ ${coreInstallType} == "1" ]]; then # if [[ ${coreInstallType} == "1" ]]; then
# path="/${currentPath}ws" # path="/${currentPath}ws"
@ -5451,7 +5470,7 @@ showAccounts() {
while read -r line; do while read -r line; do
echoContent skyBlue "\n ---> 账号:${email}${count}" echoContent skyBlue "\n ---> 账号:${email}${count}"
if [[ -n "${line}" ]]; then if [[ -n "${line}" ]]; then
defaultBase64Code vlessSplitHTTP "${xrayVLESSSplitHTTPort}" "${email}${count}" "$(echo "${user}" | jq -r .id//.uuid)" "${line}" "${path}" defaultBase64Code vlessXHTTP "${xrayVLESSRealityXHTTPort}" "${email}${count}" "$(echo "${user}" | jq -r .id//.uuid)" "${line}" "${path}"
count=$((count + 1)) count=$((count + 1))
echo echo
fi fi
@ -8144,7 +8163,7 @@ customXrayInstall() {
echoContent yellow "5.VLESS+TLS+gRPC[仅CDN推荐]" echoContent yellow "5.VLESS+TLS+gRPC[仅CDN推荐]"
echoContent yellow "7.VLESS+Reality+uTLS+Vision[推荐]" echoContent yellow "7.VLESS+Reality+uTLS+Vision[推荐]"
# echoContent yellow "8.VLESS+Reality+gRPC" # echoContent yellow "8.VLESS+Reality+gRPC"
echoContent yellow "12.VLESS+SplitHTTP+TLS[仅CDN推荐]" echoContent yellow "12.VLESS+XHTTP+TLS"
read -r -p "请选择[多选][例如:1,2,3]:" selectCustomInstallType read -r -p "请选择[多选][例如:1,2,3]:" selectCustomInstallType
echoContent skyBlue "--------------------------------------------------------------" echoContent skyBlue "--------------------------------------------------------------"
if echo "${selectCustomInstallType}" | grep -q ""; then if echo "${selectCustomInstallType}" | grep -q ""; then
@ -8602,7 +8621,7 @@ addOtherSubscribe() {
read -r -p "请输入域名 端口 机器别名:" remoteSubscribeUrl read -r -p "请输入域名 端口 机器别名:" remoteSubscribeUrl
if [[ -z "${remoteSubscribeUrl}" ]]; then if [[ -z "${remoteSubscribeUrl}" ]]; then
echoContent red " ---> 不可为空" echoContent red " ---> 不可为空"
addSubscribe addOtherSubscribe
elif ! echo "${remoteSubscribeUrl}" | grep -q ":"; then elif ! echo "${remoteSubscribeUrl}" | grep -q ":"; then
echoContent red " ---> 规则不合法" echoContent red " ---> 规则不合法"
else else
@ -9417,36 +9436,36 @@ initXrayRealityPort() {
fi fi
} }
# 初始化SplitHTTP端口 # 初始化XHTTP端口
initXraySplitPort() { initXrayXHTTPort() {
if [[ -n "${xrayVLESSSplitHTTPort}" && -z "${lastInstallationConfig}" ]]; then if [[ -n "${xrayVLESSRealityXHTTPort}" && -z "${lastInstallationConfig}" ]]; then
read -r -p "读取到上次安装记录,是否使用上次安装时的端口 [y/n]:" historySplitHTTPortStatus read -r -p "读取到上次安装记录,是否使用上次安装时的端口 [y/n]:" historyXHTTPortStatus
if [[ "${historySplitHTTPortStatus}" == "y" ]]; then if [[ "${historyXHTTPortStatus}" == "y" ]]; then
splitHTTPort=${xrayVLESSSplitHTTPort} xHTTPort=${xrayVLESSRealityXHTTPort}
fi fi
elif [[ -n "${xrayVLESSSplitHTTPort}" && -n "${lastInstallationConfig}" ]]; then elif [[ -n "${xrayVLESSRealityXHTTPort}" && -n "${lastInstallationConfig}" ]]; then
splitHTTPort=${xrayVLESSSplitHTTPort} xHTTPort=${xrayVLESSRealityXHTTPort}
fi fi
if [[ -z "${splitHTTPort}" ]]; then if [[ -z "${xHTTPort}" ]]; then
echoContent yellow "请输入端口[回车随机10000-30000]" echoContent yellow "请输入端口[回车随机10000-30000]"
read -r -p "端口:" splitHTTPort read -r -p "端口:" xHTTPort
if [[ -z "${splitHTTPort}" ]]; then if [[ -z "${xHTTPort}" ]]; then
splitHTTPort=$((RANDOM % 20001 + 10000)) xHTTPort=$((RANDOM % 20001 + 10000))
fi fi
if [[ -n "${splitHTTPort}" && "${xrayVLESSSplitHTTPort}" == "${splitHTTPort}" ]]; then if [[ -n "${xHTTPort}" && "${xrayVLESSRealityXHTTPort}" == "${xHTTPort}" ]]; then
handleXray stop handleXray stop
else else
checkPort "${splitHTTPort}" checkPort "${xHTTPort}"
fi fi
fi fi
if [[ -z "${splitHTTPort}" ]]; then if [[ -z "${xHTTPort}" ]]; then
initXraySplitPort initXrayXHTTPort
else else
allowPort "${splitHTTPort}" allowPort "${xHTTPort}"
allowPort "${splitHTTPort}" "udp" allowPort "${xHTTPort}" "udp"
echoContent yellow "\n ---> 端口: ${splitHTTPort}" echoContent yellow "\n ---> 端口: ${xHTTPort}"
fi fi
} }
# 初始化 reality 配置 # 初始化 reality 配置
@ -9719,7 +9738,7 @@ menu() {
cd "$HOME" || exit cd "$HOME" || exit
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent green "作者mack-a" echoContent green "作者mack-a"
echoContent green "当前版本v3.3.26" echoContent green "当前版本v3.3.27"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent" echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c" echoContent green "描述:八合一共存脚本\c"
showInstallStatus showInstallStatus