mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-16 15:17:14 +00:00
fix(inbounds): check ports when an inbound is enabled, not only when it is saved (#6549)
* fix(inbounds): check ports when an inbound is enabled, not only when it is saved The save-time guards compare enabled rows, so a row could be created while another disabled row held its port and only collide once the disabled one was switched on. Run the same checks before the flag moves: the refusal names the row that owns the port, the flag is left alone, and tcp/udp coexistence and node rows keep working. * docs(inbounds): state the real reason the enable path needs its own check
This commit is contained in:
@@ -1581,6 +1581,17 @@ func (s *InboundService) SetInboundEnable(id int, enable bool) (bool, error) {
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
// Enabling puts this row's ports into the running config, and the guards ran
|
||||
// only if it was saved: a restored or hand-edited row reaches it unchecked.
|
||||
if enable && inbound.NodeID == nil {
|
||||
conflict, err := checkPortConflictTx(db, inbound, inbound.Id)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if conflict != nil {
|
||||
return false, common.NewError(conflict.String())
|
||||
}
|
||||
}
|
||||
if err := db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := tx.Model(model.Inbound{}).Where("id = ?", id).
|
||||
Update("enable", enable).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user