mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5648] [MERGED] fix(xray): clean stale routing references when a balancer or outbound is deleted #5947
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5947
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5648
Author: @nima1024m
Created: 6/29/2026
Status: ✅ Merged
Merged: 6/29/2026
Merged by: @MHSanaei
Base:
main← Head:fix/routing-rule-reference-cleanup📝 Commits (6)
6e6ed8ffeat(xray): reference-cleanup helpers for entity deletiona20ec5dfix(balancers): clean routing rules referencing a deleted balancer9fc3faefix(outbounds): clean rules, balancer selectors and dialerProxy on outbound delete4677bdbMerge remote-tracking branch 'origin/main' into fix/routing-rule-reference-cleanup9e95365refactor(xray): share one rule classifier across preview and applyc30f7b4fix(xray): null-guard reference cleanup against unvalidated configs📊 Changes
20 files changed (+634 additions, -75 deletions)
View changed files
➕
frontend/src/pages/xray/DeletionImpactList.tsx(+40 -0)📝
frontend/src/pages/xray/balancers/BalancersTab.tsx(+8 -14)📝
frontend/src/pages/xray/balancers/balancer-helpers.ts(+0 -16)📝
frontend/src/pages/xray/outbounds/OutboundsTab.tsx(+7 -5)➕
frontend/src/pages/xray/reference-cleanup.ts(+236 -0)📝
frontend/src/test/balancer-observatory-sync.test.ts(+1 -40)➕
frontend/src/test/routing-reference-cleanup.test.ts(+264 -0)📝
internal/web/translation/ar-EG.json(+6 -0)📝
internal/web/translation/en-US.json(+6 -0)📝
internal/web/translation/es-ES.json(+6 -0)📝
internal/web/translation/fa-IR.json(+6 -0)📝
internal/web/translation/id-ID.json(+6 -0)📝
internal/web/translation/ja-JP.json(+6 -0)📝
internal/web/translation/pt-BR.json(+6 -0)📝
internal/web/translation/ru-RU.json(+6 -0)📝
internal/web/translation/tr-TR.json(+6 -0)📝
internal/web/translation/uk-UA.json(+6 -0)📝
internal/web/translation/vi-VN.json(+6 -0)📝
internal/web/translation/zh-CN.json(+6 -0)📝
internal/web/translation/zh-TW.json(+6 -0)📄 Description
Problem
Deleting a balancer or outbound on the Xray Settings page left routing rules pointing at the removed entity. A dangling
balancerTagis fatal — xray-core'sRouter.Initreturns"balancer <tag> not found", so the whole core fails to (re)start and every inbound drops. A danglingoutboundTagblack-holes matched traffic at the dispatcher.CheckXrayConfigonly validates JSON shape, so the broken config saved cleanly and only detonated on the next core restart.Fix
When an outbound or balancer is deleted, the rules/balancers that reference it are repaired in the same edit, and the delete confirmation lists exactly what will change (modified vs removed):
outboundTagorbalancerTag); it is removed if none remains, since a destination-less rule black-holes its matched traffic.selectorcan empty the selector, which removes that balancer too — and then its rules are repaired the same way.fallbackTagand other outbounds'dialerProxyreferences are cleared, and observatories are re-synced.Pure logic lives in
frontend/src/pages/xray/reference-cleanup.ts(plan*for the preview,apply*for the mutation, sharing oneclassifyRuleso the preview can never disagree with the mutation), wired into the balancer/outbound delete modals via a sharedDeletionImpactList.Scope
RemoveInboundTagReferences).user[]pruning is deferred to a follow-up: a danglinguserentry is inert in xray-core, and client records are deleted from several scattered backend paths with no single chokepoint.Testing
fallbackTag/dialerProxycleanup, disabled rules, plan/apply parity, and the tagless/edge cases.Screenshots
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.