perf(logging): aggregate disabled-client logs in Xray config generation (#7055)

GetXrayConfig logged one INFO line for every client whose traffic row is
disabled, on every config generation: each reconcile, restart and node
traffic sync, changed or not. With a few thousand expired clients that
flooded the journal and pushed everything else out of the panel's in-memory
log buffer. The line also said "Remove Inbound User", although nothing is
removed there; the client is only left out of the config being built.

A successful generation now writes one summary with the number of excluded
client entries and affected inbounds, and a failed one writes none. The
filter and the generated config are unchanged.

Closes #7054
This commit is contained in:
Hamed
2026-11-13 22:25:21 +03:30
committed by GitHub
parent 2fab6c3d50
commit 5297fd3c84
3 changed files with 210 additions and 1 deletions
+9 -1
View File
@@ -204,6 +204,7 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
if err != nil {
return nil, err
}
excludedClients, excludedInbounds := 0, 0
for _, inbound := range inbounds {
if !inbound.Enable {
continue
@@ -248,10 +249,11 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
finalClients := make([]any, 0, len(dbClients))
var wgPeers []any
excludedBefore := excludedClients
for i := range dbClients {
c := dbClients[i]
if enable, exists := enableMap[c.Email]; exists && !enable {
logger.Infof("Remove Inbound User %s due to expiration or traffic limit", c.Email)
excludedClients++
continue
}
if !c.Enable {
@@ -320,6 +322,9 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
}
finalClients = append(finalClients, entry)
}
if excludedClients > excludedBefore {
excludedInbounds++
}
var mutated bool
if inbound.Protocol == model.WireGuard {
@@ -491,6 +496,9 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
xrayConfig.RouterConfig = dropRefusedScript(xrayConfig.RouterConfig, "routing", routingScriptRefused)
xrayConfig.DNSConfig = dropRefusedScript(xrayConfig.DNSConfig, "dns", dnsScriptRefused)
if excludedClients > 0 {
logger.Infof("Xray config generated: excluded %d disabled client entries across %d inbounds", excludedClients, excludedInbounds)
}
return xrayConfig, nil
}