mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5833] [MERGED] fix(inbound): scope port-conflict check to the stored node on update #6002
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#6002
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/5833
Author: @yukh975
Created: 7/6/2026
Status: ✅ Merged
Merged: 7/8/2026
Merged by: @MHSanaei
Base:
main← Head:fix/node-inbound-port-conflict📝 Commits (3)
45871f2fix(inbound): scope port-conflict check to the stored node on update1198713Merge branch 'main' into fix/node-inbound-port-conflictbeee9a1style(inbound): trim inline comments from port-conflict scoping📊 Changes
2 files changed (+32 additions, -5 deletions)
View changed files
📝
internal/web/service/inbound.go(+8 -5)📝
internal/web/service/inbound_update_tag_test.go(+24 -0)📄 Description
Problem
Editing an inbound that belongs to a node is rejected with a spurious port-conflict error when an unrelated inbound on the central panel (or another node) happens to reuse the same port. For example, changing a node inbound's listen address fails with:
and the edit is silently discarded. The two inbounds run on different machines, so there is no real conflict.
Root cause
InboundService.UpdateInboundrunscheckPortConflictbefore it restores the inbound'sNodeIDfrom the database:The request body's
nodeIdis unreliable for edits — it isjson:",omitempty"and the UI omits it — which is exactly why the code overwrites it with the stored value. But the conflict check has already run withinbound.NodeID == nil, so a node inbound is treated as a local/main-panel inbound.checkPortConflictcorrectly scopes candidates by node (sameNode); it was simply being fed the wrongNodeID.Fix
Restore
inbound.NodeIDfrom the stored row before the conflict check, so it runs against the node the inbound actually lives on.AddInboundis unaffected (there the request'snodeIdis authoritative at creation time).Test
Adds
TestUpdateInbound_NodeInboundNotBlockedByLocalSamePort: seeds a main-panel inbound and a node inbound on the same port, edits the node inbound's listen address withnodeIdomitted, and asserts it is not rejected as a conflict. Fails before this change with the exact "already used" error; passes after.go test ./internal/web/service/,gofmtandgo vetare green.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.