feat(sub): auto-detect subscription format by User-Agent (Updated) (#5826)

* feat(settings): add subscription format controls

* feat(sub): auto-detect subscription formats

* fix(xray): validate balancer regexes before save

* Revert "fix(xray): validate balancer regexes before save"

This reverts commit 8a208ce71b.

* doc(endpoints): align indent spaces

* doc(settings): improve error message formatting in validateSubUserAgentRegex

- Use NewErrorf with proper formatting instead of NewError with string concatenation
- Add comment explaining the rationale for returning original pattern value
- This preserves the intentional design where empty input is stored as empty
  in the DB and inherited as the runtime default at read time

---------

Co-authored-by: Tomilla <5007859+Tomilla@users.noreply.github.com>
Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>
This commit is contained in:
Tomi lla
2026-07-14 13:01:40 +02:00
committed by GitHub
co-authored by Tomilla Sanaei
parent f2b17397f4
commit 129f50d92a
40 changed files with 1588 additions and 89 deletions
+14 -1
View File
@@ -1191,6 +1191,19 @@
"subJsonEnable": "单独启用/禁用 JSON 订阅端点。",
"subJsonEnableTitle": "JSON 订阅",
"subClashEnableTitle": "Clash / Mihomo 订阅",
"subFormatsTipTitle": "特定格式的订阅设置",
"subFormatsTipDesc": "分别配置 JSON 和 Clash / Mihomo 的 URL 路径、反向代理 URL 和客户端自动识别。",
"subFormatsTipAction": "打开订阅格式",
"subJsonAutoDetect": "自动识别 Xray JSON 客户端",
"subJsonAutoDetectDesc": "启用后,使用标准订阅 URL 的已识别兼容客户端将自动获得 Xray JSON 配置数组。其他客户端继续获得原始/Base64 响应。需要启用 JSON 订阅并重启面板才能生效。",
"subJsonAlwaysArray": "始终返回 JSON 数组",
"subJsonAlwaysArrayDesc": "即使只有一个配置,也将显式 JSON 订阅端点返回为数组,以符合 XTLS 订阅标准。自动识别的 JSON 响应始终使用数组。禁用时保留旧版单对象响应。",
"subJsonUserAgentRegex": "Xray JSON User-Agent 正则表达式",
"subJsonUserAgentRegexDesc": "用于与客户端 User-Agent 进行匹配,从而在标准订阅 URL 上自动选择 Xray JSON 格式的 Go RE2 正则表达式。默认留空,因此在为需要服务的客户端设置规则之前,自动识别保持关闭。其他客户端继续获得原始/Base64 响应。更改后请重启面板。",
"subClashAutoDetect": "自动识别 Clash/Mihomo 客户端",
"subClashAutoDetectDesc": "启用后,使用标准订阅 URL 的已识别 Clash/Mihomo 客户端将自动获得 Clash YAML。浏览器仍显示订阅页面,其他客户端继续获得原始/Base64 响应,独立的 JSON 和 Clash URL 仍然可用。需要启用 Clash/Mihomo 订阅并重启面板才能生效。",
"subClashUserAgentRegex": "Clash/Mihomo User-Agent 正则表达式",
"subClashUserAgentRegexDesc": "用于与客户端 User-Agent 进行匹配,从而在标准订阅 URL 上识别 Clash/Mihomo 客户端的 Go RE2 正则表达式。留空则使用默认规则。更改后请重启面板。",
"subTitle": "订阅标题",
"subTitleDesc": "在VPN客户端中显示的标题",
"subSupportUrl": "支持链接",
@@ -1281,7 +1294,7 @@
},
"subFormats": {
"finalMask": "Final Mask",
"finalMaskDesc": "注入到每个 JSON 订阅流的 xray finalmask 掩码(TCP/UDP和 QUIC 调优。需要较新的 xray 客户端。",
"finalMaskDesc": "将 Xray finalmask TCP/UDP 掩码和 QUIC 参数注入每个生成的 Xray JSON 配置。需要支持 Xray JSON 订阅的客户端应用和较新的 Xray 核心。",
"packets": "数据包",
"length": "长度",
"interval": "间隔",