[PR #5984] [CLOSED] fix(xray): validate generated egress targets #6044

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5984
Author: @Alishahrokhiii
Created: 7/15/2026
Status: ❌ Closed

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


📝 Commits (2)

  • fdaf989 fix(xray): validate panel egress target
  • 4568031 fix(xray): guard node and mtproto egress

📊 Changes

2 files changed (+178 additions, -21 deletions)

View changed files

📝 internal/web/service/xray.go (+49 -20)
📝 internal/web/service/xray_config_inject_test.go (+129 -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, malformed MTProto routing, and valid balancer targets

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/5984 **Author:** [@Alishahrokhiii](https://github.com/Alishahrokhiii) **Created:** 7/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `agent/validate-panel-egress-target` --- ### 📝 Commits (2) - [`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 ### 📊 Changes **2 files changed** (+178 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/xray.go` (+49 -20) 📝 `internal/web/service/xray_config_inject_test.go` (+129 -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, malformed MTProto routing, and valid balancer targets ## 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:05:58 +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#6044
No description provided.