helloworld icon indicating copy to clipboard operation
helloworld copied to clipboard

hysteria2 节点 remarks 为空时 Xray 启动失败: outbound tag cfg274a8f 重复

Open foxhoundhcm opened this issue 5 months ago • 1 comments

Issue: hysteria2 节点启动失败 — gen_config.lua 中 freedom outbound 与主 outbound tag 重复

环境

  • 固件:OpenWrt (fw4/nftables)
  • SSR-plus:luci-app-ssr-plus (latest)
  • Xray:26.6.1
  • 节点类型:hysteria2

现象

切换到 hysteria2 节点后,Xray 进程无法启动。

ps | grep v2ray
# 无进程

查看日志:

/var/etc/ssrplus/bin/v2ray run -c /var/etc/ssrplus/tcp-udp-ssr-retcp.json -test
# Failed to start: main: failed to create server
#   > app/proxyman/outbound: existing tag found: cfg274a8f

生成的配置(问题部分)

{
  "outbounds": [
    {
      "protocol": "hysteria",
      "tag": "cfg274a8f",
      "dialerProxy": "cfg274a8f",        // ← 引用了自己
      ...
    },
    {
      "protocol": "freedom",
      "tag": "cfg274a8f"                  // ← 与主出站 tag 重复
    }
  ]
}

hysteria 出站需要 dialerProxy 指向一个 freedom 出站作为底层 QUIC 传输,但两者生成了相同的 tag。Xray 要求所有 outbound tag 唯一,因重复而拒绝启动。

根因

/usr/share/shadowsocksr/gen_config.lua

当节点 remarks(别名)为空 时,以下三处都直接用 node_id 作为 tag:

-- 第 481 行:主 outbound tag(正确,保持不变)
tag = (remarks ~= nil and remarks ~= "") and (node_id .. ":" .. remarks) or node_id,

-- 第 838 行:dialerProxy 引用(BUG:应指向 freedom,却指向了自己)
dialerProxy = ... or node_id

-- 第 875 行:freedom outbound tag(BUG:与主出站 tag 相同)
tag = (remarks ~= nil and remarks ~= "") and (node_id .. "." .. remarks) or node_id,

remarks 非空时没有问题(因为有 . 和 : 的区分),但 remarks 为空时三处都 fallback 到 node_id,导致主出站、dialerProxy、freedom 出站 tag 三者相同。

修复

第 838、875 行追加 _direct 后缀以确保唯一性:

-- 第 838 行
dialerProxy = ... or node_id .. "_direct"

-- 第 875 行
tag = (remarks ~= nil and remarks ~= "") and (node_id .. "." .. remarks) or node_id .. "_direct",

修复后的生成配置:

{
  "outbounds": [
    {
      "protocol": "hysteria",
      "tag": "cfg274a8f",
      "dialerProxy": "cfg274a8f_direct"
    },
    {
      "protocol": "freedom",
      "tag": "cfg274a8f_direct"
    }
  ]
}

验证

/var/etc/ssrplus/bin/v2ray run -c /var/etc/ssrplus/tcp-udp-ssr-retcp.json -test
# Configuration OK.

Xray 正常启动,代理连通。

影响范围

仅影响 hysteria2 节点且 remarks(别名)为空 的情况。remarks 非空时 . 和 : 能区分,不受影响。

相关文件

  • /rom/usr/share/shadowsocksr/gen_config.lua — 原始文件(ROM 只读)
  • /usr/share/shadowsocksr/gen_config.lua — overlay 修改文件

foxhoundhcm avatar Jul 01 '26 23:07 foxhoundhcm

已修: https://github.com/fw876/helloworld/commit/c04ace92dd8b53434164bb6bf737d3bda2bf3f74

zxlhhyccc avatar Jul 02 '26 16:07 zxlhhyccc