feat(sub): let the panel set the JSON subscription DNS servers (#6485)

* feat(sub): let the panel set the JSON subscription DNS servers

A baked routing profile (#6402) carries only the DNS its preset defines, so an
operator who wants their own resolvers has to override the whole profile or
patch the subscription behind a proxy.

Add the subJsonDns setting: either a full xray dns block or a bare array of
servers. It wins over the profile's DNS while leaving the profile's routing
rules intact, and reaches per-inbound, balancer and info-node documents alike.

The value is validated with xray's own schema (internal/xray/dnsconf): a block
the client could not load is rejected when the settings are saved and ignored
with a warning at request time, instead of being baked into every document.
Both the sub server and the settings API share that validator, so a stored
value can never be silently dropped.

xray's Build() is deliberately not used for validation: it resolves geosite
tokens from the geodata files and would reject valid configs whenever those
are absent from the panel's working directory.

* style(dnsconf): drop the ineffectual initial map assignment

golangci's ineffassign flagged the zero-value map whose value both paths
overwrite: the object branch now assigns the decoded map directly.

* docs(sub): scope the DNS setting to the documents it rewrites

The Routing header mirrored to Happ/INCY keeps the routing profile's own
resolvers, so the setting description and the header-source comment now say
so instead of claiming the profile's DNS is replaced everywhere.

Also trims two comments in the new dnsconf package to the repo's two-line cap.
This commit is contained in:
DIMFLIX
2026-09-13 12:51:56 +03:00
committed by GitHub
parent aaa5e61cad
commit 2730e4d071
33 changed files with 709 additions and 5 deletions
+2
View File
@@ -1178,6 +1178,8 @@
"subJsonUserAgentRegexDesc": "用于与客户端 User-Agent 进行匹配,从而在标准订阅 URL 上自动选择 Xray JSON 格式的 Go RE2 正则表达式。默认留空,因此在为需要服务的客户端设置规则之前,自动识别保持关闭。其他客户端继续获得原始/Base64 响应。更改后请重启面板。",
"subJsonRoutingRules": "JSON 订阅路由配置",
"subJsonRoutingRulesDesc": "路由 JSON、happ:// 或 incy:// 深度链接,或 https:// URL。设置后,将替换 JSON 订阅的 DNS 和路由规则(为忽略响应头的客户端直接嵌入配置,例如使用客户端侧负载均衡的 Happ 和 INCY)。若 Happ 路由响应头设置为空,同一配置会自动作为 Routing 响应头发送(内联 JSON 和 URL 转换为 happ:// 深度链接),以便客户端下载匹配的 geo 文件。",
"subJsonDns": "DNS 服务器",
"subJsonDnsDesc": "替换写入每个 JSON 订阅配置的 dns 块:可以是完整的 dns 对象,也可以只是 servers 数组。这些配置中路由配置文件的 DNS 也会被替换;但应用 Routing 头的客户端仍使用配置文件中的解析器。留空则使用内置解析器。",
"subClashAutoDetect": "自动识别 Clash/Mihomo 客户端",
"subClashAutoDetectDesc": "启用后,使用标准订阅 URL 的已识别 Clash/Mihomo 客户端将自动获得 Clash YAML。浏览器仍显示订阅页面,其他客户端继续获得原始/Base64 响应,独立的 JSON 和 Clash URL 仍然可用。需要启用 Clash/Mihomo 订阅并重启面板才能生效。",
"subClashUserAgentRegex": "Clash/Mihomo User-Agent 正则表达式",