fix(onlines): agent 在线名单按节点归因键存储(第12条修复A)
reportTraffic 旧实现把所有 agent 的在线名单写死存入 "agent" 键,
而入站页按 originNodeGuid / node:{id} 归因键查找,永远查不到:
agent 入站行永不亮在线,且所有 agent 节点被并进同一键。
改为 InboundService.SetAgentOnlineClients:按节点的 effectiveNodeKey
(有唯一 GUID 用 GUID、否则 node:{id})存入;空名单仍走
ClearNodeOnlineClients 清整棵子树。同步修正 online_store_test 中
断言旧键的用例注释与键名;新增两例服务层测试(双 agent 节点键互不
合并、空上报清空)。
This commit is contained in:
@@ -217,13 +217,7 @@ func (a *AgentController) reportTraffic(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
if agent.NodeID != nil {
|
||||
if len(req.Onlines) > 0 {
|
||||
a.inboundService.SetNodeOnlineTree(*agent.NodeID, map[string][]string{
|
||||
"agent": req.Onlines,
|
||||
})
|
||||
} else {
|
||||
a.inboundService.ClearNodeOnlineClients(*agent.NodeID)
|
||||
}
|
||||
a.inboundService.SetAgentOnlineClients(*agent.NodeID, req.Onlines)
|
||||
}
|
||||
a.touchAgent(uint(agent.Id), "")
|
||||
jsonObj(c, gin.H{"message": "ok"}, nil)
|
||||
|
||||
Reference in New Issue
Block a user