[PR #6787] [MERGED] fix(panel): default TLS ALPN to http/1.1 for WebSocket transport #6454

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6787
Author: @HappyLeslieAlexander
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @MHSanaei

Base: main ← Head: fix/ws-tls-alpn-6782


📝 Commits (3)

  • ba4aafc fix(panel): default TLS ALPN to http/1.1 for WebSocket transport
  • f5187ee style(frontend): keep comments within the two-line limit
  • 685cd0b style(frontend): keep comments within the two-line limit

📊 Changes

4 files changed (+35 additions, -3 deletions)

View changed files

📝 frontend/src/lib/xray/inbound-tls-defaults.ts (+6 -1)
📝 frontend/src/pages/inbounds/form/InboundFormModal.tsx (+6 -0)
📝 frontend/src/pages/inbounds/form/useSecurityActions.ts (+2 -1)
📝 frontend/src/test/inbound-defaults.test.ts (+21 -1)

📄 Description

Summary

New TLS inbounds whose transport is WebSocket now default ALPN to ['http/1.1'] instead of ['h2', 'http/1.1'] — both when switching Security to TLS and when switching the transport to WebSocket while TLS is already on.

Why

Closes #6782. With the old default the panel wrote alpn=h2,http/1.1 into the Xray server config, the share links and the JSON subscriptions. Recent Xray-core clients offer exactly that ALPN (kept verbatim for camouflage in WebsocketHandshakeContext), the server negotiates h2, and the WebSocket handshake then fails with websocket: protocol "h2" was given but is not supported.

I verified this end-to-end with Xray-core v26.10.10 (VLESS + WS + TLS, self-signed certificate): ALPN h2,http/1.1 fails the handshake while http/1.1 alone works, and openssl s_client confirms the server negotiates h2 when offered. This follows the existing precedent from #4076, which pins ALPN to h3 when switching to the Hysteria protocol.

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?

  • Reproduced the reported failure end-to-end with Xray-core v26.10.10 before the fix (ALPN h2,http/1.1 → handshake fails; http/1.1 → works).
  • Added vitest cases for createTlsSettingsWithDefaultCert(network): ws yields ['http/1.1'], every other transport (and no argument) keeps the schema default ['h2','http/1.1'], plus a Zod round-trip asserting the overridden value still satisfies TlsStreamSettingsSchema.

Screenshots / recordings

N/A — form default change only; the ALPN field simply comes up with http/1.1 for new WebSocket+TLS inbounds.

Breaking changes

None. Only the default for newly created/changed selections is affected; existing inbounds keep their stored ALPN.

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. (frontend-only change; Go code untouched)
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass. (could not run the Node toolchain in this environment; leaving verification to CI)
  • I updated the Wiki / README / API docs if user-facing behavior changed. (no doc change needed — this restores the expected behavior)
  • 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/6787 **Author:** [@HappyLeslieAlexander](https://github.com/HappyLeslieAlexander) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/ws-tls-alpn-6782` --- ### 📝 Commits (3) - [`ba4aafc`](https://github.com/MHSanaei/3x-ui/commit/ba4aafc85b92e18374f08cbaabd0977cf739ac8a) fix(panel): default TLS ALPN to http/1.1 for WebSocket transport - [`f5187ee`](https://github.com/MHSanaei/3x-ui/commit/f5187eeb7ab39185f86ae2da7d5021e3384f70c3) style(frontend): keep comments within the two-line limit - [`685cd0b`](https://github.com/MHSanaei/3x-ui/commit/685cd0b91d8d478213e142d7ac9075d0deb450a8) style(frontend): keep comments within the two-line limit ### 📊 Changes **4 files changed** (+35 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/lib/xray/inbound-tls-defaults.ts` (+6 -1) 📝 `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (+6 -0) 📝 `frontend/src/pages/inbounds/form/useSecurityActions.ts` (+2 -1) 📝 `frontend/src/test/inbound-defaults.test.ts` (+21 -1) </details> ### 📄 Description ## Summary New TLS inbounds whose transport is WebSocket now default ALPN to `['http/1.1']` instead of `['h2', 'http/1.1']` — both when switching Security to TLS and when switching the transport to WebSocket while TLS is already on. ## Why Closes #6782. With the old default the panel wrote `alpn=h2,http/1.1` into the Xray server config, the share links and the JSON subscriptions. Recent Xray-core clients offer exactly that ALPN (kept verbatim for camouflage in `WebsocketHandshakeContext`), the server negotiates `h2`, and the WebSocket handshake then fails with `websocket: protocol "h2" was given but is not supported`. I verified this end-to-end with Xray-core v26.10.10 (VLESS + WS + TLS, self-signed certificate): ALPN `h2,http/1.1` fails the handshake while `http/1.1` alone works, and `openssl s_client` confirms the server negotiates `h2` when offered. This follows the existing precedent from #4076, which pins ALPN to `h3` when switching to the Hysteria protocol. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [x] 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? - Reproduced the reported failure end-to-end with Xray-core v26.10.10 before the fix (ALPN `h2,http/1.1` → handshake fails; `http/1.1` → works). - Added vitest cases for `createTlsSettingsWithDefaultCert(network)`: `ws` yields `['http/1.1']`, every other transport (and no argument) keeps the schema default `['h2','http/1.1']`, plus a Zod round-trip asserting the overridden value still satisfies `TlsStreamSettingsSchema`. ## Screenshots / recordings N/A — form default change only; the ALPN field simply comes up with `http/1.1` for new WebSocket+TLS inbounds. ## Breaking changes None. Only the default for newly created/changed selections is affected; existing inbounds keep their stored ALPN. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. (frontend-only change; Go code untouched) - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. (could not run the Node toolchain in this environment; leaving verification to CI) - [x] I updated the Wiki / README / API docs if user-facing behavior changed. (no doc change needed — this restores the expected behavior) - [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:53 +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#6454
No description provided.