[PR #5989] [MERGED] fix(xray): validate generated egress targets #6047

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5989
Author: @Alishahrokhiii
Created: 7/16/2026
Status: ✅ Merged
Merged: 7/21/2026
Merged by: @MHSanaei

Base: main ← Head: agent/validate-panel-egress-target


📝 Commits (3)

  • fdaf989 fix(xray): validate panel egress target
  • 4568031 fix(xray): guard node and mtproto egress
  • 8e37606 test(xray): complete node egress coverage

📊 Changes

2 files changed (+243 additions, -30 deletions)

View changed files

📝 internal/web/service/xray.go (+58 -29)
📝 internal/web/service/xray_config_inject_test.go (+185 -1)

📄 Description

What changed

  • validate panel, node, and MTProto egress selections against the final merged outbound tags or routing balancers
  • skip routing and loopback SOCKS bridge injection when a selected target disappeared or the relevant JSON is invalid
  • keep node injection independent so one invalid node target does not suppress valid node bridges
  • add regression coverage for missing subscription tags, malformed outbounds/routing, balancer targets, node tag/port collisions, and absent routing

Why

Panel, node, and routed MTProto egress can reference subscription-derived tags. If one of those tags disappears after a refresh or removal, the generated config could retain a routing rule pointing to a nonexistent target and expose a loopback SOCKS bridge that cannot forward traffic.

The shared guard now fails closed across all three generated egress paths: existing routing stays untouched and no unusable bridge is exposed. MTProto routing without an explicitly selected outbound keeps its existing default-route behavior.

Validation

  • go test ./internal/web/service -run '^TestInject(Panel|Node|Mtproto)Egress' -count=1
  • go test ./... -count=1
  • go test -race ./internal/web/service -run '^TestInject(Panel|Node|Mtproto)Egress' -count=1
  • go vet ./internal/web/service/...
  • npm run gen (clean)
  • npm run typecheck
  • npm run lint
  • npm run test (856 passed)
  • npm run build
  • npm run build-storybook

🔄 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/5989 **Author:** [@Alishahrokhiii](https://github.com/Alishahrokhiii) **Created:** 7/16/2026 **Status:** ✅ Merged **Merged:** 7/21/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `agent/validate-panel-egress-target` --- ### 📝 Commits (3) - [`fdaf989`](https://github.com/MHSanaei/3x-ui/commit/fdaf98918ba5f3bad999088400f86c632d71057d) fix(xray): validate panel egress target - [`4568031`](https://github.com/MHSanaei/3x-ui/commit/4568031d8fea8f36d4f58c556f552f95aad787c4) fix(xray): guard node and mtproto egress - [`8e37606`](https://github.com/MHSanaei/3x-ui/commit/8e3760681200d4181b7f3cbc7713d02037d7dda1) test(xray): complete node egress coverage ### 📊 Changes **2 files changed** (+243 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/xray.go` (+58 -29) 📝 `internal/web/service/xray_config_inject_test.go` (+185 -1) </details> ### 📄 Description ## What changed - validate panel, node, and MTProto egress selections against the final merged outbound tags or routing balancers - skip routing and loopback SOCKS bridge injection when a selected target disappeared or the relevant JSON is invalid - keep node injection independent so one invalid node target does not suppress valid node bridges - add regression coverage for missing subscription tags, malformed outbounds/routing, balancer targets, node tag/port collisions, and absent routing ## Why Panel, node, and routed MTProto egress can reference subscription-derived tags. If one of those tags disappears after a refresh or removal, the generated config could retain a routing rule pointing to a nonexistent target and expose a loopback SOCKS bridge that cannot forward traffic. The shared guard now fails closed across all three generated egress paths: existing routing stays untouched and no unusable bridge is exposed. MTProto routing without an explicitly selected outbound keeps its existing default-route behavior. ## Validation - `go test ./internal/web/service -run '^TestInject(Panel|Node|Mtproto)Egress' -count=1` - `go test ./... -count=1` - `go test -race ./internal/web/service -run '^TestInject(Panel|Node|Mtproto)Egress' -count=1` - `go vet ./internal/web/service/...` - `npm run gen` (clean) - `npm run typecheck` - `npm run lint` - `npm run test` (856 passed) - `npm run build` - `npm run build-storybook` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:00 +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#6047
No description provided.