mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-19 11:34:59 +03:00
feat(nodes): per-node client IP attribution for IP-limit
Record each panel's own Xray IP observations under its panelGuid and merge each node's guid-keyed report on the master, so the panel can tell which node a client IP is connecting through (the flat inbound_client_ips union is pushed back to every node and cannot attribute). Adds the NodeClientIp model + migration, the clientIpsByGuid endpoint and node-sync merge, node-name labels in the client IP log, and cleanup on node deletion.
This commit is contained in:
@@ -294,4 +294,15 @@ func (j *NodeTrafficSyncJob) syncOne(mgr *runtime.Manager, n *model.Node, doIpSy
|
||||
logger.Warning("node traffic sync: push client ips to", n.Name, "failed:", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Per-node IP attribution: pull the node's guid-keyed subtree (its own
|
||||
// observations plus any descendants) so the master can tell which node each
|
||||
// IP is on. Old nodes without the endpoint just return an error — skip them.
|
||||
if guidTrees, err := rt.FetchClientIpsByGuid(ctx); err != nil {
|
||||
logger.Debug("node traffic sync: fetch client ip attribution from", n.Name, "failed:", err)
|
||||
} else if len(guidTrees) > 0 {
|
||||
if err := j.inboundService.MergeClientIpsByGuid(guidTrees); err != nil {
|
||||
logger.Warning("node traffic sync: merge client ip attribution from", n.Name, "failed:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user