[PR #6480] [MERGED] fix(link): restore mKCP seed and headerType on share-link import #6296

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6480
Author: @mrchatam
Created: 9/11/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @MHSanaei

Base: main ← Head: fix/mkcp-link-import-seed-header


📝 Commits (3)

  • 284b578 fix(link): restore mKCP seed and headerType on share-link import
  • c8065a8 fix(link): restore mKCP header/seed via finalmask mkcp-legacy
  • 2ac536d fix(link): split mKCP header and seed into separate masks on import

📊 Changes

4 files changed (+299 additions, -8 deletions)

View changed files

📝 frontend/src/lib/xray/outbound-link-parser.ts (+74 -8)
📝 frontend/src/test/outbound-link-parser.test.ts (+61 -0)
📝 internal/util/link/outbound.go (+90 -0)
📝 internal/util/link/outbound_helpers_test.go (+74 -0)

📄 Description

Summary

  • Share links for mKCP inbounds carry type=kcp&headerType=…&seed=… (plus mtu/tti), but both importers — Go internal/util/link/outbound.go and TS frontend/src/lib/xray/outbound-link-parser.ts — ignored them and kept the canned kcpSettings defaults.
  • On the pinned xray-core, kcpSettings.header/seed are parsed but never used (KCPConfig.Build reads only mtu/tti/capacities). The live obfuscation is the finalmask mkcp-legacy UDP mask, so import now rebuilds those masks from headerType/seed when the link carries no fm= mkcp-legacy mask (an fm= mask wins).
  • One mask per field, seed first: MkcpLegacy.Build ignores value once header is set (and reads it as the DNS domain for dns), and the finalmask array's first item is the innermost layer. [{header:"", value:<seed>}, {header:"wechat", value:""}] therefore puts the header around the cipher as legacy mKCP did, and matches what the panel's inbound form and the sub emitter model (one mask per field).
  • mtu/tti are copied onto kcpSettings only inside KCPConfig.Build's accepted ranges (mtu ≥ 21, tti 10..1000, decimal digits only on both importers). An out-of-range value would fail the whole Xray config load, so it keeps the buildStream default instead.
  • Header types are looked up as own properties in TS, so a prototype key such as constructor is not mapped.
  • Go and TS table tests cover: header+seed → two masks in order, header-only, seed-only, out-of-range and non-decimal mtu/tti, prototype key.

Not covered here (pre-existing): the vmess importers still have no kcp branch and ignore fm (the vmess emitter writes the header as type and the seed as path), and the TS share-link emitter emits only mtu/tti for kcp while the Go sub emitter also emits headerType/seed.

Fixes #6476

Test plan

  • go test ./internal/util/link/ -run TestParse_KcpShareParams
  • cd frontend && npx vitest run src/test/outbound-link-parser.test.ts
  • make verify
  • Create a VLESS inbound with network kcp and two mkcp-legacy masks (header: "" with a seed as value, and header: wechat); copy the client share link and confirm the query has type=kcp&headerType=wechat-video&seed=…
  • Import that link as an outbound with the fm= param removed (the panel's own link carries fm, which already round-trips); streamSettings.finalmask.udp must list {header:"", value:<seed>} then {header:"wechat", value:""}, and the outbound must connect to the inbound

🔄 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/6480 **Author:** [@mrchatam](https://github.com/mrchatam) **Created:** 9/11/2026 **Status:** ✅ Merged **Merged:** 9/13/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/mkcp-link-import-seed-header` --- ### 📝 Commits (3) - [`284b578`](https://github.com/MHSanaei/3x-ui/commit/284b578280dd00571394fc8472d6c4669a95fc6b) fix(link): restore mKCP seed and headerType on share-link import - [`c8065a8`](https://github.com/MHSanaei/3x-ui/commit/c8065a8f42add4d8170325465b4f1a43df2fc93e) fix(link): restore mKCP header/seed via finalmask mkcp-legacy - [`2ac536d`](https://github.com/MHSanaei/3x-ui/commit/2ac536d612a9b990ac02147259f90aa55dcdfe3c) fix(link): split mKCP header and seed into separate masks on import ### 📊 Changes **4 files changed** (+299 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/lib/xray/outbound-link-parser.ts` (+74 -8) 📝 `frontend/src/test/outbound-link-parser.test.ts` (+61 -0) 📝 `internal/util/link/outbound.go` (+90 -0) 📝 `internal/util/link/outbound_helpers_test.go` (+74 -0) </details> ### 📄 Description ## Summary - Share links for mKCP inbounds carry `type=kcp&headerType=…&seed=…` (plus `mtu`/`tti`), but both importers — Go `internal/util/link/outbound.go` and TS `frontend/src/lib/xray/outbound-link-parser.ts` — ignored them and kept the canned `kcpSettings` defaults. - On the pinned xray-core, `kcpSettings.header`/`seed` are parsed but never used (`KCPConfig.Build` reads only mtu/tti/capacities). The live obfuscation is the finalmask `mkcp-legacy` UDP mask, so import now rebuilds those masks from `headerType`/`seed` when the link carries no `fm=` mkcp-legacy mask (an `fm=` mask wins). - One mask per field, seed first: `MkcpLegacy.Build` ignores `value` once `header` is set (and reads it as the DNS domain for `dns`), and the finalmask array's first item is the innermost layer. `[{header:"", value:<seed>}, {header:"wechat", value:""}]` therefore puts the header around the cipher as legacy mKCP did, and matches what the panel's inbound form and the sub emitter model (one mask per field). - `mtu`/`tti` are copied onto `kcpSettings` only inside `KCPConfig.Build`'s accepted ranges (mtu ≥ 21, tti 10..1000, decimal digits only on both importers). An out-of-range value would fail the whole Xray config load, so it keeps the `buildStream` default instead. - Header types are looked up as own properties in TS, so a prototype key such as `constructor` is not mapped. - Go and TS table tests cover: header+seed → two masks in order, header-only, seed-only, out-of-range and non-decimal `mtu`/`tti`, prototype key. Not covered here (pre-existing): the vmess importers still have no kcp branch and ignore `fm` (the vmess emitter writes the header as `type` and the seed as `path`), and the TS share-link emitter emits only `mtu`/`tti` for kcp while the Go sub emitter also emits `headerType`/`seed`. Fixes #6476 ## Test plan - [x] `go test ./internal/util/link/ -run TestParse_KcpShareParams` - [x] `cd frontend && npx vitest run src/test/outbound-link-parser.test.ts` - [x] `make verify` - [ ] Create a VLESS inbound with network `kcp` and two mkcp-legacy masks (`header: ""` with a seed as value, and `header: wechat`); copy the client share link and confirm the query has `type=kcp&headerType=wechat-video&seed=…` - [ ] Import that link as an outbound with the `fm=` param removed (the panel's own link carries `fm`, which already round-trips); `streamSettings.finalmask.udp` must list `{header:"", value:<seed>}` then `{header:"wechat", value:""}`, and the outbound must connect to the inbound --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:46 +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#6296
No description provided.