fix(订阅): 修复 sing-box Reality 端口变量拼接问题

fix(sing-box): 修复订阅无法使用问题
This commit is contained in:
mack-a
2026-09-02 04:19:40 +08:00
parent 11da068e9a
commit c15f06d211
3 changed files with 47 additions and 51 deletions
+5 -45
View File
@@ -30,8 +30,7 @@
"server": "1.1.1.1",
"server_port": 443,
"detour": "自动选择",
"path": "/dns-query",
"domain_resolver": "dns_resolver"
"path": "/dns-query"
},
{
"tag": "dns_direct",
@@ -39,18 +38,12 @@
"server": "dns.alidns.com",
"server_port": 443,
"path": "/dns-query",
"domain_resolver": "dns_resolver"
"domain_resolver": "local"
},
{
"tag": "google",
"type": "tls",
"server": "8.8.4.4",
"domain_resolver": "dns_resolver"
},
{
"tag": "dns_resolver",
"type": "udp",
"server": "114.114.114.114"
"server": "8.8.4.4"
},
{
"type": "local",
@@ -83,30 +76,6 @@
"final": "dns_direct"
},
"inbounds": [
{
"type": "tun",
"tag": "tun-in",
"stack": "system",
"address": [
"172.18.0.1/30",
"fdfe:dcba:9876::1/126"
],
"route_address": [
"0.0.0.0/1",
"128.0.0.0/1",
"::/1",
"8000::/1"
],
"route_exclude_address": [
"192.168.0.0/16",
"10.0.0.0/8",
"172.16.0.0/12",
"fc00::/7"
],
"mtu": 9000,
"auto_route": true,
"strict_route": true
},
{
"type": "mixed",
"tag": "mixed-in",
@@ -216,10 +185,7 @@
],
"route": {
"default_http_client": "rule_set_http",
"default_domain_resolver": {
"server": "dns_resolver",
"strategy": "prefer_ipv4"
},
"default_domain_resolver": "local",
"rule_set": [
{
"tag": "geosite-category-ads-all",
@@ -354,11 +320,6 @@
"action": "sniff",
"timeout": "1s"
},
{
"inbound": "tun-in",
"action": "sniff",
"timeout": "1s"
},
{
"protocol": "dns",
"action": "hijack-dns"
@@ -460,7 +421,6 @@
"outbound": "本地直连"
}
],
"final": "本地直连",
"auto_detect_interface": true
"final": "本地直连"
}
}
+22 -4
View File
@@ -200,6 +200,7 @@ initVar() {
# xray-core reality serverName publicKey
xrayVLESSRealityServerName=
xrayVLESSRealityPort=
xrayVLESSRealityVisionPort=
xrayVLESSRealityXHTTPServerName=
xrayVLESSRealityXHTTPort=
# xrayVLESSRealityPublicKey=
@@ -425,6 +426,7 @@ readInstallProtocolType() {
frontingType=
xrayVLESSRealityPort=
xrayVLESSRealityVisionPort=
xrayVLESSRealityServerName=
xrayVLESSRealityXHTTPort=
@@ -5233,6 +5235,20 @@ EOF
}
# 获取Reality订阅端口
getRealitySubscriptionPort() {
local protocol=$1
if [[ "${coreInstallType}" == "2" ]]; then
if [[ "${protocol}" == "grpc" ]]; then
printf '%s\n' "${singBoxVLESSRealityGRPCPort}"
else
printf '%s\n' "${singBoxVLESSRealityVisionPort}"
fi
else
printf '%s\n' "${xrayVLESSRealityVisionPort}"
fi
}
# 账号
showAccounts() {
readInstallType
@@ -5401,7 +5417,7 @@ showAccounts() {
echoContent skyBlue "\n ---> 账号:${email}"
echo
defaultBase64Code vlessReality "${xrayVLESSRealityVisionPort}${singBoxVLESSRealityVisionPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)"
defaultBase64Code vlessReality "$(getRealitySubscriptionPort vision)" "${email}" "$(echo "${user}" | jq -r .id//.uuid)"
done
fi
# VLESS reality gRPC
@@ -5413,7 +5429,7 @@ showAccounts() {
echoContent skyBlue "\n ---> 账号:${email}"
echo
defaultBase64Code vlessRealityGRPC "${xrayVLESSRealityVisionPort}${singBoxVLESSRealityGRPCPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)"
defaultBase64Code vlessRealityGRPC "$(getRealitySubscriptionPort grpc)" "${email}" "$(echo "${user}" | jq -r .id//.uuid)"
done
fi
# tuic
@@ -9638,7 +9654,7 @@ checkRealityDest() {
local traceResult=
traceResult=$(curl -s "https://$(echo "${realityDestDomain}" | cut -d ':' -f 1)/cdn-cgi/trace" | grep "visit_scheme=https")
if [[ -n "${traceResult}" ]]; then
echoContent red "\n ---> 检测到使用的域名,托管在cloudflare并开启了代理,使用此类型域名可能导致VPS流量被他人使用[不建议使用]\n"
echoContent red "\n ---> 禁止使用已启用 Cloudflare 代理的域名。强制使用将导致 VPS 流量被他人滥用,相关后果由您自行承担。\n"
read -r -p "是否继续 [y/n]" setRealityDestStatus
if [[ "${setRealityDestStatus}" != 'y' ]]; then
exit 0
@@ -9719,6 +9735,8 @@ initRealityClientServersName() {
fi
fi
realityDestDomain="${realityServerName}:${realityDomainPort}"
checkRealityDest
echoContent yellow "\n ---> 客户端可用域名: ${realityServerName}:${realityDomainPort}\n"
}
# 初始化reality端口
@@ -9996,7 +10014,7 @@ menu() {
cd "$HOME" || exit
echoContent red "\n=============================================================="
echoContent green "作者:mack-a"
echoContent green "当前版本:v3.5.21"
echoContent green "当前版本:v3.5.22"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus
+20 -2
View File
@@ -204,6 +204,7 @@ initVar() {
# xray-core reality serverName publicKey
xrayVLESSRealityServerName=
xrayVLESSRealityPort=
xrayVLESSRealityVisionPort=
xrayVLESSRealityXHTTPServerName=
xrayVLESSRealityXHTTPort=
# xrayVLESSRealityPublicKey=
@@ -431,6 +432,7 @@ readInstallProtocolType() {
frontingType=
xrayVLESSRealityPort=
xrayVLESSRealityVisionPort=
xrayVLESSRealityServerName=
xrayVLESSRealityXHTTPort=
@@ -5193,6 +5195,20 @@ EOF
}
# Get Reality subscription port
getRealitySubscriptionPort() {
local protocol=$1
if [[ "${coreInstallType}" == "2" ]]; then
if [[ "${protocol}" == "grpc" ]]; then
printf '%s\n' "${singBoxVLESSRealityGRPCPort}"
else
printf '%s\n' "${singBoxVLESSRealityVisionPort}"
fi
else
printf '%s\n' "${xrayVLESSRealityVisionPort}"
fi
}
# account
showAccounts() {
readInstallType
@@ -5361,7 +5377,7 @@ showAccounts() {
echoContent skyBlue "\n --->Account:${email}"
echo
defaultBase64Code vlessReality "${xrayVLESSRealityVisionPort}${singBoxVLESSRealityVisionPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)"
defaultBase64Code vlessReality "$(getRealitySubscriptionPort vision)" "${email}" "$(echo "${user}" | jq -r .id//.uuid)"
done
fi
# VLESS reality gRPC
@@ -5373,7 +5389,7 @@ showAccounts() {
echoContent skyBlue "\n --->Account:${email}"
echo
defaultBase64Code vlessRealityGRPC "${xrayVLESSRealityVisionPort}${singBoxVLESSRealityGRPCPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)"
defaultBase64Code vlessRealityGRPC "$(getRealitySubscriptionPort grpc)" "${email}" "$(echo "${user}" | jq -r .id//.uuid)"
done
fi
# tuic
@@ -9650,6 +9666,8 @@ initRealityClientServersName() {
fi
fi
realityDestDomain="${realityServerName}:${realityDomainPort}"
checkRealityDest
echoContent yellow "Online QR code: https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=https://${currentDomain}/s/clashMetaProfiles/${emailMd5}\n "
}
initXrayRealityPort() {