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 正規表示式",