[PR #6781] [MERGED] fix(sub): default VLESS client encryption to none when the inbound has none stored #6451

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

📋 Pull Request Information

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

Base: main ← Head: fix/sub-vless-default-encryption


📝 Commits (3)

  • c890ff8 fix(sub): default VLESS client encryption to none when the inbound has none stored
  • e4a97c2 Merge branch 'main' into fix/sub-vless-default-encryption
  • 96d0ee7 Merge branch 'main' into fix/sub-vless-default-encryption

📊 Changes

3 files changed (+44 additions, -9 deletions)

View changed files

📝 internal/sub/json_service.go (+1 -5)
📝 internal/sub/json_service_test.go (+33 -0)
📝 internal/sub/service.go (+10 -4)

📄 Description

Summary

A VLESS inbound whose settings have no encryption key gets "encryption": "" in every JSON subscription outbound, and Xray refuses to load that config. This treats a missing or empty value as none in the JSON outbound and in the share link.

Why

The encryption key is not always stored. An inbound added through POST /panel/api/inbounds/add with the body from the API docs ("decryption": "none" only, endpoints.ts:70) does not have it, and neither do VLESS inbounds saved by older panels that were never re-saved.

For those inbounds:

  • JSON subscription: genVless copies the empty value (internal/sub/json_service.go:878-884 on main). Xray-core 26.9.30 then fails with
    infra/conf: VLESS users: please add/set "encryption":"none" for every user.
    Every VLESS entry in the JSON subscription is unusable. VMess, Trojan and Shadowsocks entries in the same subscription load fine.
  • Share link: genVlessLink leaves the encryption parameter out (internal/sub/service.go:1229 on main).

The frontend schema already defaults this field to none (frontend/src/schemas/protocols/inbound/vless.ts, encryption: z.string().min(1).default('none')), and so does the docs generator (docs/lib/xray/outbounds.ts:152). The Go subscription code was the only path that did not. The fix adds one small helper, vlessClientEncryption, and both Go paths use it. A real vlessenc value is passed through unchanged.

Type of change

  • Bug fix

Areas affected

  • Subscription (share links / Clash / JSON)

How was this tested?

  • New test TestSubVlessEncryptionDefaultsToNone (internal/sub/json_service_test.go) covers three settings: key missing, key empty, and a vlessenc value. It checks both the JSON outbound and the share link. Without the fix it fails: json outbound encryption = "", want "none". With the fix it passes.
  • go test -shuffle=on -count=1 ./...: 49 packages ok, same as on main. golangci-lint run ./internal/sub/: 0 issues.
  • Manual check with a local panel and Xray-core 26.9.30: I added VLESS ws+tls, xhttp+tls and httpupgrade inbounds over the API without encryption, then fetched the JSON subscription and ran xray run -test -c on each config. Before the fix all three VLESS configs failed with the error above. After it, all 8 configs in the subscription print Configuration OK. The httpupgrade config, used without edits, connected through the server.

Breaking changes

None. Inbounds that store encryption give the same output as before.

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/6781 **Author:** [@jayhemnani9910](https://github.com/jayhemnani9910) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/sub-vless-default-encryption` --- ### 📝 Commits (3) - [`c890ff8`](https://github.com/MHSanaei/3x-ui/commit/c890ff82b87c3bb6d26cf92cfd23493c14729ebb) fix(sub): default VLESS client encryption to none when the inbound has none stored - [`e4a97c2`](https://github.com/MHSanaei/3x-ui/commit/e4a97c2268a1f24b57bc5e891a18a775f07a5f2a) Merge branch 'main' into fix/sub-vless-default-encryption - [`96d0ee7`](https://github.com/MHSanaei/3x-ui/commit/96d0ee7fc71b1ed51e5d4468f6bf9e19ff56c6c6) Merge branch 'main' into fix/sub-vless-default-encryption ### 📊 Changes **3 files changed** (+44 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `internal/sub/json_service.go` (+1 -5) 📝 `internal/sub/json_service_test.go` (+33 -0) 📝 `internal/sub/service.go` (+10 -4) </details> ### 📄 Description ## Summary A VLESS inbound whose settings have no `encryption` key gets `"encryption": ""` in every JSON subscription outbound, and Xray refuses to load that config. This treats a missing or empty value as `none` in the JSON outbound and in the share link. ## Why The `encryption` key is not always stored. An inbound added through `POST /panel/api/inbounds/add` with the body from the API docs (`"decryption": "none"` only, `endpoints.ts:70`) does not have it, and neither do VLESS inbounds saved by older panels that were never re-saved. For those inbounds: - JSON subscription: `genVless` copies the empty value (`internal/sub/json_service.go:878-884` on main). Xray-core 26.9.30 then fails with `infra/conf: VLESS users: please add/set "encryption":"none" for every user`. Every VLESS entry in the JSON subscription is unusable. VMess, Trojan and Shadowsocks entries in the same subscription load fine. - Share link: `genVlessLink` leaves the `encryption` parameter out (`internal/sub/service.go:1229` on main). The frontend schema already defaults this field to `none` (`frontend/src/schemas/protocols/inbound/vless.ts`, `encryption: z.string().min(1).default('none')`), and so does the docs generator (`docs/lib/xray/outbounds.ts:152`). The Go subscription code was the only path that did not. The fix adds one small helper, `vlessClientEncryption`, and both Go paths use it. A real vlessenc value is passed through unchanged. ## Type of change - [x] Bug fix ## Areas affected - [x] Subscription (share links / Clash / JSON) ## How was this tested? - New test `TestSubVlessEncryptionDefaultsToNone` (`internal/sub/json_service_test.go`) covers three settings: key missing, key empty, and a vlessenc value. It checks both the JSON outbound and the share link. Without the fix it fails: `json outbound encryption = "", want "none"`. With the fix it passes. - `go test -shuffle=on -count=1 ./...`: 49 packages ok, same as on main. `golangci-lint run ./internal/sub/`: 0 issues. - Manual check with a local panel and Xray-core 26.9.30: I added VLESS ws+tls, xhttp+tls and httpupgrade inbounds over the API without `encryption`, then fetched the JSON subscription and ran `xray run -test -c` on each config. Before the fix all three VLESS configs failed with the error above. After it, all 8 configs in the subscription print `Configuration OK`. The httpupgrade config, used without edits, connected through the server. ## Breaking changes None. Inbounds that store `encryption` give the same output as before. ## 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:52 +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#6451
No description provided.