[PR #6803] [MERGED] feat(sub): make the host "Mihomo X25519" switch drop ML-KEM #6459

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/6803
Author: @Toximiner
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei

Base: main ← Head: feat/host-mihomo-x25519


📝 Commits (6)

  • adad6af fix(sub): carry a reality host's fingerprint into Clash and JSON
  • 3660650 feat(sub): make the host "Mihomo X25519" switch drop ML-KEM
  • 0aaba17 fix(sub): give every host endpoint its own deep copy of the stream
  • 143a4d9 feat(database): clear Mihomo X25519 switches saved while they were ignored
  • 0726def Merge remote-tracking branch 'origin/main' into pr/6803
  • 8265315 Merge remote-tracking branch 'origin/main' into pr/6803

📊 Changes

24 files changed (+369 additions, -25 deletions)

View changed files

📝 docs/content/docs/en/config/reality.mdx (+5 -3)
📝 docs/content/docs/fa/config/reality.mdx (+9 -3)
📝 docs/content/docs/ru/config/reality.mdx (+6 -4)
📝 docs/content/docs/zh/config/reality.mdx (+1 -1)
📝 frontend/src/pages/hosts/HostFormModal.tsx (+1 -0)
📝 internal/database/db.go (+18 -1)
📝 internal/database/host_migration_test.go (+42 -0)
📝 internal/sub/clash_service.go (+7 -0)
📝 internal/sub/host_sub.go (+16 -0)
📝 internal/sub/host_sub_test.go (+224 -0)
📝 internal/sub/service.go (+27 -13)
📝 internal/web/translation/ar-EG.json (+1 -0)
📝 internal/web/translation/en-US.json (+1 -0)
📝 internal/web/translation/es-ES.json (+1 -0)
📝 internal/web/translation/fa-IR.json (+1 -0)
📝 internal/web/translation/id-ID.json (+1 -0)
📝 internal/web/translation/ja-JP.json (+1 -0)
📝 internal/web/translation/pt-BR.json (+1 -0)
📝 internal/web/translation/ru-RU.json (+1 -0)
📝 internal/web/translation/tr-TR.json (+1 -0)

...and 4 more files

📄 Description

Summary

Makes the existing per-host Mihomo X25519 switch actually do something: a host with it on gets support-x25519mlkem768: false in its Clash/Mihomo proxy and no ML-KEM hint in its vless:// link. Also fixes a reality host's fingerprint not reaching the Clash and JSON outputs, stops hosts of one inbound from leaking a blank-field override (SNI, fingerprint, Host header, path) into each other by deep-copying the stream per endpoint, and adds a one-time migration that resets switches saved while they had no effect.

Why

  • mihomoX25519 has been stored on hosts since #5409, but no renderer ever read it, so the switch had no effect.
  • #6451 then forced support-x25519mlkem768: true for every REALITY proxy. Its own Compatibility note says servers that should not get ML-KEM "need a per-node client override setting the option to false", but no such override exists.
  • Real-world case: on some networks DPI lets a few REALITY handshakes through and then drops the second TCP segment of every new ML-KEM ClientHello (~1.8 KB, two segments), blackholing the server's 443 for that client for minutes. A plain X25519 hello fits in one segment and passes. I reproduced this on two different servers, IPs and domains, with tcpdump on the server: SYN / SYN-ACK / ACK and the first 1348-byte segment arrive, the rest of the ClientHello never does. With Mihomo 1.19.32 against the same server, chrome without ML-KEM went 20/20 and chrome with ML-KEM 3/20. Today the only way to get the X25519 hello on such a network is to stay on 3x-ui 3.7.x, because 3.8.0+ hard-codes the flag.
  • With this change you can run current 3x-ui and keep Xray-core < 26.9.8 on that server (it accepts the X25519 hello), turning the switch on for the affected hosts only.
  • Separately, applyHostStreamOverrides copied a reality host's SNI into the client stream but not its fingerprint, so one host produced fp=firefox in vless:// and chrome in Clash/JSON. The bot review on #6451 flagged this as pre-existing.

Refs #5409, #6451, #6712.

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 tests in internal/sub/host_sub_test.go. Each one failed on main for the reported reason before the fix:

  • TestSub_HostRealityFingerprintJSONAndClash: a reality host with firefox yields fingerprint: firefox in JSON and client-fingerprint: firefox in Clash (was chrome).
  • TestSub_HostMihomoX25519Clash: two hosts on one reality inbound. The default host keeps support-x25519mlkem768: true, the host with the switch gets false.
  • TestSub_HostMihomoX25519RawLink: same setup, the default host's vless:// keeps support-x25519mlkem768=true and the switched host's link has no hint.
  • TestSub_HostBlankOverridesDoNotLeakBetweenHosts: two hosts on one inbound, the first sets an override and the second leaves it blank. The second must get the inbound's value in Clash and JSON. Cases: reality fingerprint + SNI, and ws Host + path.
  • TestMigrate_PreexistingMihomoX25519IsResetOnce: a row switched on before the upgrade is reset once, and a switch set after the upgrade survives a restart.

Also run:

  • go test ./... -shuffle=on -count=1: green.
  • golangci-lint run (v2.14.0): 0 issues.
  • Frontend: npm run typecheck, npm run lint, all unit vitest projects (1363 tests, including i18n-dead-keys), and npm run build pass.
  • End to end: built this branch, ran it on a copy of a real 3.10 database with two REALITY hosts and the switch on for one, then fetched the subscription. Clash: the switched host has support-x25519mlkem768: false and the other true, and both carry the host's firefox. Raw: only the non-switched host's link has support-x25519mlkem768=true.

Not run locally: the Storybook/Playwright test project and the full make verify. The only frontend change is a tooltip on an existing field.

Screenshots / recordings

Host form → Advanced → Clash (mihomo), with the new tooltip:

Mihomo X25519 tooltip

Breaking changes

None. The switch defaults to off. A one-time migration (HostMihomoX25519Reset) clears switches saved while they had no effect, so every existing subscription renders exactly as before; switches set after the upgrade persist. No schema change: the column already exists.

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.
  • 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.

The code in this PR was written with the help of an AI assistant (Claude). The DPI diagnosis and the checks above come from my own deployment.


🔄 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/6803 **Author:** [@Toximiner](https://github.com/Toximiner) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/host-mihomo-x25519` --- ### 📝 Commits (6) - [`adad6af`](https://github.com/MHSanaei/3x-ui/commit/adad6afb8ea616258d012883b4cb936eef98f964) fix(sub): carry a reality host's fingerprint into Clash and JSON - [`3660650`](https://github.com/MHSanaei/3x-ui/commit/3660650c4b9cc0ba741961c223c498df860de163) feat(sub): make the host "Mihomo X25519" switch drop ML-KEM - [`0aaba17`](https://github.com/MHSanaei/3x-ui/commit/0aaba17d59e9f7b4e6f1a69ffbd8972999b61b5c) fix(sub): give every host endpoint its own deep copy of the stream - [`143a4d9`](https://github.com/MHSanaei/3x-ui/commit/143a4d98635f212328e900610de1453cf1d08328) feat(database): clear Mihomo X25519 switches saved while they were ignored - [`0726def`](https://github.com/MHSanaei/3x-ui/commit/0726def509e75d5f7d30d9a3ef6af6c08b8bf9f4) Merge remote-tracking branch 'origin/main' into pr/6803 - [`8265315`](https://github.com/MHSanaei/3x-ui/commit/826531596b52d197e91e70b25f82803bd2923924) Merge remote-tracking branch 'origin/main' into pr/6803 ### 📊 Changes **24 files changed** (+369 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/config/reality.mdx` (+5 -3) 📝 `docs/content/docs/fa/config/reality.mdx` (+9 -3) 📝 `docs/content/docs/ru/config/reality.mdx` (+6 -4) 📝 `docs/content/docs/zh/config/reality.mdx` (+1 -1) 📝 `frontend/src/pages/hosts/HostFormModal.tsx` (+1 -0) 📝 `internal/database/db.go` (+18 -1) 📝 `internal/database/host_migration_test.go` (+42 -0) 📝 `internal/sub/clash_service.go` (+7 -0) 📝 `internal/sub/host_sub.go` (+16 -0) 📝 `internal/sub/host_sub_test.go` (+224 -0) 📝 `internal/sub/service.go` (+27 -13) 📝 `internal/web/translation/ar-EG.json` (+1 -0) 📝 `internal/web/translation/en-US.json` (+1 -0) 📝 `internal/web/translation/es-ES.json` (+1 -0) 📝 `internal/web/translation/fa-IR.json` (+1 -0) 📝 `internal/web/translation/id-ID.json` (+1 -0) 📝 `internal/web/translation/ja-JP.json` (+1 -0) 📝 `internal/web/translation/pt-BR.json` (+1 -0) 📝 `internal/web/translation/ru-RU.json` (+1 -0) 📝 `internal/web/translation/tr-TR.json` (+1 -0) _...and 4 more files_ </details> ### 📄 Description ## Summary Makes the existing per-host **Mihomo X25519** switch actually do something: a host with it on gets `support-x25519mlkem768: false` in its Clash/Mihomo proxy and no ML-KEM hint in its `vless://` link. Also fixes a reality host's fingerprint not reaching the Clash and JSON outputs, stops hosts of one inbound from leaking a blank-field override (SNI, fingerprint, Host header, path) into each other by deep-copying the stream per endpoint, and adds a one-time migration that resets switches saved while they had no effect. ## Why - `mihomoX25519` has been stored on hosts since #5409, but no renderer ever read it, so the switch had no effect. - #6451 then forced `support-x25519mlkem768: true` for every REALITY proxy. Its own Compatibility note says servers that should not get ML-KEM "need a per-node client override setting the option to `false`", but no such override exists. - Real-world case: on some networks DPI lets a few REALITY handshakes through and then drops the second TCP segment of every new ML-KEM ClientHello (~1.8 KB, two segments), blackholing the server's 443 for that client for minutes. A plain X25519 hello fits in one segment and passes. I reproduced this on two different servers, IPs and domains, with tcpdump on the server: SYN / SYN-ACK / ACK and the first 1348-byte segment arrive, the rest of the ClientHello never does. With Mihomo 1.19.32 against the same server, `chrome` without ML-KEM went 20/20 and `chrome` with ML-KEM 3/20. Today the only way to get the X25519 hello on such a network is to stay on 3x-ui 3.7.x, because 3.8.0+ hard-codes the flag. - With this change you can run current 3x-ui and keep Xray-core < 26.9.8 on that server (it accepts the X25519 hello), turning the switch on for the affected hosts only. - Separately, `applyHostStreamOverrides` copied a reality host's SNI into the client stream but not its fingerprint, so one host produced `fp=firefox` in `vless://` and `chrome` in Clash/JSON. The bot review on #6451 flagged this as pre-existing. Refs #5409, #6451, #6712. ## Type of change - [x] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [x] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [x] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [x] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? New tests in `internal/sub/host_sub_test.go`. Each one failed on `main` for the reported reason before the fix: - `TestSub_HostRealityFingerprintJSONAndClash`: a reality host with `firefox` yields `fingerprint: firefox` in JSON and `client-fingerprint: firefox` in Clash (was `chrome`). - `TestSub_HostMihomoX25519Clash`: two hosts on one reality inbound. The default host keeps `support-x25519mlkem768: true`, the host with the switch gets `false`. - `TestSub_HostMihomoX25519RawLink`: same setup, the default host's `vless://` keeps `support-x25519mlkem768=true` and the switched host's link has no hint. - `TestSub_HostBlankOverridesDoNotLeakBetweenHosts`: two hosts on one inbound, the first sets an override and the second leaves it blank. The second must get the inbound's value in Clash and JSON. Cases: reality fingerprint + SNI, and ws Host + path. - `TestMigrate_PreexistingMihomoX25519IsResetOnce`: a row switched on before the upgrade is reset once, and a switch set after the upgrade survives a restart. Also run: - `go test ./... -shuffle=on -count=1`: green. - `golangci-lint run` (v2.14.0): 0 issues. - Frontend: `npm run typecheck`, `npm run lint`, all `unit` vitest projects (1363 tests, including `i18n-dead-keys`), and `npm run build` pass. - End to end: built this branch, ran it on a copy of a real 3.10 database with two REALITY hosts and the switch on for one, then fetched the subscription. Clash: the switched host has `support-x25519mlkem768: false` and the other `true`, and both carry the host's `firefox`. Raw: only the non-switched host's link has `support-x25519mlkem768=true`. Not run locally: the Storybook/Playwright test project and the full `make verify`. The only frontend change is a tooltip on an existing field. ## Screenshots / recordings Host form → Advanced → Clash (mihomo), with the new tooltip: ![Mihomo X25519 tooltip](https://raw.githubusercontent.com/Toximiner/3x-ui/pr-assets/mihomo-x25519-tooltip.png) ## Breaking changes None. The switch defaults to off. A one-time migration (`HostMihomoX25519Reset`) clears switches saved while they had no effect, so every existing subscription renders exactly as before; switches set after the upgrade persist. No schema change: the column already exists. ## 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. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] 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. --- *The code in this PR was written with the help of an AI assistant (Claude). The DPI diagnosis and the checks above come from my own deployment.* --- <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#6459
No description provided.