agent 每 60s 心跳捎带遥测: agentVersion/xrayVersion(按 mtime 缓存重读)/ uptime/最近一次主控请求 RTT/cpu%/mem%/公网 v4+v6(公网优先, ULA/私网兜底); 主控心跳处理按指针语义只存上报字段, 旧 agent 无遥测行为不变; agent_nodes 加法迁移存遥测, 节点列表对 agent 行覆写真值, panelVersion 显示 "agent <版本>", NodeView 新增 ipv4/ipv6。
42 lines
2.0 KiB
Go
42 lines
2.0 KiB
Go
package model
|
|
|
|
// AgentNode binds a lightweight agent (token-registered, no web panel) to a
|
|
// 3x-ui node row and carries the per-agent egress configuration.
|
|
//
|
|
// Agents are the only writers of their own LastSeen; the panel owns everything
|
|
// else. Raw tokens are never stored — only the SHA-256 hex of the token.
|
|
type AgentNode struct {
|
|
Id int `json:"id" gorm:"primaryKey;autoIncrement"`
|
|
TokenHash string `json:"-" gorm:"size:64;uniqueIndex"`
|
|
TokenPrefix string `json:"tokenPrefix" gorm:"size:16;index"`
|
|
Name string `json:"name"`
|
|
// NodeID is the 3x-ui node whose inbounds this agent serves. Nil means the
|
|
// token was issued but not yet bound to a node.
|
|
NodeID *int `json:"nodeId" gorm:"index"`
|
|
// Outbounds is the full xray "outbounds" JSON array pushed to this agent,
|
|
// replacing the template defaults. Empty means "use template defaults".
|
|
Outbounds string `json:"outbounds" gorm:"type:text"`
|
|
// RoutingRules is the full xray "routing.rules" JSON array pushed to this
|
|
// agent, replacing the template defaults. Empty means "use template defaults".
|
|
RoutingRules string `json:"routingRules" gorm:"type:text"`
|
|
LastSeen int64 `json:"lastSeen"`
|
|
CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime:milli"`
|
|
UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime:milli"`
|
|
|
|
// Heartbeat telemetry (P13): the agent piggybacks host/runtime facts on
|
|
// its 60s heartbeat and the panel overlays them onto the node list row.
|
|
// All fields are best-effort: an agent that never reported telemetry has
|
|
// TelemetryAt == 0 and the UI keeps showing "-" for its row.
|
|
AgentVersion string `json:"agentVersion"`
|
|
XrayVersion string `json:"xrayVersion"`
|
|
UptimeSecs uint64 `json:"uptimeSecs"`
|
|
LatencyMs int `json:"latencyMs"`
|
|
CpuPct float64 `json:"cpuPct"`
|
|
MemPct float64 `json:"memPct"`
|
|
IPv4 string `json:"ipv4"`
|
|
IPv6 string `json:"ipv6"`
|
|
// TelemetryAt is the unix-milli time of the last heartbeat that carried
|
|
// a telemetry object.
|
|
TelemetryAt int64 `json:"telemetryAt"`
|
|
}
|