[PR #6808] [MERGED] fix(link): read the XHTTP fields a vmess link carries inline #6460

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6808
Author: @jayhemnani9910
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @MHSanaei

Base: main ← Head: fix/link-vmess-xhttp-extra


📝 Commits (1)

  • b1bfb3e fix(link): read the XHTTP fields a vmess link carries inline

📊 Changes

2 files changed (+69 additions, -2 deletions)

View changed files

📝 internal/util/link/outbound.go (+23 -2)
📝 internal/util/link/outbound_helpers_test.go (+46 -0)

📄 Description

Summary

The Go share-link importer reads only three XHTTP fields from a vmess link: xPaddingBytes, scMaxEachPostBytes and scMinPostsIntervalMs. The panel's vmess links carry more, and some of them have to match the server. This makes the importer read the same XHTTP keys from vmess JSON that the TS importer already reads.

Why

A vless or trojan link puts the XHTTP extra fields in the extra param, and the Go importer copies all of them. A vmess link has no extra. The sub emitter writes the same fields at the top level of the vmess JSON (maps.Copy(obj, buildXhttpExtra(xhttp)), internal/sub/service.go:1777). parseVmess only picks up three of them (internal/util/link/outbound.go:189).

So a vmess XHTTP inbound that sets, for example, sessionIDPlacement: header or xPaddingObfsMode gets imported without those settings, and the outbound can't connect. The Go importer is used by outbound subscriptions (internal/web/service/outbound_subscription.go:398) and by client external links in the JSON subscription (internal/sub/external_config.go:216).

The TS importer already reads these keys from vmess JSON (applyXhttpStringFromJson, frontend/src/lib/xray/outbound-link-parser.ts:116), so only the Go side changes. The legacy sessionPlacement/sessionKey names are mapped as well, the same way the TS importer maps them.

Type of change

  • Bug fix

Areas affected

  • Subscription (share links / Clash / JSON)
  • Xray config generation

How was this tested?

  • New table test TestParse_VmessXhttpInlineFields (internal/util/link/outbound_helpers_test.go) covers session placement + padding obfs, uplink placement/method + xmux, and the legacy session keys. Without the fix every case fails (for example xhttpSettings.sessionIDPlacement = <nil>, want "header"). With the fix it passes.
  • go test -shuffle=on -count=1 ./...: 50 packages ok, same as on main.
  • Manual check on v3.10.0 with Xray-core 26.10.10, all local: I added vmess XHTTP (packet-up) inbounds with sessionIDPlacement: header and with xPaddingObfsMode on, and the same inbounds as vless for comparison. I imported each client's own subscription URL through outbound subscription preview (/panel/api/xray/outbound-subs/parse) and tested each outbound with /panel/api/xray/testOutbounds. On v3.10.0 the JSON-subscription outbound and the vless import connected, and the vmess import failed (EOF). With the fix the vmess imports also connect.

Breaking changes

None.

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.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass. (no frontend changes)
  • I updated the Wiki / README / API docs if user-facing behavior changed. (not needed)
  • 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/6808 **Author:** [@jayhemnani9910](https://github.com/jayhemnani9910) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/link-vmess-xhttp-extra` --- ### 📝 Commits (1) - [`b1bfb3e`](https://github.com/MHSanaei/3x-ui/commit/b1bfb3e04de54794edb86184e2389baf1a16f88b) fix(link): read the XHTTP fields a vmess link carries inline ### 📊 Changes **2 files changed** (+69 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `internal/util/link/outbound.go` (+23 -2) 📝 `internal/util/link/outbound_helpers_test.go` (+46 -0) </details> ### 📄 Description ## Summary The Go share-link importer reads only three XHTTP fields from a vmess link: `xPaddingBytes`, `scMaxEachPostBytes` and `scMinPostsIntervalMs`. The panel's vmess links carry more, and some of them have to match the server. This makes the importer read the same XHTTP keys from vmess JSON that the TS importer already reads. ## Why A vless or trojan link puts the XHTTP extra fields in the `extra` param, and the Go importer copies all of them. A vmess link has no `extra`. The sub emitter writes the same fields at the top level of the vmess JSON (`maps.Copy(obj, buildXhttpExtra(xhttp))`, `internal/sub/service.go:1777`). `parseVmess` only picks up three of them (`internal/util/link/outbound.go:189`). So a vmess XHTTP inbound that sets, for example, `sessionIDPlacement: header` or `xPaddingObfsMode` gets imported without those settings, and the outbound can't connect. The Go importer is used by outbound subscriptions (`internal/web/service/outbound_subscription.go:398`) and by client external links in the JSON subscription (`internal/sub/external_config.go:216`). The TS importer already reads these keys from vmess JSON (`applyXhttpStringFromJson`, `frontend/src/lib/xray/outbound-link-parser.ts:116`), so only the Go side changes. The legacy `sessionPlacement`/`sessionKey` names are mapped as well, the same way the TS importer maps them. ## Type of change - [x] Bug fix ## Areas affected - [x] Subscription (share links / Clash / JSON) - [x] Xray config generation ## How was this tested? - New table test `TestParse_VmessXhttpInlineFields` (`internal/util/link/outbound_helpers_test.go`) covers session placement + padding obfs, uplink placement/method + xmux, and the legacy session keys. Without the fix every case fails (for example `xhttpSettings.sessionIDPlacement = <nil>, want "header"`). With the fix it passes. - `go test -shuffle=on -count=1 ./...`: 50 packages ok, same as on main. - Manual check on v3.10.0 with Xray-core 26.10.10, all local: I added vmess XHTTP (packet-up) inbounds with `sessionIDPlacement: header` and with `xPaddingObfsMode` on, and the same inbounds as vless for comparison. I imported each client's own subscription URL through outbound subscription preview (`/panel/api/xray/outbound-subs/parse`) and tested each outbound with `/panel/api/xray/testOutbounds`. On v3.10.0 the JSON-subscription outbound and the vless import connected, and the vmess import failed (`EOF`). With the fix the vmess imports also connect. ## Breaking changes None. ## 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. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. (no frontend changes) - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. (not needed) - [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:55 +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#6460
No description provided.