mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-12 14:21:01 +00:00
fix: inbound edit validation failure and legacy copy to clipboard (#5132)
* fix: auto-enable clients when resetting traffic When a client's traffic is exhausted, the panel automatically disables the client and pushes enable: false to the nodes. However, when an admin clicked 'Reset Traffic' or used bulk reset, the counters were zeroed but the client was left disabled. This forced administrators to manually re-enable the client across the central panel and remote nodes. This patch updates ResetTrafficByEmail and BulkResetTraffic to automatically set Enable: true for any previously disabled client and push the updated settings to nodes, ensuring the client is instantly restored upon traffic reset. * fix: inbound edit validation failure and legacy copy to clipboard
This commit is contained in:
@@ -45,4 +45,4 @@ func (j *OutboundSubscriptionJob) Run() {
|
||||
// view (new outbounds will be visible after the reload cycle).
|
||||
websocket.BroadcastInvalidate(websocket.MessageTypeOutbounds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-2
@@ -1493,13 +1493,27 @@ func (s *ClientService) ResetTrafficByEmail(inboundSvc *InboundService, email st
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
needRestart := false
|
||||
if !rec.Enable {
|
||||
updated := rec.ToClient()
|
||||
updated.Enable = true
|
||||
nr, uErr := s.Update(inboundSvc, rec.Id, *updated)
|
||||
if uErr != nil {
|
||||
logger.Warning("Failed to auto-enable client during traffic reset:", uErr)
|
||||
}
|
||||
if nr {
|
||||
needRestart = true
|
||||
}
|
||||
}
|
||||
|
||||
if len(inboundIds) == 0 {
|
||||
if rErr := inboundSvc.ResetClientTrafficByEmail(email); rErr != nil {
|
||||
return false, rErr
|
||||
}
|
||||
return false, nil
|
||||
return needRestart, nil
|
||||
}
|
||||
needRestart := false
|
||||
|
||||
for _, ibId := range inboundIds {
|
||||
nr, rErr := inboundSvc.ResetClientTraffic(ibId, email)
|
||||
if rErr != nil {
|
||||
@@ -1809,6 +1823,15 @@ func (s *ClientService) BulkResetTraffic(inboundSvc *InboundService, emails []st
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
for _, e := range cleanEmails {
|
||||
rec, err := s.GetRecordByEmail(nil, e)
|
||||
if err == nil && !rec.Enable {
|
||||
updated := rec.ToClient()
|
||||
updated.Enable = true
|
||||
s.Update(inboundSvc, rec.Id, *updated)
|
||||
}
|
||||
}
|
||||
|
||||
affected := 0
|
||||
err := submitTrafficWrite(func() error {
|
||||
db := database.GetDB()
|
||||
|
||||
@@ -537,4 +537,4 @@ Consequences for balancers / routing:
|
||||
|
||||
We deliberately do *not* mutate the saved xrayTemplateConfig. Subscription
|
||||
outbounds are always injected at runtime in GetXrayConfig.
|
||||
*/
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user