[PR #4126] [CLOSED] xray-setting: strip legacy reverse block on save (#4115) #5608

Closed
opened 2026-10-31 20:48:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4126
Author: @pwnnex
Created: 4/28/2026
Status: ❌ Closed

Base: main ← Head: fix/strip-legacy-reverse


📝 Commits (1)

  • 6a293b4 xray-setting: strip legacy reverse block on save

📊 Changes

3 files changed (+180 additions, -0 deletions)

View changed files

📝 web/html/settings/xray/reverse.html (+4 -0)
📝 web/service/xray_setting.go (+57 -0)
📝 web/service/xray_setting_test.go (+119 -0)

📄 Description

closes #4115.

what users see

after upgrading xray-core to v26+ (3x-ui v2.9.x ships v26.4.x), any panel that has reverse-proxy configured via xray configs > reverse-proxy fails to start xray with:

Failed to start: ... The feature "legacy reverse" has been removed and migrated to "VLESS Reverse Proxy". Please update your config(s) according to release note and documentation.

the proxy stops working entirely. the only fix today is for the admin to manually edit the saved template and remove the reverse block by hand, which most users won't figure out.

root cause

xray-core dropped the original reverse-proxy implementation (XTLS/Xray-core#5101) and replaced it with VLESS Reverse Proxy — a per-client field on a vless inbound, not a top-level block. the panel UI was still writing configs in the legacy shape:

"reverse": {
  "portals":  [{ "tag": "Portal1", "domain": "reverse.xui1" }],
  "bridges":  [{ "tag": "Bridge1", "domain": "reverse.xui1" }]
}

xray refuses to parse it from v26 onwards.

fix

  1. on SaveXraySetting, run the template through a new StripLegacyReverse helper. if the top-level reverse block carries portals or bridges, it gets removed silently and a warning is written to the panel log. the rest of the config stays valid, xray starts again, and the next save makes the cleanup permanent.

  2. added a deprecation banner to the reverse-proxy tab in the panel so admins stop generating new broken configs from the UI. the tab itself is not removed (would break re-editing for users still on older xray), just labeled.

the new VLESS Reverse Proxy uses a reverse field nested inside inbounds[].settings.clients[], not at the top level. the helper only matches the top-level legacy shape, so the new mechanism is left untouched (covered by TestStripLegacyReverse_DoesNotTouchNestedReverseFields).

a full UI rewrite to support VLESS Reverse Proxy would be a separate, larger PR. this one is a band-aid that unblocks broken servers.

tests

6 unit tests in xray_setting_test.go:

  • RemovesPortalsAndBridges — direct repro of the issue, both fields present
  • OnlyPortals — config with only one of the two
  • NoOpWhenNoReverseBlock — clean config returns identical string, no diff churn
  • LeavesNonLegacyReverseAlone — defensive, future-proofs against unrelated reverse fields
  • DoesNotTouchNestedReverseFields — pins the boundary with the new VLESS Reverse Proxy mechanism
  • InvalidJsonReturnsError — defensive on garbage input

go build ./..., go test ./..., gofmt all clean.


🔄 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/4126 **Author:** [@pwnnex](https://github.com/pwnnex) **Created:** 4/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/strip-legacy-reverse` --- ### 📝 Commits (1) - [`6a293b4`](https://github.com/MHSanaei/3x-ui/commit/6a293b4b2b525ee08cc4c3faff1d469a743cec1a) xray-setting: strip legacy reverse block on save ### 📊 Changes **3 files changed** (+180 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `web/html/settings/xray/reverse.html` (+4 -0) 📝 `web/service/xray_setting.go` (+57 -0) 📝 `web/service/xray_setting_test.go` (+119 -0) </details> ### 📄 Description closes #4115. ## what users see after upgrading xray-core to v26+ (3x-ui v2.9.x ships v26.4.x), any panel that has reverse-proxy configured via xray configs > reverse-proxy fails to start xray with: > `Failed to start: ... The feature "legacy reverse" has been removed and migrated to "VLESS Reverse Proxy". Please update your config(s) according to release note and documentation.` the proxy stops working entirely. the only fix today is for the admin to manually edit the saved template and remove the `reverse` block by hand, which most users won't figure out. ## root cause xray-core dropped the original reverse-proxy implementation (XTLS/Xray-core#5101) and replaced it with `VLESS Reverse Proxy` — a per-client field on a vless inbound, not a top-level block. the panel UI was still writing configs in the legacy shape: ```jsonc "reverse": { "portals": [{ "tag": "Portal1", "domain": "reverse.xui1" }], "bridges": [{ "tag": "Bridge1", "domain": "reverse.xui1" }] } ``` xray refuses to parse it from v26 onwards. ## fix 1. on `SaveXraySetting`, run the template through a new `StripLegacyReverse` helper. if the top-level `reverse` block carries `portals` or `bridges`, it gets removed silently and a warning is written to the panel log. the rest of the config stays valid, xray starts again, and the next save makes the cleanup permanent. 2. added a deprecation banner to the reverse-proxy tab in the panel so admins stop generating new broken configs from the UI. the tab itself is not removed (would break re-editing for users still on older xray), just labeled. the new VLESS Reverse Proxy uses a `reverse` field nested inside `inbounds[].settings.clients[]`, not at the top level. the helper only matches the top-level legacy shape, so the new mechanism is left untouched (covered by `TestStripLegacyReverse_DoesNotTouchNestedReverseFields`). a full UI rewrite to support VLESS Reverse Proxy would be a separate, larger PR. this one is a band-aid that unblocks broken servers. ## tests 6 unit tests in `xray_setting_test.go`: - `RemovesPortalsAndBridges` — direct repro of the issue, both fields present - `OnlyPortals` — config with only one of the two - `NoOpWhenNoReverseBlock` — clean config returns identical string, no diff churn - `LeavesNonLegacyReverseAlone` — defensive, future-proofs against unrelated `reverse` fields - `DoesNotTouchNestedReverseFields` — pins the boundary with the new VLESS Reverse Proxy mechanism - `InvalidJsonReturnsError` — defensive on garbage input `go build ./...`, `go test ./...`, `gofmt` all clean. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 20:48:09 +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#5608
No description provided.