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"` }