mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6054] [MERGED] fix(balancer): pin loopback routing rules ahead of general rules #6066
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#6066
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/6054
Author: @H-TTTTT
Created: 7/20/2026
Status: ✅ Merged
Merged: 7/21/2026
Merged by: @MHSanaei
Base:
main← Head:fix/balancer-loopback-order📝 Commits (2)
bc7bd67fix(balancer): pin loopback routing rules ahead of general rulesc34ddc1ci: re-trigger checks after flaky FuzzDecodeCertPin timeout📊 Changes
2 files changed (+122 additions, -4 deletions)
View changed files
📝
frontend/src/pages/xray/balancers/balancer-loopback.ts(+22 -4)📝
frontend/src/test/balancer-loopback.test.ts(+100 -0)📄 Description
Summary
`ensureBalancerLoopback` appended a balancer's fallback loopback rule (`{ inboundTag: ['bl'], balancerTag: }`) to the end of `routing.rules` via `Array.push`, and only updated `balancerTag` in place when the rule already existed.
Xray evaluates routing rules top-to-bottom, first match wins, and a general domain rule (no `inboundTag` restriction) matches every inbound — including the loopback one. So once such a general rule targeting the parent balancer ended up earlier in the array (added before the fallback was configured, or recreated later by an edit or by `ensureMissingBalancerLoopbacks`), the fallback re-entered routing through the `bl` loopback outbound, the general rule matched again, and traffic routed straight back into the parent balancer: an unbounded loop and the CPU spike reported. `detectBalancerCycles` only catches mutual fallback cycles, so a plain acyclic `Balancer1 -> Balancer2` chain passed silently.
Changes
Verification
Fixes #5960
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.