mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4850] [Feature]: Add panel settings to customize DNS, queryStrategy, and domainStrategy for generated client subscription configs #3380
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3380
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rusik-afk on GitHub (Jun 3, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4850
Is your feature request related to a problem?
Yes. As discussed in issue #4848, the client subscription JSON config endpoint (
/sub/json/<subId>) currently relies on a hardcoded embedded template (sub/default.json).Because of this, parameters like
dns.servers(Google DNS),dns.queryStrategy(UseIP), androuting.domainStrategy(AsIs) are hardcoded for all clients. Administrators cannot enforce privacy-centric DNS (e.g., Cloudflare) or specific routing strategies globally from the panel. This requires manually instructing every end-user to configure these parameters inside their respective client applications (Hiddify, Happ, etc.), which is inefficient and error-prone for non-technical users.Describe the solution you'd like
I would like the panel to expose new configuration fields in Panel Settings -> Subscription Settings -> JSON Settings (similar to how
subJsonRulesorsubJsonFragmentcurrently work).Ideally, add the following setting keys to the UI:
subJsonDNSServers: To override the default"8.8.8.8"with custom upstream DNS arrays.subJsonDNSQueryStrategy: A dropdown or string field to override"UseIP"(e.g., with"UseIPv4").subJsonDomainStrategy: A dropdown or string field to override"AsIs"(e.g., with"IPIfNonMatch").When generating the subscription via the
/sub/json/endpoint, the panel should check these fields and inject them into the client config instead of using the hardcoded values fromsub/default.json.Alternatives you've considered
sub/default.json: This works but creates immense maintenance overhead, as every official panel update forces a manual re-compile of the binary.Concrete use case
I manage a server providing Xray access to a close group of friends/clients. I need all generated configs to seamlessly use Cloudflare DNS (
1.1.1.1), utilize theIPIfNonMatchdomain strategy, and strictly enforce theUseIPv4query/domain strategy to prevent connection issues caused by unstable IPv6 routing, DNS leaks, or geofence blocks. Having this exposed in the Web UI would allow me to manage this centrally and instantly update all clients upon subscription renewal.Mockups, screenshots, or examples
Please refer to the discussion and hardcoded values table provided by the bot/maintainers in my previous issue: #4848
Which parts of the panel would this affect?
Subscription (share links / Clash / JSON)
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 3, 2026):
Thanks for the detailed and well-researched request. Your analysis is correct — the values you want to control are indeed hardcoded in the embedded template today.
What the code currently does
sub/default.jsonis the template thatsub/subJsonService.gounmarshals at startup (//go:embed default.json). It contains these hardcoded values:dns.queryStrategy"UseIP"dns.servers[0].address"8.8.8.8"routing.domainStrategy"AsIs"outbounds[0].settings.domainStrategy"AsIs"The only runtime overrides
NewSubJsonServicecurrently applies to these fields are: whenfragmentornoisesis set, the freedom outbound'sdomainStrategyis overridden to"UseIP"(seesubJsonService.go:47). There is no path today to overridedns.servers,dns.queryStrategy, orrouting.domainStrategyfrom panel settings.The existing pattern to follow
The
subJsonRulessetting is the closest precedent. Here's how it flows end-to-end:web/service/setting.go— default"subJsonRules": ""+GetSubJsonRules()getterweb/entity/entity.goAllSettingstruct —SubJsonRules stringfieldsub/sub.go— fetchesSubJsonRulesand passes it toNewSUBControllersub/subController.goNewSUBController— forwards it toNewSubJsonServicesub/subJsonService.goNewSubJsonService— unmarshals and prepends the rules intoconfigJson["routing"]["rules"]Adding the three new settings would require the same changes across all five files, plus a frontend form in the Panel Settings → Subscription Settings → JSON Settings section.
Specific code points for a PR
sub/subJsonService.go:33—NewSubJsonServicesignature and the init block; add new params and apply them toconfigJson["dns"]andconfigJson["routing"]afterjson.Unmarshal.sub/subController.go:54—NewSUBControllersignature.sub/sub.go:123–141— whereSubJsonFragment,SubJsonNoises, etc. are fetched; add analogous calls for the new getters.web/service/setting.go:59–85— defaults map; add e.g."subJsonDNSServers": "","subJsonDNSQueryStrategy": "","subJsonDomainStrategy": "".web/entity/entity.go:86–89—AllSettingstruct; add the three new fields.One subtlety:
dns.serversis a JSON array of objects (not a plain string), so the setting value would need to be stored as a JSON string and unmarshaled before being injected — the same approach used forsubJsonRulesandsubJsonFragment.If you'd like to open a PR, the five files above plus the React frontend component for the settings form are all that need to change.