[PR #6691] [MERGED] fix(sub): keep serverNames out of a reality host's JSON client config #6414

Closed
opened 2026-11-02 04:08:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6691
Author: @FZ1010
Created: 9/30/2026
Status: ✅ Merged
Merged: 10/2/2026
Merged by: @MHSanaei

Base: main ← Head: fix/host-reality-sni-json


📝 Commits (2)

  • 1f5f458 fix(sub): keep serverNames out of a reality host's JSON client config
  • e2e3385 docs(sub): keep the host reality SNI comments within two lines

📊 Changes

2 files changed (+58 additions, -3 deletions)

View changed files

📝 internal/sub/host_sub.go (+2 -3)
📝 internal/sub/host_sub_test.go (+56 -0)

📄 Description

Summary

When a host with an SNI sits on a REALITY inbound, its client stream now gets only serverName, so the JSON subscription no longer ships the server-side serverNames list, which Xray-core refuses.

Why

Fixes #6690.

applyHostStreamOverrides set both serverName and serverNames, on the assumption that the JSON realityData reads serverNames later. But the JSON and Clash renderers both run streamData → realityData before the host overrides, so by then the stream is already in client form. serverNames was never read, and it ended up in the JSON proxy outbound. Xray-core then refuses the whole config:

infra/conf: Failed to build REALITY config. > infra/conf: non-empty "serverNames", please use "serverName" instead

This cuts off every JSON-subscription client (Happ, v2rayN/v2rayNG JSON mode, …) on an inbound whose host has an SNI. Share links were unaffected, and so was Clash: its renderer reads only serverName, so it keeps working with the one key.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • New TestSub_HostRealitySniJSONAndClash (internal/sub/host_sub_test.go). It seeds a REALITY inbound plus a host with an SNI, then checks that:

    • the JSON proxy outbound's realitySettings.serverName is the host SNI;
    • that outbound has no serverNames key;
    • the Clash proxy still has servername: <host SNI>.

    It failed before the change (serverNames [host.reality.com] leaked into the json reality client) and passes after.

  • go test -shuffle=on -count=1 ./internal/sub/... and go vet ./internal/sub/ pass.

  • End to end with real Xray-core: I rendered the same inbound + host through GetJson before and after the change and ran xray run -test -c on each config with Xray 26.7.28 and 26.9.9:

    • before: non-empty "serverNames", please use "serverName" instead
    • after: Configuration OK.

Screenshots / recordings

The new test on main (red), then on this branch (green), plus the whole internal/sub suite:

go test red/green

The same inbound + host rendered through GetJson on main (before.json) and on this branch (after.json), loaded with Xray-core 26.7.28 and 26.9.9:

xray run -test before/after

Breaking changes

None. Only the invalid serverNames key disappears from JSON subscriptions.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally. (go build ./... needs the frontend dist embed; the changed package builds, vets and tests clean.)
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6691 **Author:** [@FZ1010](https://github.com/FZ1010) **Created:** 9/30/2026 **Status:** ✅ Merged **Merged:** 10/2/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/host-reality-sni-json` --- ### 📝 Commits (2) - [`1f5f458`](https://github.com/MHSanaei/3x-ui/commit/1f5f458e6a5b8560e563f50d3a56d5979a6d266a) fix(sub): keep serverNames out of a reality host's JSON client config - [`e2e3385`](https://github.com/MHSanaei/3x-ui/commit/e2e3385ff49a499cf48d75329d2147c0086bf733) docs(sub): keep the host reality SNI comments within two lines ### 📊 Changes **2 files changed** (+58 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `internal/sub/host_sub.go` (+2 -3) 📝 `internal/sub/host_sub_test.go` (+56 -0) </details> ### 📄 Description ## Summary When a host with an SNI sits on a REALITY inbound, its client stream now gets only `serverName`, so the JSON subscription no longer ships the server-side `serverNames` list, which Xray-core refuses. ## Why Fixes #6690. `applyHostStreamOverrides` set both `serverName` and `serverNames`, on the assumption that the JSON `realityData` reads `serverNames` later. But the JSON and Clash renderers both run `streamData` → `realityData` *before* the host overrides, so by then the stream is already in client form. `serverNames` was never read, and it ended up in the JSON proxy outbound. Xray-core then refuses the whole config: ``` infra/conf: Failed to build REALITY config. > infra/conf: non-empty "serverNames", please use "serverName" instead ``` This cuts off every JSON-subscription client (Happ, v2rayN/v2rayNG JSON mode, …) on an inbound whose host has an SNI. Share links were unaffected, and so was Clash: its renderer reads only `serverName`, so it keeps working with the one key. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [x] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? - New `TestSub_HostRealitySniJSONAndClash` (`internal/sub/host_sub_test.go`). It seeds a REALITY inbound plus a host with an SNI, then checks that: - the JSON proxy outbound's `realitySettings.serverName` is the host SNI; - that outbound has no `serverNames` key; - the Clash proxy still has `servername: <host SNI>`. It failed before the change (`serverNames [host.reality.com] leaked into the json reality client`) and passes after. - `go test -shuffle=on -count=1 ./internal/sub/...` and `go vet ./internal/sub/` pass. - End to end with real Xray-core: I rendered the same inbound + host through `GetJson` before and after the change and ran `xray run -test -c` on each config with Xray 26.7.28 and 26.9.9: - before: `non-empty "serverNames", please use "serverName" instead` - after: `Configuration OK.` ## Screenshots / recordings The new test on `main` (red), then on this branch (green), plus the whole `internal/sub` suite: ![go test red/green](https://raw.githubusercontent.com/FZ1010/3x-ui/361062c3851321d9b361343b640f5029702d8cde/go-test-red-green.png) The same inbound + host rendered through `GetJson` on `main` (`before.json`) and on this branch (`after.json`), loaded with Xray-core 26.7.28 and 26.9.9: ![xray run -test before/after](https://raw.githubusercontent.com/FZ1010/3x-ui/361062c3851321d9b361343b640f5029702d8cde/xray-test-before-after.png) ## Breaking changes None. Only the invalid `serverNames` key disappears from JSON subscriptions. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. (`go build ./...` needs the frontend `dist` embed; the changed package builds, vets and tests clean.) - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:08:36 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6414
No description provided.