mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-03 11:45:04 +03:00
fix(sync): preserve shared client lifecycle across nodes (#7038)
A client on inbounds of several nodes has one traffic row homed on one inbound, but the lifecycle merge looked it up in a node-scoped map. A node that was not the home therefore looked like it had no master state, so its stale enable or disable overwrote the shared record and adopted settings, flipping the client every tick, and a renewal on that node was missed. The merge now uses the global per-email traffic lookup, including clients reported only in settings.
This commit is contained in:
@@ -197,6 +197,23 @@ func (p *panel) deleteInboundRow(id int) {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *panel) setClientTrafficHome(email string, inboundID int) {
|
||||
p.t.Helper()
|
||||
if p.cmd != nil {
|
||||
p.t.Fatalf("%s: setClientTrafficHome on a running panel", p.name)
|
||||
}
|
||||
sharedDBMu.Lock()
|
||||
defer sharedDBMu.Unlock()
|
||||
if err := database.InitDB(filepath.Join(p.dir, "db", "x-ui.db")); err != nil {
|
||||
p.t.Fatalf("%s: open db: %v", p.name, err)
|
||||
}
|
||||
defer func() { _ = database.CloseDB() }()
|
||||
result := database.GetDB().Table("client_traffics").Where("email = ?", email).Update("inbound_id", inboundID)
|
||||
if result.Error != nil || result.RowsAffected != 1 {
|
||||
p.t.Fatalf("%s: set traffic home: rows=%d error=%v", p.name, result.RowsAffected, result.Error)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *panel) seedClientIpAttribution(email, ips string) string {
|
||||
p.t.Helper()
|
||||
if p.cmd != nil {
|
||||
|
||||
Reference in New Issue
Block a user