Documentation
¶
Index ¶
- Constants
- func AgentTransportLegacy(transport string) bool
- func AgentTransportThirdParty(transport string) bool
- func AgentUpgradeModels() []any
- func ForwardLegacyModels() []any
- func KernelForwardDNSModels() []any
- func KernelForwardModels() []any
- func KernelModels() []any
- func KernelNodeOperationModels() []any
- type AccessGroup
- type AccessGroupPlan
- type AccessGroupUser
- type AdminAPIToken
- type AdminCreateUserRequest
- type AgentCertificate
- type AgentDiagnosticTask
- type AgentEnrollment
- type AgentReportBatch
- type AgentTransport
- type AgentUpgradeCampaign
- type AgentUpgradeNode
- type AlipayConfig
- type AuditLog
- type AuthorizedKey
- type BackupConfig
- type BackupRecord
- type BaseServer
- type CommissionRecord
- type CommissionWithdraw
- type Coupon
- type CouponUsage
- type EPayConfig
- type EmailConfig
- type EncryptionSettings
- type Event
- type Forward
- type ForwardAgentBridgeTask
- type ForwardCleanAgent
- type ForwardLatencyBucket
- type ForwardLegacyArchive
- type ForwardLegacyDrop
- type ForwardLegacyNode
- type ForwardLinkCA
- type ForwardLinkCertificate
- type ForwardLog
- type ForwardNode
- type ForwardPortBinding
- type ForwardRoute
- type ForwardRule
- type ForwardRuntimeJob
- type ForwardStats
- type ForwardTrafficCursor
- type ForwardTunnel
- type ForwardUserTunnel
- type IdentityAccountLink
- type IdentityAuthority
- type IdentityCutoverEvent
- type IdentityRevocation
- type IdentitySessionRevocation
- type IdentityTokenKey
- type InviteCode
- type InviteConfig
- type KernelAlert
- type KernelForwardAllocation
- type KernelForwardCounter
- type KernelForwardDNSBinding
- type KernelForwardDNSNode
- type KernelForwardDNSProvider
- type KernelForwardNode
- type KernelForwardNodeReport
- type KernelForwardNodeState
- type KernelForwardPlan
- type KernelForwardRequest
- type KernelForwardRoute
- type KernelForwardTraffic
- type KernelNodeConfigStatus
- type KernelNodeDesiredConfig
- type KernelNodeOperation
- type KernelNodeOperationEvent
- type KernelNodeOperationTarget
- type KernelOperation
- type Knowledge
- type LoadBalancer
- type LoginRequest
- type LoginResponse
- type MFAConfig
- type MFALoginAttempt
- type ModuleCertificate
- type ModuleEnrollment
- type Node
- type NodeCredential
- type NodeGroup
- type NodeHeartbeatRequest
- type NodeLog
- type NodeOperationRevision
- type NodePluginLifecycle
- type NodePluginObservedState
- type NodeProtocol
- type NodeRegisterRequest
- type NodeRegisterResponse
- type NodeRuntimeHealthRequest
- type NodeSecretSplit
- type NodeServiceAssignment
- type NodeStatus
- type NotificationLog
- type NotificationTemplate
- type OnlineLog
- type OperationLog
- type Order
- type PackageBackupReference
- type PackageMigrationRun
- type PackageReportState
- type PackageRolloutLock
- type PackageRouteGeneration
- type PackageStorage
- type PackageValidationResult
- type ParsedNode
- type PayPalConfig
- type Payment
- type PaymentChannel
- type PaymentGateway
- type PaymentLog
- type PaymentRecord
- type Plan
- type PlanSubscriptionGroup
- type Plugin
- type PluginArtifact
- type PluginConfiguration
- type PluginInstallation
- type PluginLifecyclePlan
- type PluginLifecyclePlanStep
- type PluginRelease
- type PluginRuntime
- type PluginTargetLock
- type PluginTelemetryState
- type PluginTrustRoot
- type PluginWebUIAsset
- type ProtocolSecret
- type ProtocolTemplate
- type ProtocolType
- type QuotaPolicy
- type RegisterRequest
- type ResourceGrant
- type RouteModeRevision
- type ServerAnyTLS
- type ServerHysteria
- type ServerInfo
- type ServerRoute
- type ServerShadowsocks
- type ServerTUIC
- type ServerTrojan
- type ServerType
- type ServerVLESS
- type ServerVMess
- type ServiceCA
- type ServiceScope
- type SettingsRequest
- type ShadowMismatchSample
- type SpeedLimit
- type StatServer
- type StatUser
- type StripeConfig
- type SubscriberChange
- type SubscriberRequest
- type SubscriptionFormat
- type SubscriptionGroup
- type SubscriptionRequest
- type SubscriptionResponse
- type SubscriptionTemplate
- type SystemConfig
- type TelegramBot
- type TelegramChat
- type TelegramCommand
- type TelegramNotification
- type TelegramUser
- type TemplateRenderContext
- type Ticket
- type TicketMessage
- type Topology
- type TopologyDeployment
- type TopologyDeploymentStep
- type TopologyEdge
- type TopologyObservedState
- type TopologyRevision
- type TopologyVertex
- type TrafficLog
- type USDTConfig
- type User
- type UserActivity
- type UserLevel
- type UserMFA
- type UserSubscriptionGroup
- type WechatPayConfig
- type WireGuardPeer
- type X402Config
Constants ¶
const ( // AdminAPITokenScopeRead lets a token make safe requests (GET and HEAD) // on the administrator APIs, except the reads that answer a secret in // clear. AdminAPITokenScopeRead = "read" // AdminAPITokenScopeAdmin lets a token do what its owner may do on the // administrator APIs, except manage API tokens. AdminAPITokenScopeAdmin = "admin" )
Admin API token scopes.
const ( AgentDiagnosticTaskStatusPending = "pending" AgentDiagnosticTaskStatusDispatched = "dispatched" AgentDiagnosticTaskStatusCompleted = "completed" AgentDiagnosticTaskStatusFailed = "failed" )
const ( // AgentEnrollmentMethodCredential is a one-time anixagt_ credential // bound to a node. AgentEnrollmentMethodCredential = "enrollment_credential" // AgentEnrollmentMethodNodeAPIKey is a proxy node's API key (agents in // the field, and nodes minted by registration keys). AgentEnrollmentMethodNodeAPIKey = "node_api_key" // #nosec G101 -- names an enrollment method, not a credential. // AgentEnrollmentMethodForwardToken is a forward node's token. AgentEnrollmentMethodForwardToken = "forward_token" )
Agent enrollment methods: how the agent proved which node it runs on.
const ( // AgentTransportMTLSStream is the Agent Control stream authenticated by // a client certificate: the target transport. AgentTransportMTLSStream = "mtls-stream" // AgentTransportAPIKeyStream is the Agent Control stream authenticated // by the legacy node API key. AgentTransportAPIKeyStream = "apikey-stream" // AgentTransportHTTPLegacy is the legacy AnixOps-agent REST paths: // /api/v2/agent/*, /api/v2/node/*, /api/v2/forward/agent/rules and the // clean agent endpoints. AgentTransportHTTPLegacy = "http-legacy" // AgentTransportWebSocket is the agent and node WebSocket. AgentTransportWebSocket = "websocket" // AgentTransportUniProxy is the UniProxy REST API, which third-party // node software (V2bX, XrayR) uses too. AgentTransportUniProxy = "uniproxy" // AgentTransportV2boardGRPC is the v2board gRPC services, which // third-party node software uses too. AgentTransportV2boardGRPC = "v2board-grpc" // AgentTransportCleanAgent is a forward clean agent // (/api/v2/forward-agent/*); the inventory reads it from // v2_forward_clean_agent, it is never recorded here. AgentTransportCleanAgent = "clean-agent" )
Transports an AnixOps Agent (or third-party node software) was seen on, recorded in AgentTransport (node-ops-service.md, section 5.6).
const ( // AgentUpgradeRunning: batches are offered and evaluated. AgentUpgradeRunning = "running" // AgentUpgradePaused: no node is offered the upgrade and no batch // starts; nodes already offered are still evaluated, and a failed // batch still rolls back. AgentUpgradePaused = "paused" // AgentUpgradeRollingBack: a batch failed (or an administrator aborted // with rollback); its upgraded nodes are told to roll back. AgentUpgradeRollingBack = "rolling_back" // AgentUpgradeSucceeded: every batch passed (terminal). AgentUpgradeSucceeded = "succeeded" // AgentUpgradeRolledBack: a batch failed and was rolled back (terminal). AgentUpgradeRolledBack = "rolled_back" // AgentUpgradeAborted: an administrator stopped it (terminal). AgentUpgradeAborted = "aborted" )
Agent upgrade campaign statuses (forward-sdk.md section 9, O4; H19).
const ( // AgentUpgradeNodePending: not offered yet (its batch has not started, // or the node is offline or busy). AgentUpgradeNodePending = "pending" // AgentUpgradeNodeOffered: the agent.upgrade operation was sent and // acknowledged. AgentUpgradeNodeOffered = "offered" // AgentUpgradeNodeUpgrading: the Agent reported progress or handed the // release to its updater; Control waits for the new version in Hello. AgentUpgradeNodeUpgrading = "upgrading" // AgentUpgradeNodeSucceeded: the Agent reconnected with the target // version (or already ran it) and its configuration is healthy. AgentUpgradeNodeSucceeded = "succeeded" // AgentUpgradeNodeFailed: refused, failed to apply, did not reconnect // with the target version in time, or failed its configuration. AgentUpgradeNodeFailed = "failed" // AgentUpgradeNodeRolledBack: told to roll back after its batch failed. AgentUpgradeNodeRolledBack = "rolled_back" // AgentUpgradeNodeSkipped: not offered: its Agent does not negotiate // upgrade.v1, or it stayed offline for its whole batch. Not counted // in the batch's failure ratio. AgentUpgradeNodeSkipped = "skipped" )
Per-node states of a campaign.
const ( ForwardNodeTypeRelay = "relay" // 中转节点 ForwardNodeTypeExit = "exit" // 落地节点 )
ForwardNodeType 节点类型
const ( ForwardNodeStatusOffline = 0 ForwardNodeStatusOnline = 1 )
ForwardNodeStatus 节点状态
const ( ForwardAgentBridgeTaskStatusPending = "pending" ForwardAgentBridgeTaskStatusDispatched = "dispatched" ForwardAgentBridgeTaskStatusCompleted = "completed" ForwardAgentBridgeTaskStatusFailed = "failed" )
const ( ForwardCleanAgentStatusRevoked = -1 ForwardCleanAgentStatusOffline = 0 ForwardCleanAgentStatusOnline = 1 )
const ( ForwardLinkCAStateCurrent = "current" ForwardLinkCAStateNext = "next" ForwardLinkCAStateRetired = "retired" )
Forward link CA states, as the module CA's (ServiceCAState*): the current CA signs, a next CA is trusted before it signs, a retired CA stays trusted until the link certificates it signed have expired.
const ( LatencyTargetTypeForward = "forward" // forward -> remote_addr 目标 LatencyTargetTypeTunnelNode = "tunnel_node" // 隧道中继/出口节点端点 LatencyTargetTypeForwardNode = "forward_node" // ForwardNode 管理端点 (HealthCheck) LatencyTargetTypeNode = "node" // 常规代理节点 v2_node (V2bX 注册) )
LatencyTargetType 延迟探测目标类型
const ( ForwardTunnelStatusDisabled = 0 ForwardTunnelStatusActive = 1 )
const ( ForwardStatusPaused = 0 ForwardStatusActive = 1 ForwardStatusError = -1 )
const ( ForwardUserTunnelStatusDisabled = 0 ForwardUserTunnelStatusActive = 1 )
const ( ForwardRuntimeBackendGost = "gost" ForwardRuntimeBackendNftablesAnsible = "nftables_ansible" ForwardRuntimeBackendIptablesAnsible = "iptables_ansible" ForwardRuntimeBackendCleanAgent = "clean_agent" )
const ( // These status values are also used by Forward.RuntimeStatus as the latest runtime sync state. ForwardRuntimeJobStatusPending = 0 ForwardRuntimeJobStatusRunning = 1 ForwardRuntimeJobStatusSuccess = 2 ForwardRuntimeJobStatusFailed = 3 )
const ( ForwardRuntimeJobActionCreate = "create" ForwardRuntimeJobActionUpdate = "update" ForwardRuntimeJobActionDelete = "delete" ForwardRuntimeJobActionPause = "pause" ForwardRuntimeJobActionResume = "resume" ForwardRuntimeJobActionSync = "sync" )
const ( // IdentityAuthorityKernel: the kernel's legacy handlers own logins. IdentityAuthorityKernel = "kernel" // IdentityAuthorityImporting: accounts are being copied to identity. IdentityAuthorityImporting = "importing" // IdentityAuthorityIdentity: identity owns logins and mirrors // credentials back, so switching to legacy is an instant rollback. IdentityAuthorityIdentity = "identity" // IdentityAuthorityFinalized: legacy credentials are gone; no mirror. IdentityAuthorityFinalized = "finalized" )
Identity authority states: which side owns credentials.
const ( IdentityCutoverActionCutover = "cutover" IdentityCutoverActionAborted = "cutover_aborted" IdentityCutoverActionRollback = "rollback" IdentityCutoverActionFinalize = "finalize" )
Identity cutover actions, recorded in IdentityCutoverEvent.
const ( KernelAlertWarning = "warning" KernelAlertCritical = "critical" )
Kernel alert severities.
const ( MFAMethodTOTP = "totp" // TOTP验证器 MFAMethodSMS = "sms" // 短信验证 MFAMethodEmail = "email" // 邮箱验证 MFAMethodBackup = "backup" // 备用码 )
MFAMethod MFA方式
const ( ServiceCAStateNext = "next" ServiceCAStateCurrent = "current" ServiceCAStateRetired = "retired" )
Service CA states.
const ( PluginRuntimeLocal = "local" PluginRuntimeRemote = "remote" )
Package runtimes.
const ( // ConfigVerdictApplied: the agent applied the node's desired // configuration, at its revision and hash. ConfigVerdictApplied = "applied" // ConfigVerdictFailed: the agent could not apply the node's desired // configuration, at its revision and hash. ConfigVerdictFailed = "failed" // ConfigVerdictStale: the status names a revision older than the // node's desired one. ConfigVerdictStale = "stale" // ConfigVerdictMismatch: the status names the desired revision with // another hash, a revision the kernel never stored, or a node without // a desired configuration. ConfigVerdictMismatch = "mismatch" )
Verdicts of an agent's ConfigStatus, as KernelNodeConfigStatus.Verdict records them (node-ops-service.md section 5.5).
const ( // 用户相关 EventUserRegister = "user.register" // 用户注册 EventUserLogin = "user.login" // 用户登录 (新设备) EventUserPasswordReset = "user.password_reset" // 密码重置 EventUserMFAEnabled = "user.mfa_enabled" // MFA启用 // 账户状态 EventUserExpire = "user.expire" // 用户到期 (提前通知) EventUserExpired = "user.expired" // 用户已到期 EventUserTrafficLow = "user.traffic_low" // 流量不足 EventUserTrafficExhausted = "user.traffic_exhausted" // 流量耗尽 EventUserBanned = "user.banned" // 用户被封禁 // 订单支付 EventOrderCreated = "order.created" // 订单创建 EventOrderPaid = "order.paid" // 订单支付成功 EventOrderExpired = "order.expired" // 订单过期 EventOrderRefunded = "order.refunded" // 订单退款 // 工单系统 EventTicketCreated = "ticket.created" // 工单创建 EventTicketReplied = "ticket.replied" // 工单回复 EventTicketClosed = "ticket.closed" // 工单关闭 // 节点相关 EventNodeOffline = "node.offline" // 节点离线 EventNodeOnline = "node.online" // 节点上线 EventNodeHighLoad = "node.high_load" // 节点高负载 // 系统通知 EventSystemBroadcast = "system.broadcast" // 系统广播 EventSystemMaintenance = "system.maintenance" // 维护通知 EventSystemAlert = "system.alert" // 内核告警摘要 (证书到期, 阶段停滞) )
NotificationEvent 通知事件
const ( PaymentMethodCrypto = "crypto" // 虚拟货币支付 (X402) PaymentMethodFiat = "fiat" // 法币支付 (Stripe/PayPal等) )
PaymentMethod 支付方式枚举
const ( // 虚拟货币支付提供商 PaymentProviderX402 = "x402" // X402 协议 // 法币支付提供商 PaymentProviderStripe = "stripe" PaymentProviderPayPal = "paypal" PaymentProviderAlipay = "alipay" PaymentProviderWechatPay = "wechat_pay" )
PaymentProvider 支付提供商枚举
const ( PaymentStatusPending = 0 // 待支付 PaymentStatusPaid = 1 // 已支付 PaymentStatusCancelled = 2 // 已取消 PaymentStatusRefunded = 3 // 已退款 PaymentStatusExpired = 4 // 已过期 )
PaymentStatus 支付状态枚举
const ( PaymentGatewayAlipay = "alipay" // 支付宝 PaymentGatewayWechat = "wechat" // 微信支付 PaymentGatewayEPay = "epay" // EPay通用支付 PaymentGatewayUSDT = "usdt" // USDT加密货币 (TRC20/ERC20) PaymentGatewayStripe = "stripe" // Stripe信用卡 PaymentGatewayPayPal = "paypal" // PayPal PaymentGatewayX402 = "x402" // X402虚拟货币协议 )
PaymentGatewayType 支付网关类型
const ( PackageMigrationStateRunning = "running" PackageMigrationStateCompleted = "completed" PackageMigrationStateFailed = "failed" PackageValidationStateValidated = "validated" PackageRouteGenerationStateValidated = "validated" PackageRouteGenerationStateRolledBack = "rolled_back" )
const ( RouteModeRevisionActionSet = "set" RouteModeRevisionActionRollback = "rollback" )
Route-mode revision actions, recorded in RouteModeRevision.
const ( SpeedLimitStatusDisabled = 0 SpeedLimitStatusActive = 1 )
const ( NotificationTypeExpire = "expire" // 到期通知 NotificationTypeTraffic = "traffic" // 流量不足 NotificationTypeTicket = "ticket" // 工单回复 NotificationTypeSystem = "system" // 系统通知 NotificationTypePayment = "payment" // 支付通知 NotificationTypeNode = "node" // 节点通知 )
NotificationType 通知类型
const AgentUpgradeActiveSlot = "active"
AgentUpgradeActiveSlot is AgentUpgradeCampaign.ActiveSlot of the one campaign that is not terminal.
const UnusableLegacyPassword = "!identity"
UnusableLegacyPassword is stored in v2_user.password for accounts whose credentials live in identity. It never matches a password.
Variables ¶
This section is empty.
Functions ¶
func AgentTransportLegacy ¶ added in v4.1.0
AgentTransportLegacy tells whether transport is a legacy AnixOps Agent channel, one agent_control.mtls: required refuses.
func AgentTransportThirdParty ¶ added in v4.1.0
AgentTransportThirdParty tells whether transport is a node protocol that third-party node software shares, which agent_control.mtls never refuses.
func AgentUpgradeModels ¶ added in v4.2.0
func AgentUpgradeModels() []any
AgentUpgradeModels are the tables of Agent upgrade campaigns.
func ForwardLegacyModels ¶ added in v4.2.0
func ForwardLegacyModels() []any
ForwardLegacyModels are the upgrade's tables.
func KernelForwardDNSModels ¶ added in v4.2.0
func KernelForwardDNSModels() []any
KernelForwardDNSModels are the entry HA tables.
func KernelForwardModels ¶ added in v4.2.0
func KernelForwardModels() []any
KernelForwardModels are the kernel's forwarding tables.
func KernelModels ¶
func KernelModels() []any
func KernelNodeOperationModels ¶ added in v4.1.0
func KernelNodeOperationModels() []any
KernelNodeOperationModels are the KernelNodeOps tables.
Types ¶
type AccessGroup ¶
type AccessGroup struct {
ID uint `gorm:"primaryKey" json:"id"`
ScopeID string `gorm:"size:64;not null;uniqueIndex:ux_access_group_scope_name" json:"scope_id"`
Name string `gorm:"size:120;not null;uniqueIndex:ux_access_group_scope_name" json:"name"`
Description string `gorm:"type:text" json:"description"`
Enabled bool `gorm:"not null" json:"enabled"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (AccessGroup) TableName ¶
func (AccessGroup) TableName() string
type AccessGroupPlan ¶
type AccessGroupPlan struct {
ID uint `gorm:"primaryKey" json:"id"`
GroupID uint `gorm:"not null;uniqueIndex:ux_access_group_plan" json:"group_id"`
PlanID uint `gorm:"not null;uniqueIndex:ux_access_group_plan;index" json:"plan_id"`
CreatedAt time.Time `json:"created_at"`
}
func (AccessGroupPlan) TableName ¶
func (AccessGroupPlan) TableName() string
type AccessGroupUser ¶
type AccessGroupUser struct {
ID uint `gorm:"primaryKey" json:"id"`
GroupID uint `gorm:"not null;uniqueIndex:ux_access_group_user" json:"group_id"`
UserID uint `gorm:"not null;uniqueIndex:ux_access_group_user;index" json:"user_id"`
CreatedAt time.Time `json:"created_at"`
}
func (AccessGroupUser) TableName ¶
func (AccessGroupUser) TableName() string
type AdminAPIToken ¶ added in v4.2.0
type AdminAPIToken struct {
ID string `gorm:"primaryKey;size:36" json:"id"`
UserID uint `gorm:"not null;index" json:"user_id"`
Name string `gorm:"size:100;not null" json:"name"`
// TokenHash is the hex SHA-256 of the token; it is the lookup key.
TokenHash string `gorm:"size:64;not null;uniqueIndex" json:"-"`
// Hint is the last four characters of the token, to tell tokens apart.
Hint string `gorm:"size:8;not null" json:"hint"`
Scope string `gorm:"size:16;not null" json:"scope"`
ExpiresAt *time.Time `json:"expires_at"`
LastUsedAt *time.Time `json:"last_used_at"`
LastUsedIP string `gorm:"size:45" json:"last_used_ip,omitempty"`
CreatedIP string `gorm:"size:45" json:"created_ip,omitempty"`
CreatedAt time.Time `json:"created_at"`
RevokedAt *time.Time `json:"revoked_at"`
// OwnerEmail is the owner's current email, filled in when tokens are
// listed so an administrator who lists everyone's tokens can tell whose
// they are. It is not a column.
OwnerEmail string `gorm:"-" json:"owner_email,omitempty"`
// RevokeReason says why the token ended: owner_revoked, admin_revoked or
// owner_not_admin (the owner was banned, demoted or deleted when it was
// used).
RevokeReason string `gorm:"size:32" json:"revoke_reason,omitempty"`
}
AdminAPIToken is an administrator's personal access token for automation. Only the SHA-256 of the token is stored: the token itself is shown once, in the answer that creates it. The owner's rights are read from v2_user on every use, so a banned, demoted or deleted administrator's tokens stop working at once.
func (AdminAPIToken) TableName ¶ added in v4.2.0
func (AdminAPIToken) TableName() string
type AdminCreateUserRequest ¶
type AdminCreateUserRequest struct {
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required,min=6"`
IsAdmin int `json:"is_admin"`
FlowResetTime int64 `json:"flowResetTime"`
GroupID *uint `json:"group_id"`
TransferEnable *int64 `json:"transfer_enable"`
SpeedLimit *int64 `json:"speed_limit"`
DeviceLimit *int `json:"device_limit"`
}
AdminCreateUserRequest 管理员创建用户请求
type AgentCertificate ¶ added in v4.1.0
type AgentCertificate struct {
Serial string `gorm:"primaryKey;size:40" json:"serial"`
NodeKind string `gorm:"size:16;not null;index:idx_v4_kernel_agent_certificate_node,priority:1" json:"node_kind"`
NodeID uint `gorm:"not null;index:idx_v4_kernel_agent_certificate_node,priority:2" json:"node_id"`
Cluster string `gorm:"size:63;not null" json:"cluster"`
EnrollmentID string `gorm:"size:36;not null;index" json:"enrollment_id"`
IssuerKeyID string `gorm:"size:64;not null" json:"issuer_key_id"`
NotAfter time.Time `gorm:"not null;index" json:"not_after"`
RevokedAt *time.Time `json:"revoked_at"`
RevokeReason string `gorm:"size:64" json:"revoke_reason,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AgentCertificate records every certificate the agent PKI issued, so the agent listener can refuse revoked serials and revoking a node's credentials revokes its certificates.
func (AgentCertificate) TableName ¶ added in v4.1.0
func (AgentCertificate) TableName() string
type AgentDiagnosticTask ¶
type AgentDiagnosticTask struct {
ID uint `gorm:"primaryKey" json:"id"`
TaskID string `gorm:"size:80;uniqueIndex" json:"task_id"`
NodeID uint `gorm:"index" json:"node_id"`
Action string `gorm:"size:40" json:"action"`
Params string `gorm:"type:text" json:"params,omitempty"`
Status string `gorm:"size:20;index" json:"status"`
Success bool `json:"success"`
Output string `gorm:"type:text" json:"output,omitempty"`
Error string `gorm:"type:text" json:"error,omitempty"`
DurationMS int64 `json:"duration_ms"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"timestamp"`
}
AgentDiagnosticTask 持久化白名单诊断任务(NodeX Agent 终端功能),使任务结果在 面板进程重启后仍可查询,不再依赖 AgentHandler.taskResults 这张纯内存表。 JSON 字段沿用原 AgentTaskStatus 的 snake_case 命名,保持与前端 Agent.vue 的契约不变。
func (AgentDiagnosticTask) TableName ¶
func (AgentDiagnosticTask) TableName() string
type AgentEnrollment ¶ added in v4.1.0
type AgentEnrollment struct {
ID string `gorm:"primaryKey;size:36" json:"id"`
NodeKind string `gorm:"size:16;not null;index:idx_v4_kernel_agent_enrollment_node,priority:1" json:"node_kind"`
NodeID uint `gorm:"not null;index:idx_v4_kernel_agent_enrollment_node,priority:2" json:"node_id"`
Cluster string `gorm:"size:63;not null" json:"cluster"`
Method string `gorm:"size:32;not null" json:"method"`
// CredentialHash is set for AgentEnrollmentMethodCredential only.
CredentialHash *string `gorm:"size:64;uniqueIndex" json:"-"`
ExpiresAt *time.Time `json:"expires_at"`
UsedAt *time.Time `json:"used_at"`
RevokedAt *time.Time `json:"revoked_at"`
RevokeReason string `gorm:"size:64" json:"revoke_reason,omitempty"`
AgentVersion string `gorm:"size:64" json:"agent_version,omitempty"`
InstanceID string `gorm:"size:128" json:"instance_id,omitempty"`
CreatedBy uint `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
}
AgentEnrollment is one way into the agent PKI for a node: a one-time enrollment credential an administrator issued (only its SHA-256 is kept), or an enrollment the agent made with its node credential. Every agent certificate points at the enrollment it descends from; revoking the enrollment stops its renewals.
func (AgentEnrollment) TableName ¶ added in v4.1.0
func (AgentEnrollment) TableName() string
type AgentReportBatch ¶ added in v4.1.0
type AgentReportBatch struct {
NodeKind string `gorm:"primaryKey;size:16" json:"node_kind"`
NodeID uint `gorm:"primaryKey" json:"node_id"`
BatchID string `gorm:"primaryKey;size:128" json:"batch_id"`
Kind string `gorm:"size:16;not null" json:"kind"`
CreatedAt time.Time `gorm:"not null;index" json:"created_at"`
}
AgentReportBatch records a report batch an agent delivered on the Agent Control stream (reports.v1): a TrafficReport or a LogBatch, by the node's kind and id and the batch id the agent chose. The kernel applies a batch in the transaction that creates its row, so a batch counts once however often the agent resends it; a replay is answered from the row. Rows older than the retention are pruned (internal/agentreports).
func (AgentReportBatch) TableName ¶ added in v4.1.0
func (AgentReportBatch) TableName() string
type AgentTransport ¶ added in v4.1.0
type AgentTransport struct {
NodeKind string `gorm:"primaryKey;size:16" json:"node_kind"`
NodeID uint `gorm:"primaryKey;autoIncrement:false" json:"node_id"`
Transport string `gorm:"primaryKey;size:32" json:"transport"`
// AgentVersion is what the agent reported on this transport (the
// stream's Hello), empty where the transport carries none.
AgentVersion string `gorm:"size:64;not null;default:''" json:"agent_version"`
// Identity is the SPIFFE ID of a certificate-authenticated agent, or
// "api-key"; CertSerial and CertNotAfter describe the certificate.
Identity string `gorm:"size:255;not null;default:''" json:"identity"`
CertSerial string `gorm:"size:40;not null;default:''" json:"cert_serial,omitempty"`
CertNotAfter *time.Time `json:"cert_not_after,omitempty"`
FirstSeenAt time.Time `gorm:"not null" json:"first_seen_at"`
LastSeenAt time.Time `gorm:"not null;index" json:"last_seen_at"`
}
AgentTransport records when a node was last seen on one transport. The kernel keeps the live value in memory and writes a row at most about once a minute per node and transport (internal/agenttransport), so the table costs little however often agents poll.
func (AgentTransport) TableName ¶ added in v4.1.0
func (AgentTransport) TableName() string
type AgentUpgradeCampaign ¶ added in v4.2.0
type AgentUpgradeCampaign struct {
ID string `gorm:"primaryKey;size:36" json:"id"`
TargetVersion string `gorm:"size:64;not null" json:"target_version"`
// ArtifactsJSON is the per-architecture release assets the operation
// carries ([]agentcontrol.UpgradeArtifact: asset, url, sha256, size,
// signature), verified with the official key when the campaign was
// created.
ArtifactsJSON string `gorm:"type:text;not null" json:"-"`
// BatchesJSON is the batches ([]agentupgrade.Batch: cumulative
// percent, minimum duration in seconds).
BatchesJSON string `gorm:"type:text;not null" json:"-"`
// FailureThresholdPercent: a batch rolls back when more than this
// share of its offered nodes fail (H19: 5).
FailureThresholdPercent int `gorm:"not null" json:"failure_threshold_percent"`
// ReconnectTimeoutSeconds: an offered node must reconnect with the
// target version within this time (H19: 600).
ReconnectTimeoutSeconds int `gorm:"not null" json:"reconnect_timeout_seconds"`
// ExcludeJSON lists the excluded nodes and tags
// ({"nodes":["forward-3"],"tags":["edge"]}).
ExcludeJSON string `gorm:"type:text;not null" json:"-"`
Status string `gorm:"size:16;not null;index" json:"status"`
// ActiveSlot is AgentUpgradeActiveSlot while the campaign is not
// terminal, NULL afterwards: its unique index admits one active
// campaign on SQLite and PostgreSQL alike.
ActiveSlot *string `gorm:"size:8;uniqueIndex:ux_v4_kernel_agent_upgrade_active" json:"-"`
// CurrentBatch is the index of the running batch.
CurrentBatch int `gorm:"not null;default:0" json:"current_batch"`
BatchStartedAt *time.Time `json:"batch_started_at"`
// PausedAt is when the campaign was paused; nil otherwise.
PausedAt *time.Time `json:"paused_at"`
// RollbackStartedAt is when the current batch started rolling back.
RollbackStartedAt *time.Time `json:"rollback_started_at"`
// StatusReason and ErrorCode explain a terminal status or rollback.
StatusReason string `gorm:"size:1024;not null;default:''" json:"status_reason"`
ErrorCode string `gorm:"size:64;not null;default:''" json:"error_code"`
Reason string `gorm:"size:512;not null;default:''" json:"reason"`
CreatedBy uint `gorm:"not null;default:0" json:"created_by"`
Actor string `gorm:"size:100;not null;default:''" json:"actor"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
FinishedAt *time.Time `json:"finished_at"`
}
AgentUpgradeCampaign is one staged Agent upgrade: the target release, its verified artifacts, the batches and where the campaign is. At most one campaign is not terminal (ActiveSlot is unique and NULL once it ends). Protected (service.protectedTables).
func (AgentUpgradeCampaign) TableName ¶ added in v4.2.0
func (AgentUpgradeCampaign) TableName() string
type AgentUpgradeNode ¶ added in v4.2.0
type AgentUpgradeNode struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"-"`
CampaignID string `` /* 153-byte string literal not displayed */
// NodeKind is proxy or forward; ids of the two overlap.
NodeKind string `gorm:"size:16;not null;uniqueIndex:ux_v4_kernel_agent_upgrade_node,priority:2" json:"node_kind"`
NodeID uint64 `gorm:"not null;uniqueIndex:ux_v4_kernel_agent_upgrade_node,priority:3" json:"node_id"`
// Batch is the node's batch; OrderKey its canary order (the
// SHA-256 of its name, hex), lowest first.
Batch int `gorm:"not null;index:idx_v4_kernel_agent_upgrade_node_batch,priority:2" json:"batch"`
OrderKey string `gorm:"size:64;not null" json:"order_key"`
State string `gorm:"size:16;not null" json:"state"`
// FromVersion is the version the node's Agent ran when it was offered
// the upgrade (the rollback target).
FromVersion string `gorm:"size:64;not null;default:''" json:"from_version"`
// OperationID is the agent.upgrade operation sent; SessionID the
// stream session it was sent on.
OperationID string `gorm:"size:64;not null;default:''" json:"operation_id"`
SessionID string `gorm:"size:64;not null;default:''" json:"session_id"`
// RollbackOperationID is the rollback operation sent, empty if none.
RollbackOperationID string `gorm:"size:64;not null;default:''" json:"rollback_operation_id"`
ErrorCode string `gorm:"size:64;not null;default:''" json:"error_code"`
Error string `gorm:"size:1024;not null;default:''" json:"error"`
OfferedAt *time.Time `json:"offered_at"`
HandedOffAt *time.Time `json:"handed_off_at"`
ReconnectedAt *time.Time `json:"reconnected_at"`
FinishedAt *time.Time `json:"finished_at"`
RollbackSentAt *time.Time `json:"rollback_sent_at"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
AgentUpgradeNode is one node of a campaign: its batch, its place in the canary order and how its upgrade went.
func (AgentUpgradeNode) TableName ¶ added in v4.2.0
func (AgentUpgradeNode) TableName() string
type AlipayConfig ¶
type AlipayConfig struct {
AppID string `json:"app_id"` // 应用ID
PrivateKey string `json:"private_key"` // 应用私钥
PublicKey string `json:"public_key"` // 支付宝公钥
NotifyURL string `json:"notify_url"` // 异步通知地址
ReturnURL string `json:"return_url"` // 同步跳转地址
Sandbox bool `json:"sandbox"` // 沙箱模式
}
AlipayConfig 支付宝配置
type AuditLog ¶
type AuditLog struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID *uint `gorm:"index" json:"user_id"`
Email string `gorm:"size:255" json:"email"`
Method string `gorm:"size:10" json:"method"` // HTTP method
Path string `gorm:"size:500" json:"path"` // Request path
Module string `gorm:"size:100;index" json:"module"` // Extracted module from path
Action string `gorm:"size:50;index" json:"action"` // create/update/delete/etc.
IP string `gorm:"size:45" json:"ip"` // Client IP
UserAgent string `gorm:"size:500" json:"user_agent"`
RequestID string `gorm:"size:64" json:"request_id"` // Correlation ID
RequestBody string `gorm:"type:text" json:"request_body"` // Request body (truncated)
StatusCode int `json:"status_code"` // HTTP response status
DurationMS int64 `json:"duration_ms"` // Request duration in milliseconds
ErrorMessage string `gorm:"type:text" json:"error_message"` // Error if status >= 400
CreatedAt time.Time `gorm:"index" json:"created_at"`
}
AuditLog records detailed audit trail for admin operations. Designed for compliance and security review.
type AuthorizedKey ¶
type AuthorizedKey struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100" json:"name"` // 密钥名称/备注
Key string `gorm:"size:64;uniqueIndex" json:"key"` // 授权密钥
KeyHash string `gorm:"size:64" json:"-"` // 密钥哈希 (不返回给前端)
Used int `gorm:"default:0" json:"used"` // 已注册节点数量
ExpireAt *int64 `json:"expire_at"` // 过期时间 (null=永不过期)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
AuthorizedKey 授权密钥 (用于节点自动注册)
func (AuthorizedKey) TableName ¶
func (AuthorizedKey) TableName() string
type BackupConfig ¶
type BackupConfig struct {
ID uint `gorm:"primaryKey" json:"id"`
Enabled bool `gorm:"default:false" json:"enabled"`
AutoBackup bool `gorm:"default:false" json:"auto_backup"`
Schedule string `gorm:"size:50" json:"schedule"` // cron表达式
RetentionDays int `gorm:"default:7" json:"retention_days"` // 保留天数
BackupDatabase bool `gorm:"default:true" json:"backup_database"`
BackupFiles bool `gorm:"default:false" json:"backup_files"`
StorageType string `gorm:"size:20;default:local" json:"storage_type"` // local/s3/ftp
StoragePath string `gorm:"size:255" json:"storage_path"`
S3Bucket string `gorm:"size:100" json:"s3_bucket"`
S3Region string `gorm:"size:50" json:"s3_region"`
S3Endpoint string `gorm:"size:255" json:"s3_endpoint"`
S3AccessKey string `gorm:"size:100" json:"s3_access_key"`
S3SecretKey string `gorm:"size:100" json:"s3_secret_key"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
BackupConfig 备份配置
type BackupRecord ¶
type BackupRecord struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100" json:"name"`
Type string `gorm:"size:20" json:"type"` // full/database/files
Size int64 `json:"size"` // 文件大小(字节)
Path string `gorm:"size:255" json:"path"` // 存储路径
Status int `gorm:"default:0" json:"status"` // 0=进行中 1=成功 2=失败
Error string `gorm:"type:text" json:"error"` // 错误信息
Auto bool `gorm:"default:false" json:"auto"` // 是否自动备份
CreatedBy *uint `json:"created_by"` // 创建者ID
CompletedAt *time.Time `json:"completed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
BackupRecord 备份记录
type BaseServer ¶
type BaseServer struct {
ID uint `gorm:"primaryKey" json:"id"`
GroupID string `gorm:"type:varchar(255)" json:"group_id"` // JSON array of group IDs
RouteID string `gorm:"type:varchar(255)" json:"route_id"` // JSON array of route IDs
ParentID *uint `json:"parent_id"`
Tags *string `gorm:"type:varchar(255)" json:"tags"`
Name string `gorm:"size:255" json:"name"`
Rate float64 `gorm:"default:1" json:"rate"`
Host string `gorm:"size:255" json:"host"`
Port int `json:"port"`
ServerPort int `json:"server_port"`
TLS int `gorm:"default:0" json:"tls"` // 0: None, 1: TLS, 2: Reality
TLSSettings *string `gorm:"type:text" json:"tls_settings"`
Show int `gorm:"default:0" json:"show"`
Sort *int `json:"sort"`
LastCheckAt *int64 `json:"last_check_at"` // 最后检查时间
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
BaseServer 服务器基础模型
type CommissionRecord ¶
type CommissionRecord struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"` // 获得佣金的用户
OrderID uint `gorm:"index" json:"order_id"` // 关联订单
FromUserID uint `gorm:"index" json:"from_user_id"` // 被邀请用户
Amount float64 `json:"amount"` // 佣金金额
Type int `json:"type"` // 1=订单佣金 2=充值佣金 3=系统赠送
Status int `gorm:"default:0" json:"status"` // 0=待确认 1=已到账 2=已提现 3=已取消
Remark string `gorm:"size:255" json:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
CommissionRecord 佣金记录
type CommissionWithdraw ¶
type CommissionWithdraw struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
Amount float64 `json:"amount"` // 提现金额
Method string `gorm:"size:20" json:"method"` // alipay/wechat/bank
Account string `gorm:"size:100" json:"account"` // 收款账号
Name string `gorm:"size:50" json:"name"` // 收款人姓名
Status int `gorm:"default:0" json:"status"` // 0=待处理 1=已处理 2=已拒绝
Remark string `gorm:"size:255" json:"remark"`
ProcessedAt *time.Time `json:"processed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
CommissionWithdraw 佣金提现
type Coupon ¶
type Coupon struct {
ID uint `gorm:"primaryKey" json:"id"`
Code string `gorm:"size:32;uniqueIndex" json:"code"`
Name string `gorm:"size:255" json:"name"`
Type int `gorm:"default:1" json:"type"` // 1: percentage, 2: fixed amount
Value int `json:"value"` // percentage (0-100) or amount in cents
LimitUse *int `json:"limit_use"` // null or -1 = unlimited
LimitUseWith *uint `gorm:"index" json:"limit_use_with"` // limit to specific plan ID
LimitPeriod *string `gorm:"size:20" json:"limit_period"` // limit to specific period
UseCount int `gorm:"default:0" json:"use_count"` // how many times used
StartedAt int64 `json:"started_at"` // unix timestamp
EndedAt int64 `json:"ended_at"` // unix timestamp
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Coupon 优惠券模型
type CouponUsage ¶
type CouponUsage struct {
ID uint `gorm:"primaryKey" json:"id"`
CouponID uint `gorm:"index" json:"coupon_id"`
UserID uint `gorm:"index" json:"user_id"`
OrderID uint `gorm:"index" json:"order_id"`
CreatedAt time.Time `json:"created_at"`
}
CouponUsage 优惠券使用记录
func (CouponUsage) TableName ¶
func (CouponUsage) TableName() string
type EPayConfig ¶
type EPayConfig struct {
APIURL string `json:"api_url"` // API地址
PID string `json:"pid"` // 商户ID
Key string `json:"key"` // 商户密钥
NotifyURL string `json:"notify_url"` // 通知地址
ReturnURL string `json:"return_url"` // 跳转地址
}
EPayConfig EPay配置
type EmailConfig ¶
type EmailConfig struct {
Host string `json:"host"` // SMTP服务器
Port int `json:"port"` // 端口
Username string `json:"username"` // 用户名
Password string `json:"password"` // 密码/授权码
FromName string `json:"from_name"` // 发件人名称
FromAddress string `json:"from_address"` // 发件人地址
Encryption string `json:"encryption"` // ssl/tls/none
}
EmailConfig 邮件配置
type EncryptionSettings ¶
type EncryptionSettings struct {
Mode string `json:"mode,omitempty"` // 模式: native
Ticket string `json:"ticket,omitempty"` // Ticket: 0rtt
ServerPadding string `json:"server_padding,omitempty"` // 服务器填充
PrivateKey string `json:"private_key,omitempty"` // 加密私钥
}
EncryptionSettings VLESS 加密设置 (mlkem768x25519plus)
type Event ¶
type Event struct {
ID uint `gorm:"primaryKey" json:"id"`
Type string `gorm:"size:100;index" json:"type"` // e.g. plan.created, plan.updated, plan.assigned
Payload *string `gorm:"type:text" json:"payload"`
Status string `gorm:"size:20;default:'pending'" json:"status"`
CreatedAt time.Time `json:"created_at"`
ProcessedAt *time.Time `json:"processed_at"`
}
Event 简单事件表,用于记录管理员操作或异步任务
type Forward ¶
type Forward struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index;not null" json:"user_id"`
UserName string `gorm:"size:255" json:"user_name"`
Name string `gorm:"size:100;not null" json:"name"`
TunnelID uint `gorm:"index;not null" json:"tunnel_id"`
Tunnel *ForwardTunnel `gorm:"foreignKey:TunnelID" json:"tunnel,omitempty"`
InPort int `gorm:"not null" json:"in_port"`
OutPort int `json:"out_port"`
RemoteAddr string `gorm:"type:text;not null" json:"remote_addr"`
InterfaceName string `gorm:"size:255" json:"interface_name"`
Strategy string `gorm:"size:20;default:'fifo'" json:"strategy"`
Status int `gorm:"default:1" json:"status"`
RuntimeBackend string `gorm:"size:50;default:'gost';index" json:"runtimeBackend"`
RuntimeStatus int `gorm:"default:0;index" json:"runtimeStatus"`
RuntimeMessage string `gorm:"type:text" json:"runtimeMessage"`
RuntimeLastSyncAt *time.Time `json:"runtimeLastSyncAt"`
InFlow int64 `gorm:"default:0" json:"in_flow"`
OutFlow int64 `gorm:"default:0" json:"out_flow"`
Inx int `gorm:"default:0" json:"inx"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
}
Forward is the flux-panel compatible forward resource.
type ForwardAgentBridgeTask ¶
type ForwardAgentBridgeTask struct {
ID uint `gorm:"primaryKey" json:"id"`
TaskID string `gorm:"size:80;uniqueIndex" json:"taskId"`
RuntimeJobID uint `gorm:"uniqueIndex" json:"runtimeJobId"`
NodeID uint `gorm:"index" json:"nodeId"`
ForwardID *uint `gorm:"index" json:"forwardId"`
Action string `gorm:"size:30" json:"action"`
Type string `gorm:"size:30" json:"type"`
Params string `gorm:"type:text" json:"params"`
Status string `gorm:"size:20;index" json:"status"`
Dispatched bool `gorm:"default:false" json:"dispatched"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardAgentBridgeTask 持久化 clean_agent 转发任务的 task_id ↔ runtime_job 映射。 由于 /api/v2/agent/tasks 的内存任务表重启即丢,这张表用于让 bridge worker 下发的 任务在重启后仍可回溯,从而把 agent 上报结果准确回写到对应 runtime job 与 forward。
func (ForwardAgentBridgeTask) TableName ¶
func (ForwardAgentBridgeTask) TableName() string
type ForwardCleanAgent ¶
type ForwardCleanAgent struct {
ID uint `gorm:"primaryKey" json:"id"`
NodeID *uint `gorm:"index" json:"nodeId"`
Name string `gorm:"size:100;not null" json:"name"`
Token string `gorm:"size:160;not null;uniqueIndex" json:"-"`
Version string `gorm:"size:50" json:"version"`
Hostname string `gorm:"size:255" json:"hostname"`
OS string `gorm:"size:50" json:"os"`
Arch string `gorm:"size:50" json:"arch"`
Kernel string `gorm:"size:120" json:"kernel"`
PublicIP string `gorm:"size:64" json:"publicIp"`
PrivateIP string `gorm:"size:64" json:"privateIp"`
Capabilities string `gorm:"type:text" json:"capabilities"`
Status int `gorm:"default:0;index" json:"status"`
LastSeen *time.Time `gorm:"index" json:"lastSeen"`
LastError string `gorm:"type:text" json:"lastError"`
RevokedAt *time.Time `json:"revokedAt"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardCleanAgent is the clean-room runtime worker used by the forward subsystem.
func (ForwardCleanAgent) TableName ¶
func (ForwardCleanAgent) TableName() string
type ForwardLatencyBucket ¶
type ForwardLatencyBucket struct {
ID uint `gorm:"primaryKey" json:"id"`
// 跨三类目标的统一键: "<type>:<id>:<host>:<port>"
TargetKey string `gorm:"size:191;not null;uniqueIndex:idx_flb_key_time,priority:1;index:idx_flb_key_latest,priority:1" json:"target_key"`
TargetType string `gorm:"size:20;not null;index" json:"target_type"`
TargetID uint `gorm:"index" json:"target_id"`
Label string `gorm:"size:191" json:"label"`
Host string `gorm:"size:255" json:"host"`
Port int `json:"port"`
BucketAt time.Time `` /* 137-byte string literal not displayed */
IntervalSeconds int `gorm:"not null;default:60" json:"interval_seconds"`
SampleCount int `gorm:"not null" json:"sample_count"`
SuccessCount int `gorm:"not null" json:"success_count"`
MinRTT float64 `json:"min_rtt"` // ms
AvgRTT float64 `json:"avg_rtt"` // ms
MaxRTT float64 `json:"max_rtt"` // ms
P95RTT float64 `json:"p95_rtt"` // ms
LossPct float64 `json:"loss_pct"` // 0..100
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardLatencyBucket 一个探测目标在一个时间桶内的预聚合 TCPing 结果。 每行 = 一个 (目标 × 时间桶),不存原始单次样本。
func (ForwardLatencyBucket) TableName ¶
func (ForwardLatencyBucket) TableName() string
TableName 指定表名
type ForwardLegacyArchive ¶ added in v4.2.0
type ForwardLegacyArchive struct {
ID uint `gorm:"primaryKey" json:"id"`
// Path is the archive file's absolute path on the Control host.
Path string `gorm:"size:1024;not null" json:"path"`
SHA256 string `gorm:"size:64;not null" json:"sha256"`
SizeBytes int64 `json:"size_bytes"`
// Schema is the archive's schema version.
Schema string `gorm:"size:64;not null" json:"schema"`
// Trigger is "startup" (the first v4.2 start) or "cli".
Trigger string `gorm:"size:16;not null" json:"trigger"`
Actor string `gorm:"size:255" json:"actor"`
// RowCounts is a JSON object of each archived table's row count; a
// table that did not exist is -1.
RowCounts string `gorm:"type:text" json:"row_counts"`
CreatedAt time.Time `gorm:"index" json:"created_at"`
}
ForwardLegacyArchive is one archive file of the flux forwarding data.
func (ForwardLegacyArchive) TableName ¶ added in v4.2.0
func (ForwardLegacyArchive) TableName() string
TableName keeps the upgrade's tables with the other v4 tables.
type ForwardLegacyDrop ¶ added in v4.2.0
type ForwardLegacyDrop struct {
ID uint `gorm:"primaryKey" json:"id"`
ArchiveID uint `json:"archive_id"`
ArchivePath string `gorm:"size:1024" json:"archive_path"`
ArchiveSHA256 string `gorm:"size:64" json:"archive_sha256"`
// Backup is a JSON object naming the database backup the drop
// accepted (source, path, size, sha256).
Backup string `gorm:"type:text" json:"backup"`
// Dropped and AlreadyMissing are JSON arrays of table names.
Dropped string `gorm:"type:text" json:"dropped"`
AlreadyMissing string `gorm:"type:text" json:"already_missing"`
Actor string `gorm:"size:255" json:"actor"`
CreatedAt time.Time `json:"created_at"`
}
ForwardLegacyDrop records the drop of the flux forwarding tables. Its presence is what keeps Control from creating them again.
func (ForwardLegacyDrop) TableName ¶ added in v4.2.0
func (ForwardLegacyDrop) TableName() string
TableName keeps the upgrade's tables with the other v4 tables.
type ForwardLegacyNode ¶ added in v4.2.0
type ForwardLegacyNode struct {
ID uint `gorm:"primaryKey" json:"id"`
NodeID uint `gorm:"not null;uniqueIndex" json:"node_id"`
NodeRef string `gorm:"size:64;not null" json:"node_ref"`
NodeName string `gorm:"size:255" json:"node_name"`
// State is the latest check's result: clean, dirty or unreachable.
State string `gorm:"size:16;not null;index" json:"state"`
// Checks is a JSON array of the check's paths (agent, nodex, ansible)
// with their results.
Checks string `gorm:"type:text" json:"checks"`
Detail string `gorm:"type:text" json:"detail"`
CheckedAt *time.Time `json:"checked_at"`
// AbandonedAt is set when an administrator accepted the node as
// unreachable for good; the drop then no longer waits for it.
AbandonedAt *time.Time `json:"abandoned_at"`
AbandonedBy string `gorm:"size:255" json:"abandoned_by"`
AbandonReason string `gorm:"type:text" json:"abandon_reason"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardLegacyNode is the latest cleanliness check of one forward node (v2_forward_node), and its abandonment.
func (ForwardLegacyNode) TableName ¶ added in v4.2.0
func (ForwardLegacyNode) TableName() string
TableName keeps the upgrade's tables with the other v4 tables.
type ForwardLinkCA ¶ added in v4.2.0
type ForwardLinkCA struct {
ID uint `gorm:"primaryKey" json:"id"`
Cluster string `gorm:"size:63;not null;index" json:"cluster"`
State string `gorm:"size:16;not null;index" json:"state"`
KeyID string `gorm:"size:64;not null;uniqueIndex" json:"key_id"`
CertificatePEM string `gorm:"type:text;not null" json:"certificate_pem"`
SealedKey string `gorm:"type:text;not null" json:"-"`
NotBefore time.Time `gorm:"not null" json:"not_before"`
NotAfter time.Time `gorm:"not null" json:"not_after"`
ActivatedAt *time.Time `json:"activated_at"`
RetiredAt *time.Time `json:"retired_at"`
CreatedAt time.Time `json:"created_at"`
}
ForwardLinkCA is a CA of the forward link PKI (owner decision H28, forward-sdk.md section 6.2): a self-signed root, separate from the module, kernel and Agent CA (ServiceCA), that signs only the link certificates forward nodes' engines (gost) present to each other. Its private key is sealed with module_runtime.ca_kek, like the module CA's, under its own additional data.
func (ForwardLinkCA) TableName ¶ added in v4.2.0
func (ForwardLinkCA) TableName() string
type ForwardLinkCertificate ¶ added in v4.2.0
type ForwardLinkCertificate struct {
Serial string `gorm:"primaryKey;size:40" json:"serial"`
NodeKind string `gorm:"size:16;not null;index:idx_v4_kernel_forward_link_certificate_node,priority:1" json:"node_kind"`
NodeID uint `gorm:"not null;index:idx_v4_kernel_forward_link_certificate_node,priority:2" json:"node_id"`
Cluster string `gorm:"size:63;not null" json:"cluster"`
// AgentSerial is the serial of the Agent client certificate the request
// was authenticated with.
AgentSerial string `gorm:"size:40;not null" json:"agent_serial"`
IssuerKeyID string `gorm:"size:64;not null" json:"issuer_key_id"`
DNSName string `gorm:"size:64;not null" json:"dns_name"`
SPIFFEID string `gorm:"column:spiffe_id;size:255;not null" json:"spiffe_id"`
NotAfter time.Time `gorm:"not null;index" json:"not_after"`
RevokedAt *time.Time `json:"revoked_at"`
RevokeReason string `gorm:"size:64" json:"revoke_reason,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
ForwardLinkCertificate records every link certificate the forward link CA issued: which node holds it, which Agent certificate asked for it, and when it was revoked (with the node's Agent credentials, agentpki.RevokeNode).
func (ForwardLinkCertificate) TableName ¶ added in v4.2.0
func (ForwardLinkCertificate) TableName() string
type ForwardLog ¶
type ForwardLog struct {
ID uint `gorm:"primaryKey" json:"id"`
RuleID uint `gorm:"index" json:"rule_id"`
UserID *uint `gorm:"index" json:"user_id"`
// 连接信息
SourceIP string `gorm:"size:50" json:"source_ip"`
SourcePort int `json:"source_port"`
TargetHost string `gorm:"size:255" json:"target_host"`
TargetPort int `json:"target_port"`
// 流量统计
Upload int64 `json:"upload"`
Download int64 `json:"download"`
Duration int64 `json:"duration"` // 持续时间(秒)
// 节点信息
RelayNodeID uint `json:"relay_node_id"`
ExitNodeID uint `json:"exit_node_id"`
// 状态
Status string `gorm:"size:20" json:"status"` // success/timeout/error
Error string `gorm:"size:500" json:"error"`
CreatedAt time.Time `gorm:"index" json:"created_at"`
}
ForwardLog 转发日志
type ForwardNode ¶
type ForwardNode struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;not null" json:"name"`
Type string `gorm:"size:20;not null;default:'exit'" json:"type"` // relay/exit
Host string `gorm:"size:255;not null" json:"host"`
Port int `gorm:"not null" json:"port"`
APIPort int `json:"api_port"` // 管理API端口
APIToken string `gorm:"size:100" json:"api_token"`
MetricsPort int `json:"metrics_port"` // Prometheus /metrics 端口,0 表示未配置
// 节点信息
Region string `gorm:"size:50" json:"region"` // 地区: HK, US, JP, SG等
ISP string `gorm:"size:50" json:"isp"` // 运营商
Datacenter string `gorm:"size:100" json:"datacenter"` // 数据中心
Bandwidth int64 `json:"bandwidth"` // 带宽(Mbps)
// 状态
Status int `gorm:"default:0" json:"status"`
LastCheck time.Time `json:"last_check"`
Latency int `json:"latency"` // 延迟(ms)
Load float64 `json:"load"` // 负载 0-1
Uptime float64 `json:"uptime"` // 在线率 0-100
// 配置
Tags string `gorm:"type:text" json:"tags"` // JSON数组
Weight int `gorm:"default:1" json:"weight"` // 负载均衡权重
MaxConn int `json:"max_conn"` // 最大连接数
Enabled bool `gorm:"default:true" json:"enabled"`
// 统计
TotalUpload int64 `json:"total_upload"`
TotalDownload int64 `json:"total_download"`
CurrentConn int `json:"current_conn"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardNode 中转/落地节点
type ForwardPortBinding ¶
type ForwardPortBinding struct {
ID uint `gorm:"primaryKey" json:"id"`
ForwardID uint `gorm:"index;not null" json:"forwardId"`
NodeID uint `gorm:"not null;uniqueIndex:idx_forward_port_binding_socket,priority:1" json:"nodeId"`
Transport string `gorm:"size:10;not null;uniqueIndex:idx_forward_port_binding_socket,priority:2" json:"transport"`
ListenAddr string `gorm:"size:255;not null;uniqueIndex:idx_forward_port_binding_socket,priority:3" json:"listenAddr"`
InPort int `gorm:"not null;uniqueIndex:idx_forward_port_binding_socket,priority:4" json:"inPort"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Forward *Forward `gorm:"foreignKey:ForwardID" json:"forward,omitempty"`
}
ForwardPortBinding records the concrete socket claims owned by a panel forward. It gives port assignment a database-level exact-conflict guard while the service layer still handles wildcard listen-address overlap semantics.
func (ForwardPortBinding) TableName ¶
func (ForwardPortBinding) TableName() string
type ForwardRoute ¶
type ForwardRoute struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;not null" json:"name"`
Priority int `gorm:"default:0" json:"priority"` // 优先级,数字越大越优先
Enabled bool `gorm:"default:true" json:"enabled"`
// 匹配条件 (所有条件为AND关系)
SourceIP string `gorm:"size:100" json:"source_ip"` // 源IP/网段,支持CIDR,多个用逗号分隔
Region string `gorm:"size:50" json:"region"` // 来源地区
PortRange string `gorm:"size:50" json:"port_range"` // 端口范围: 80-443,8080
Protocol string `gorm:"size:20" json:"protocol"` // 协议: tcp/udp/both
// 目标节点
RelayGroup string `gorm:"size:50" json:"relay_group"` // 中转节点组名
ExitGroup string `gorm:"size:50" json:"exit_group"` // 落地节点组名
RelayNodeID *uint `json:"relay_node_id"` // 或指定特定节点
ExitNodeID *uint `json:"exit_node_id"`
// 负载均衡
BalanceMode string `gorm:"size:20;default:'round-robin'" json:"balance_mode"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardRoute 智能路由规则
type ForwardRule ¶
type ForwardRule struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;not null" json:"name"`
Enabled bool `gorm:"default:true" json:"enabled"`
// 入口配置 (中转节点)
RelayNodeID uint `gorm:"not null" json:"relay_node_id"`
RelayNode *ForwardNode `gorm:"foreignKey:RelayNodeID" json:"relay_node,omitempty"`
ListenPort int `gorm:"not null" json:"listen_port"` // 监听端口
Protocol string `gorm:"size:10;default:'tcp'" json:"protocol"` // tcp/udp/both
// 出口配置 (落地节点)
ExitNodeID uint `gorm:"not null" json:"exit_node_id"`
ExitNode *ForwardNode `gorm:"foreignKey:ExitNodeID" json:"exit_node,omitempty"`
TargetHost string `gorm:"size:255;not null" json:"target_host"` // 目标地址
TargetPort int `gorm:"not null" json:"target_port"` // 目标端口
// 用户绑定 (可选,为空则为公共规则)
UserID *uint `json:"user_id"`
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
UserGroupID *uint `json:"user_group_id"`
// IP allowlist (comma-separated CIDRs or single IPs, empty = allow all)
AllowedIPs string `gorm:"size:1000" json:"allowed_ips"`
// 流量控制
SpeedLimit *int64 `json:"speed_limit"` // 速度限制(KB/s), nil为不限
TrafficLimit *int64 `json:"traffic_limit"` // 流量限制(字节), nil为不限
ExpireTime *time.Time `json:"expire_time"` // 过期时间, nil为永不过期
// 统计
Upload int64 `json:"upload"`
Download int64 `json:"download"`
Connections int `json:"connections"` // 当前连接数
TotalConns int64 `json:"total_conns"` // 累计连接数
// 其他
Remark string `gorm:"size:500" json:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardRule 转发规则
type ForwardRuntimeJob ¶
type ForwardRuntimeJob struct {
ID uint `gorm:"primaryKey" json:"id"`
Backend string `gorm:"size:50;not null;index" json:"backend"`
Action string `gorm:"size:30;not null;index" json:"action"`
ResourceType string `gorm:"size:30;index" json:"resourceType"`
ResourceID *uint `json:"resourceId"`
ForwardID *uint `gorm:"index" json:"forwardId"`
TunnelID *uint `gorm:"index" json:"tunnelId"`
NodeID *uint `gorm:"index" json:"nodeId"`
AgentID *uint `gorm:"index" json:"agentId"`
Status int `gorm:"default:0;index" json:"status"`
Payload string `gorm:"type:text" json:"payload"`
Result string `gorm:"type:text" json:"result"`
Error string `gorm:"type:text" json:"error"`
StartedAt *time.Time `json:"startedAt"`
ClaimedAt *time.Time `json:"claimedAt"`
CompletedAt *time.Time `json:"completedAt"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardRuntimeJob records non-DB runtime actions for forward-compatible runtimes.
func (ForwardRuntimeJob) TableName ¶
func (ForwardRuntimeJob) TableName() string
type ForwardStats ¶
type ForwardStats struct {
ID uint `gorm:"primaryKey" json:"id"`
NodeID uint `gorm:"index" json:"node_id"`
RuleID uint `gorm:"index" json:"rule_id"`
UserID *uint `gorm:"index" json:"user_id"`
// 时间
Date time.Time `gorm:"type:date" json:"date"` // 日期
Hour int `json:"hour"` // 小时 0-23
// 流量
Upload int64 `json:"upload"`
Download int64 `json:"download"`
Connections int64 `json:"connections"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardStats 转发统计 (按小时聚合)
type ForwardTrafficCursor ¶
type ForwardTrafficCursor struct {
ID uint `gorm:"primaryKey" json:"id"`
ForwardID uint `gorm:"uniqueIndex:idx_forward_traffic_cursor" json:"forwardId"`
Backend string `gorm:"size:50;uniqueIndex:idx_forward_traffic_cursor" json:"backend"`
UploadTotal int64 `gorm:"default:0" json:"uploadTotal"`
DownloadTotal int64 `gorm:"default:0" json:"downloadTotal"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardTrafficCursor stores the last runtime totals seen for a forward/backend pair so snapshot-based collectors can safely convert cumulative counters into deltas.
func (ForwardTrafficCursor) TableName ¶
func (ForwardTrafficCursor) TableName() string
type ForwardTunnel ¶
type ForwardTunnel struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;not null" json:"name"`
InNodeID uint `gorm:"index" json:"inNodeId"`
OutNodeID *uint `gorm:"index" json:"outNodeId"`
InIP string `gorm:"size:255" json:"in_ip"`
OutIP string `gorm:"size:255" json:"out_ip"`
InNodePortSta *int `json:"in_node_port_sta"`
InNodePortEnd *int `json:"in_node_port_end"`
Type int `gorm:"default:1" json:"type"`
Flow int `gorm:"default:2" json:"flow"`
Protocol string `gorm:"size:30;default:'tcp'" json:"protocol"`
TrafficRatio float64 `gorm:"default:1" json:"traffic_ratio"`
InterfaceName string `gorm:"size:255" json:"interface_name"`
TCPListenAddr string `gorm:"size:255;default:'0.0.0.0'" json:"tcpListenAddr"`
UDPListenAddr string `gorm:"size:255;default:'0.0.0.0'" json:"udpListenAddr"`
Status int `gorm:"default:1" json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ForwardTunnel is the minimal tunnel resource required by the flux-panel style forward page.
func (ForwardTunnel) TableName ¶
func (ForwardTunnel) TableName() string
type ForwardUserTunnel ¶
type ForwardUserTunnel struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"uniqueIndex:idx_forward_user_tunnel" json:"user_id"`
TunnelID uint `gorm:"uniqueIndex:idx_forward_user_tunnel;index" json:"tunnel_id"`
Flow int64 `gorm:"default:0" json:"flow"`
Num int `gorm:"default:0" json:"num"`
InFlow int64 `gorm:"default:0" json:"in_flow"`
OutFlow int64 `gorm:"default:0" json:"out_flow"`
FlowResetTime int64 `gorm:"default:0" json:"flowResetTime"`
ExpTime int64 `gorm:"default:0" json:"expTime"`
SpeedID *uint `json:"speedId"`
Status int `gorm:"default:1" json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
Tunnel *ForwardTunnel `gorm:"foreignKey:TunnelID" json:"tunnel,omitempty"`
}
ForwardUserTunnel stores flux-panel style per-user tunnel authorization.
func (ForwardUserTunnel) TableName ¶
func (ForwardUserTunnel) TableName() string
type IdentityAccountLink ¶ added in v4.1.0
type IdentityAccountLink struct {
UserID uint `gorm:"primaryKey;autoIncrement:false" json:"user_id"`
AccountUUID string `gorm:"size:36;not null;uniqueIndex" json:"account_uuid"`
ProjectionVersion uint64 `gorm:"not null;default:0" json:"projection_version"`
// TokenVersion is the highest identity token version projected. A
// session-ending projection revokes by token version only above it.
TokenVersion uint64 `gorm:"not null;default:0" json:"token_version"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
IdentityAccountLink ties an identity-module account to the kernel subscriber (v2_user row) it owns. ProjectionVersion is the last account version applied to the v2_user identity columns; older ones are ignored.
func (IdentityAccountLink) TableName ¶ added in v4.1.0
func (IdentityAccountLink) TableName() string
type IdentityAuthority ¶ added in v4.1.0
type IdentityAuthority struct {
ID uint `gorm:"primaryKey;autoIncrement:false" json:"id"`
State string `gorm:"size:16;not null" json:"state"`
ImportID string `gorm:"size:64;not null;default:''" json:"import_id"`
Checkpoint string `gorm:"type:text;not null;default:''" json:"checkpoint"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
IdentityAuthority is the single row recording the authority state and the account import's progress. No row means IdentityAuthorityKernel.
func (IdentityAuthority) TableName ¶ added in v4.1.0
func (IdentityAuthority) TableName() string
type IdentityCutoverEvent ¶ added in v4.1.0
type IdentityCutoverEvent struct {
ID uint `gorm:"primaryKey" json:"id"`
Action string `gorm:"size:32;not null;index" json:"action"`
ActorID uint `gorm:"not null;default:0" json:"actor_id"`
Detail string `gorm:"type:text;not null;default:''" json:"detail"`
CreatedAt time.Time `gorm:"not null;index" json:"created_at"`
}
IdentityCutoverEvent records each change of credential authority: the cutover to identity, an aborted cutover, a rollback and finalize. Finalize waits for a day after the latest cutover.
func (IdentityCutoverEvent) TableName ¶ added in v4.1.0
func (IdentityCutoverEvent) TableName() string
type IdentityRevocation ¶ added in v4.1.0
type IdentityRevocation struct {
UserID uint `gorm:"primaryKey;autoIncrement:false" json:"user_id"`
TokenVersion uint64 `gorm:"not null;default:0" json:"token_version"`
NotBefore time.Time `gorm:"not null" json:"not_before"`
IdentityNotBefore *time.Time `json:"identity_not_before,omitempty"`
Reason string `gorm:"size:64;not null;default:''" json:"reason"`
UpdatedAt time.Time `gorm:"not null;index" json:"updated_at"`
}
IdentityRevocation makes a user's tokens stop working. One row per user; a later revocation only moves the bounds forward.
- Kernel tokens (no tv claim) issued up to NotBefore stop working.
- Identity tokens (tv claim) stop working when their token version is below TokenVersion, or when they were issued up to IdentityNotBefore, the bound of revocations that carried no token version.
func (IdentityRevocation) TableName ¶ added in v4.1.0
func (IdentityRevocation) TableName() string
type IdentitySessionRevocation ¶ added in v4.1.0
type IdentitySessionRevocation struct {
SessionID string `gorm:"primaryKey;size:64" json:"session_id"`
UserID uint `gorm:"not null;index" json:"user_id"`
ExpiresAt time.Time `gorm:"not null;index" json:"expires_at"`
Reason string `gorm:"size:64;not null;default:''" json:"reason"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
}
IdentitySessionRevocation denies one session (sid claim), for example after a logout. The row can go once the session's tokens have expired.
func (IdentitySessionRevocation) TableName ¶ added in v4.1.0
func (IdentitySessionRevocation) TableName() string
type IdentityTokenKey ¶ added in v4.1.0
type IdentityTokenKey struct {
KeyID string `gorm:"column:kid;primaryKey;size:64" json:"kid"`
PublicKey string `gorm:"type:text;not null" json:"public_key"`
State string `gorm:"size:16;not null" json:"state"`
NotBefore *time.Time `json:"not_before"`
NotAfter *time.Time `json:"not_after"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
IdentityTokenKey is a public key of the identity module that verifies its access tokens, as last pulled with IdentityService.GetTokenKeys. The kernel keeps them so it verifies tokens while the identity module is down.
func (IdentityTokenKey) TableName ¶ added in v4.1.0
func (IdentityTokenKey) TableName() string
type InviteCode ¶
type InviteCode struct {
ID uint `gorm:"primaryKey" json:"id"`
Code string `gorm:"size:32;uniqueIndex" json:"code"`
UserID *uint `gorm:"index" json:"user_id"` // 所属用户 (null=公共)
Status int `gorm:"default:0" json:"status"` // 0=未使用 1=已使用
UsedBy *uint `json:"used_by"` // 使用者ID
UsedAt *time.Time `json:"used_at"`
ExpiredAt *time.Time `json:"expired_at"` // 过期时间 (null=永不过期)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
InviteCode 邀请码
type InviteConfig ¶
type InviteConfig struct {
ID uint `gorm:"primaryKey" json:"id"`
Enabled bool `gorm:"default:true" json:"enabled"`
// 邀请码设置
AutoGenerate bool `gorm:"default:true" json:"auto_generate"` // 新用户自动生成邀请码
CodeCount int `gorm:"default:5" json:"code_count"` // 每个用户邀请码数量
CodeExpireDays int `gorm:"default:0" json:"code_expire_days"` // 邀请码过期天数 (0=永不过期)
// 佣金设置
CommissionEnabled bool `gorm:"default:true" json:"commission_enabled"` // 是否启用佣金
CommissionType int `gorm:"default:1" json:"commission_type"` // 1=按比例 2=固定金额
CommissionRate float64 `gorm:"default:0.1" json:"commission_rate"` // 佣金比例 (0.1 = 10%)
CommissionFixed float64 `gorm:"default:0" json:"commission_fixed"` // 固定佣金金额
CommissionMinAmount float64 `gorm:"default:10" json:"commission_min"` // 最低提现金额
// 首次奖励
FirstOrderBonus float64 `gorm:"default:0" json:"first_order_bonus"` // 首单奖励
FirstTrafficBonus int64 `gorm:"default:0" json:"first_traffic_bonus"` // 首次流量奖励 (bytes)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
InviteConfig 邀请配置
type KernelAlert ¶ added in v4.2.0
type KernelAlert struct {
ID uint `gorm:"primaryKey" json:"id"`
// Key is "<kind>/<subject>", unique.
Key string `gorm:"column:alert_key;size:191;not null;uniqueIndex" json:"key"`
// Kind is one of the kernelalerts.Kind* values.
Kind string `gorm:"size:48;not null;index" json:"kind"`
Severity string `gorm:"size:16;not null" json:"severity"`
// SubjectKind names what the alert is about (node, ca, module,
// node_secrets, identity) and Subject which one (proxy-12,
// service_ca:<key id>, a package id, a split table).
SubjectKind string `gorm:"size:32;not null" json:"subject_kind"`
Subject string `gorm:"size:120;not null" json:"subject"`
// Message is an English sentence for notifications; the admin UI
// composes its own text from Kind and Detail.
Message string `gorm:"size:500;not null" json:"message"`
// Detail is a JSON object of the facts behind the alert.
Detail string `gorm:"type:text;not null;default:''" json:"-"`
// ExpiresAt is the end of the certificate the alert is about.
ExpiresAt *time.Time `json:"expires_at"`
FirstSeenAt time.Time `gorm:"not null" json:"first_seen_at"`
LastSeenAt time.Time `gorm:"not null" json:"last_seen_at"`
// LastNotifiedAt and NotifiedSeverity record the last notification of
// this alert; NotifyCount counts them.
LastNotifiedAt *time.Time `json:"last_notified_at"`
NotifiedSeverity string `gorm:"size:16;not null;default:''" json:"-"`
NotifyCount int `gorm:"not null;default:0" json:"notify_count"`
ResolvedAt *time.Time `gorm:"index" json:"resolved_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
KernelAlert is the state of one alert the kernel's alert monitor (internal/kernelalerts) raised: a certificate that was not renewed in time, a CA close to its end, or a phased process (the node credential split, the identity cutover) that has not moved for too long. One row per Key (alert kind and subject). The monitor re-evaluates the facts on every scan: a row whose finding is gone is resolved (ResolvedAt), and one that comes back is reopened, so administrators are told once per subject and again only after the re-notification interval or when the severity grows.
A row holds no secret: kinds, node names, dates and counts only.
func (KernelAlert) TableName ¶ added in v4.2.0
func (KernelAlert) TableName() string
type KernelForwardAllocation ¶ added in v4.2.0
type KernelForwardAllocation struct {
RouteID string `gorm:"primaryKey;size:64" json:"route_id"`
HopIndex uint32 `gorm:"primaryKey" json:"hop_index"`
NodeRef string `gorm:"primaryKey;size:32;index" json:"node_ref"`
Port uint32 `gorm:"not null" json:"port"`
Mark uint32 `gorm:"not null" json:"mark"`
ReleasedAt *time.Time `gorm:"index" json:"released_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelForwardAllocation is the port and connection mark a hop of a route holds on a node (planner.Allocations). The planner passes the active ones back as the previous allocations so they stick. A deleted route's allocations get ReleasedAt and are held (planner Options.Taken) for the grace period, so a late packet never reaches a new route.
func (KernelForwardAllocation) TableName ¶ added in v4.2.0
func (KernelForwardAllocation) TableName() string
type KernelForwardCounter ¶ added in v4.2.0
type KernelForwardCounter struct {
RouteID string `gorm:"primaryKey;size:64" json:"route_id"`
HopIndex uint32 `gorm:"primaryKey" json:"hop_index"`
NodeRef string `gorm:"primaryKey;size:32;index" json:"node_ref"`
CounterEpoch string `gorm:"primaryKey;size:128" json:"counter_epoch"`
UpBytes uint64 `gorm:"not null" json:"up_bytes"`
DownBytes uint64 `gorm:"not null" json:"down_bytes"`
UpPackets uint64 `gorm:"not null" json:"up_packets"`
DownPackets uint64 `gorm:"not null" json:"down_packets"`
TotalConns uint64 `gorm:"not null" json:"total_conns"`
ActiveConns uint32 `gorm:"not null" json:"active_conns"`
ObservedAt time.Time `gorm:"not null" json:"observed_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelForwardCounter is the traffic ledger's cursor and total for one counter epoch of one hop of a route on a node: the largest cumulative values the node reported within the epoch. Counters only grow within an epoch and a new epoch starts from zero, so a route's metered traffic is the sum of its epochs' rows, and a report adds only the growth over the stored values (forward-sdk.md sections 8.2 and 11).
func (KernelForwardCounter) TableName ¶ added in v4.2.0
func (KernelForwardCounter) TableName() string
type KernelForwardDNSBinding ¶ added in v4.2.0
type KernelForwardDNSBinding struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
RouteID string `gorm:"size:64;not null;uniqueIndex:ux_kernel_forward_dns_binding_route" json:"route_id"`
ProviderID uint64 `gorm:"not null;index;uniqueIndex:ux_kernel_forward_dns_binding_name" json:"provider_id"`
Zone string `gorm:"size:253;not null;uniqueIndex:ux_kernel_forward_dns_binding_name" json:"zone"`
RecordName string `gorm:"size:253;not null;uniqueIndex:ux_kernel_forward_dns_binding_name" json:"record_name"`
Mode string `gorm:"size:16;not null" json:"mode"`
RecordTypes string `gorm:"size:32;not null" json:"record_types"`
TTL uint32 `gorm:"not null" json:"ttl"`
Paused bool `gorm:"not null;default:false" json:"paused"`
State string `gorm:"size:32;not null;default:''" json:"state"`
PublishedJSON string `gorm:"type:text;not null;default:''" json:"published"`
PublishedAt *time.Time `json:"published_at"`
EvaluatedAt *time.Time `json:"evaluated_at"`
Degraded bool `gorm:"not null;default:false" json:"degraded"`
Failures uint32 `gorm:"not null;default:0" json:"failures"`
LastError string `gorm:"type:text;not null;default:''" json:"last_error"`
LastErrorAt *time.Time `json:"last_error_at"`
NextAttemptAt *time.Time `json:"next_attempt_at"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
PublishedTTL uint32 `gorm:"not null;default:0" json:"published_ttl"`
DesiredJSON string `gorm:"type:text;not null;default:''" json:"desired"`
}
KernelForwardDNSBinding binds a route's entry nodes to a name in a provider zone, with the controller's state: the values last published per record type (PublishedJSON, {"A": [...]}) and with which TTL, whether the last evaluation kept them because no entry was healthy (Degraded), and the provider failures with the back-off.
func (KernelForwardDNSBinding) TableName ¶ added in v4.2.0
func (KernelForwardDNSBinding) TableName() string
type KernelForwardDNSNode ¶ added in v4.2.0
type KernelForwardDNSNode struct {
BindingID uint64 `gorm:"primaryKey" json:"binding_id"`
NodeRef string `gorm:"primaryKey;size:32" json:"node_ref"`
InRotation bool `gorm:"not null;default:false" json:"in_rotation"`
Healthy bool `gorm:"not null;default:false" json:"healthy"`
GoodStreak uint32 `gorm:"not null;default:0" json:"good_streak"`
BadStreak uint32 `gorm:"not null;default:0" json:"bad_streak"`
Reason string `gorm:"size:32;not null;default:''" json:"reason"`
EvaluatedAt time.Time `gorm:"not null" json:"evaluated_at"`
}
KernelForwardDNSNode is one entry node of a binding as the controller last saw it: whether its addresses are published (InRotation), its streaks of good and bad evaluations, and the last evaluation's reason.
func (KernelForwardDNSNode) TableName ¶ added in v4.2.0
func (KernelForwardDNSNode) TableName() string
type KernelForwardDNSProvider ¶ added in v4.2.0
type KernelForwardDNSProvider struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
Name string `gorm:"size:128;not null;uniqueIndex:ux_kernel_forward_dns_provider_name" json:"name"`
Kind string `gorm:"size:32;not null" json:"kind"`
ConfigJSON string `gorm:"type:text;not null;default:''" json:"config"`
CredentialNames string `gorm:"type:text;not null;default:''" json:"credential_names"`
SealedCredentials string `gorm:"type:text;not null;default:''" json:"-"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelForwardDNSProvider is a DNS provider account. SealedCredentials is the credentials as JSON, sealed with AES-256-GCM under module_runtime.ca_kek with additional data naming the row; it never leaves the kernel. CredentialNames lists the stored credentials (JSON).
func (KernelForwardDNSProvider) TableName ¶ added in v4.2.0
func (KernelForwardDNSProvider) TableName() string
type KernelForwardNode ¶ added in v4.2.0
type KernelForwardNode struct {
NodeRef string `gorm:"primaryKey;size:32" json:"node_ref"`
NodeKind string `gorm:"size:16;not null;uniqueIndex:ux_kernel_forward_node" json:"node_kind"`
NodeID uint64 `gorm:"not null;uniqueIndex:ux_kernel_forward_node" json:"node_id"`
Negotiated bool `gorm:"not null;default:false" json:"negotiated"`
CapabilitiesJSON string `gorm:"type:text;not null;default:''" json:"capabilities"`
CapabilitiesHash string `gorm:"size:64;not null;default:''" json:"capabilities_hash"`
AgentVersion string `gorm:"size:128;not null;default:''" json:"agent_version"`
ReportedAt *time.Time `json:"reported_at"`
PortFirst uint32 `gorm:"not null;default:0" json:"port_first"`
PortLast uint32 `gorm:"not null;default:0" json:"port_last"`
ReservedPortsJSON string `gorm:"type:text;not null;default:''" json:"reserved_ports"`
AddressesJSON string `gorm:"type:text;not null;default:''" json:"addresses"`
LabelsJSON string `gorm:"type:text;not null;default:''" json:"labels"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelForwardNode is a node of the forwarding inventory: a proxy or forward node whose Agent negotiated forward.v1 at least once, or that an administrator configured for forwarding. Negotiated is whether its last Hello negotiated forward.v1, which decides its configuration format (anixops.nodeconfig/v2 or v1) for every builder. CapabilitiesJSON is the NodeCapabilities of the last forward.v1 Hello (protojson). The port range, reserved ports, addresses and labels are the kernel's settings for the node; zero or empty means the defaults (kernelforward).
func (KernelForwardNode) TableName ¶ added in v4.2.0
func (KernelForwardNode) TableName() string
type KernelForwardNodeReport ¶ added in v4.2.0
type KernelForwardNodeReport struct {
NodeRef string `gorm:"primaryKey;size:32" json:"node_ref"`
Generation uint64 `gorm:"not null" json:"generation"`
StateHash string `gorm:"size:64;not null;default:''" json:"state_hash"`
Applied bool `gorm:"not null;default:false" json:"applied"`
HopErrors int `gorm:"not null;default:0" json:"hop_errors"`
ReportJSON string `gorm:"type:text;not null" json:"report"`
ObservedAt time.Time `gorm:"not null;index" json:"observed_at"`
ReceivedAt time.Time `gorm:"not null" json:"received_at"`
}
KernelForwardNodeReport is a node's latest NodeForwardReport: the generation and state_hash it runs, whether it applied it, its hop errors and upstream health (ReportJSON, the report without its counters, which go to the traffic ledger). A report replaces the row unless the stored one was observed later.
func (KernelForwardNodeReport) TableName ¶ added in v4.2.0
func (KernelForwardNodeReport) TableName() string
type KernelForwardNodeState ¶ added in v4.2.0
type KernelForwardNodeState struct {
NodeRef string `gorm:"primaryKey;size:32" json:"node_ref"`
Generation uint64 `gorm:"not null" json:"generation"`
StateHash string `gorm:"size:64;not null" json:"state_hash"`
StateJSON string `gorm:"type:text;not null" json:"state"`
PlannedAt time.Time `gorm:"not null" json:"planned_at"`
}
KernelForwardNodeState is a node's desired forwarding state as the last accepted plan stamped it: its generation and state_hash (planner.Generation) and the NodeForwardState as protojson, which the node's anixops.nodeconfig/v2 configuration carries.
func (KernelForwardNodeState) TableName ¶ added in v4.2.0
func (KernelForwardNodeState) TableName() string
type KernelForwardPlan ¶ added in v4.2.0
type KernelForwardPlan struct {
ID string `gorm:"primaryKey;size:16" json:"id"`
Revision uint64 `gorm:"not null;default:0" json:"revision"`
Refused bool `gorm:"not null;default:false" json:"refused"`
Reason string `gorm:"size:64;not null;default:''" json:"reason"`
ViolationsJSON string `gorm:"type:text;not null;default:''" json:"violations"`
WarningsJSON string `gorm:"type:text;not null;default:''" json:"warnings"`
PlannedAt *time.Time `json:"planned_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelForwardPlan is the one row every plan locks, so plans run one at a time across Control processes, and the outcome of the last one: Revision counts accepted plans; Refused, with ViolationsJSON, says the last replan (after an inventory change) was refused and every node kept its state.
func (KernelForwardPlan) TableName ¶ added in v4.2.0
func (KernelForwardPlan) TableName() string
type KernelForwardRequest ¶ added in v4.2.0
type KernelForwardRequest struct {
RequestID string `gorm:"primaryKey;size:128" json:"request_id"`
Method string `gorm:"size:32;not null" json:"method"`
RouteID string `gorm:"size:64;not null;default:''" json:"route_id"`
RequestHash string `gorm:"size:64;not null" json:"request_hash"`
ResponseJSON string `gorm:"type:text;not null" json:"response"`
CreatedAt time.Time `gorm:"not null;index" json:"created_at"`
}
KernelForwardRequest records an applied ForwardControl write by its request id, with a hash of the request and the response, so a retry answers the same response once.
func (KernelForwardRequest) TableName ¶ added in v4.2.0
func (KernelForwardRequest) TableName() string
type KernelForwardRoute ¶ added in v4.2.0
type KernelForwardRoute struct {
ID string `gorm:"primaryKey;size:64" json:"id"`
Owner string `gorm:"size:64;not null;index" json:"owner"`
Revision uint64 `gorm:"not null" json:"revision"`
RouteJSON string `gorm:"type:text;not null" json:"route"`
Enforced string `gorm:"size:16;not null;default:''" json:"enforced"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelForwardRoute is one stored route: the contract's Route as protojson, with the columns the kernel filters on. Enforced is the kernel's own pause of the route, separate from the route's paused flag: "quota" once the entry hop's metered bytes reach limits.quota_bytes, "expired" once limits.expires_at_unix_ms has passed, empty otherwise. The planner sees an enforced route as paused; the stored route is unchanged.
func (KernelForwardRoute) TableName ¶ added in v4.2.0
func (KernelForwardRoute) TableName() string
type KernelForwardTraffic ¶ added in v4.2.0
type KernelForwardTraffic struct {
RouteID string `gorm:"primaryKey;size:64" json:"route_id"`
HopIndex uint32 `gorm:"primaryKey" json:"hop_index"`
NodeRef string `gorm:"primaryKey;size:32" json:"node_ref"`
HourStart time.Time `gorm:"primaryKey;index" json:"hour_start"`
UpBytes uint64 `gorm:"not null" json:"up_bytes"`
DownBytes uint64 `gorm:"not null" json:"down_bytes"`
UpPackets uint64 `gorm:"not null" json:"up_packets"`
DownPackets uint64 `gorm:"not null" json:"down_packets"`
Conns uint64 `gorm:"not null" json:"conns"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelForwardTraffic is the traffic ledger: the raw growth of a hop's counters on a node within one UTC hour, by direction, as reports delivered it. No multiplier is applied; billing applies them later.
func (KernelForwardTraffic) TableName ¶ added in v4.2.0
func (KernelForwardTraffic) TableName() string
type KernelNodeConfigStatus ¶ added in v4.1.0
type KernelNodeConfigStatus struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"-"`
// NodeKind is proxy (v2_node) or forward (v2_forward_node); ids of the
// two tables overlap.
NodeKind string `gorm:"size:16;not null;uniqueIndex:idx_kernel_node_config_status_node,priority:1" json:"node_kind"`
NodeID uint64 `gorm:"not null;uniqueIndex:idx_kernel_node_config_status_node,priority:2" json:"node_id"`
// SessionID is the stream session that sent the last status.
SessionID string `gorm:"size:64;not null" json:"session_id"`
// ReportedRevision, ReportedHash, ReportedApplied and ReportedError are
// the last ConfigStatus as the agent sent it (the error cut to 1024
// bytes); Verdict is how the kernel judged it (ConfigVerdict*).
ReportedRevision uint64 `gorm:"not null;default:0" json:"reported_revision"`
ReportedHash string `gorm:"size:64;not null" json:"reported_hash"`
ReportedApplied bool `gorm:"not null;default:false" json:"reported_applied"`
ReportedError string `gorm:"size:1024;not null" json:"reported_error"`
// ReportedErrorCode is the status's error_code
// (agentcontrol.ConfigErrorCode*), empty when applied, from an agent
// built before codes, or when the code is malformed.
ReportedErrorCode string `gorm:"size:64;not null;default:''" json:"reported_error_code"`
Verdict string `gorm:"size:16;not null" json:"verdict"`
ReportedAt time.Time `gorm:"not null" json:"reported_at"`
// AppliedRevision and AppliedHash are the last configuration the kernel
// verified as applied; zero and empty until one is.
AppliedRevision uint64 `gorm:"not null;default:0" json:"applied_revision"`
AppliedHash string `gorm:"size:64;not null" json:"applied_hash"`
AppliedAt *time.Time `json:"applied_at"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelNodeConfigStatus is what a node's agent last reported about its configuration on the Agent Control stream (config.v1, A2-3): its last ConfigStatus as reported, and the last revision the kernel verified as applied. One row per node kind and id. A status is verified when its revision and hash are the node's desired ones (v4_kernel_node_desired_config) at the time it arrives; a stale or mismatched status is recorded in the reported columns and never moves the applied ones.
The table is protected (service.protectedTables): a package that could write it could make a node look converged.
func (KernelNodeConfigStatus) TableName ¶ added in v4.1.0
func (KernelNodeConfigStatus) TableName() string
type KernelNodeDesiredConfig ¶ added in v4.1.0
type KernelNodeDesiredConfig struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"-"`
// NodeKind is proxy (v2_node) or forward (v2_forward_node); ids of the
// two tables overlap.
NodeKind string `gorm:"size:16;not null;uniqueIndex:idx_kernel_node_desired_config_node,priority:1" json:"node_kind"`
NodeID uint64 `gorm:"not null;uniqueIndex:idx_kernel_node_desired_config_node,priority:2" json:"node_id"`
// Revision is monotonic per node; it starts at 1.
Revision uint64 `gorm:"not null;default:0" json:"revision"`
// ConfigHash is the SHA-256 (hex) of the canonical document.
ConfigHash string `gorm:"size:64;not null" json:"config_hash"`
// Format names the document's schema, kernelnodeops.DesiredConfigFormat.
Format string `gorm:"size:40;not null" json:"format"`
// ConfigJSON is the canonical document (sorted keys, no whitespace).
ConfigJSON string `gorm:"type:text;not null" json:"-"`
// ExcludedProtocols counts the protocols left out because they failed
// validation (zero while validation is report-only, section 3.8).
ExcludedProtocols uint32 `gorm:"not null;default:0" json:"excluded_protocols"`
// BuiltAt is when the document was last rebuilt, changed or not.
BuiltAt time.Time `gorm:"not null" json:"built_at"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelNodeDesiredConfig is a node's desired configuration (docs/architecture/node-ops-service.md section 5.5): the configuration the kernel built from the node's rows, with the revision and hash that every push and every agent's ConfigStatus name. SyncNode rebuilds it, and so does the Agent Control stream for an agent with config.v1 (at its Hello and about once a minute). The revision grows only when the hash changes, so the same configuration keeps its revision.
The document holds the node's runtime secrets (protocol keys): the table is protected (service.protectedTables), and no contract call answers it.
func (KernelNodeDesiredConfig) TableName ¶ added in v4.1.0
func (KernelNodeDesiredConfig) TableName() string
type KernelNodeOperation ¶ added in v4.1.0
type KernelNodeOperation struct {
// ID orders operations (newest first in listings); OperationID names them.
ID uint64 `gorm:"primaryKey;autoIncrement" json:"-"`
OperationID string `gorm:"size:64;not null;uniqueIndex" json:"operation_id"`
// RequestID is unique: a repeat with the same Digest and owner answers
// this operation, anything else is refused.
RequestID string `gorm:"size:128;not null;uniqueIndex" json:"request_id"`
// Digest is the SHA-256 (hex) of the kind and the canonical operation.
Digest string `gorm:"size:64;not null" json:"digest"`
// PackageID owns the operation: only it reads, watches and cancels it.
PackageID string `gorm:"size:120;not null;index:idx_kernel_node_operation_owner,priority:1" json:"package_id"`
PackageGeneration uint64 `gorm:"not null;default:0" json:"package_generation"`
// SubmittedBy is "<package>@<generation>", or "kernel:<route id>" for
// the kernel's own handlers.
SubmittedBy string `gorm:"size:200;not null" json:"submitted_by"`
// Family is forward, nodeconfig, diagnose, agents or credentials; Kind
// the operation's stable name, for example "forward.apply".
Family string `gorm:"size:32;not null;index" json:"family"`
Kind string `gorm:"size:64;not null;index" json:"kind"`
// ResourceKey names what the operation changes ("forward:12",
// "nodeconfig:proxy-3"); the kernel runs one operation per resource at a
// time. Empty for operations that change no shared resource.
ResourceKey string `gorm:"size:96;not null;default:'';index" json:"resource_key"`
// State is pending, dispatching, running, or one of the terminal
// states succeeded, failed, cancelled, timed_out and superseded, which
// never change again.
State string `gorm:"size:16;not null;index;index:idx_kernel_node_operation_owner,priority:2" json:"state"`
Channel string `gorm:"size:32;not null;default:''" json:"channel"`
Attempt uint32 `gorm:"not null;default:0" json:"attempt"`
NodeRevision uint64 `gorm:"not null;default:0" json:"node_revision"`
// ParentOperationID is set on the operations a fan-out created; the
// parent counts them in FanOut*.
ParentOperationID string `gorm:"size:64;not null;default:'';index" json:"parent_operation_id"`
FanOutTotal uint32 `gorm:"not null;default:0" json:"fan_out_total"`
FanOutSucceeded uint32 `gorm:"not null;default:0" json:"fan_out_succeeded"`
FanOutFailed uint32 `gorm:"not null;default:0" json:"fan_out_failed"`
FanOutPending uint32 `gorm:"not null;default:0" json:"fan_out_pending"`
// KernelOperationID links the durable Agent dispatch (v3_kernel_operation),
// ForwardRuntimeJobID the forward runtime job (v2_forward_runtime_job).
KernelOperationID string `gorm:"size:64;not null;default:''" json:"kernel_operation_id"`
ForwardRuntimeJobID uint64 `gorm:"not null;default:0" json:"forward_runtime_job_id"`
// Operation is the canonical OperationSpec as protojson.
Operation string `gorm:"type:text;not null" json:"operation"`
Reason string `gorm:"size:255;not null;default:''" json:"reason"`
// Result is the OperationResult as protojson, scrubbed, at most 64 KiB.
Result string `gorm:"type:text;not null;default:''" json:"result"`
ErrorCode string `gorm:"size:40;not null;default:''" json:"error_code"`
ErrorMessage string `gorm:"type:text;not null;default:''" json:"error_message"`
ErrorRetryable bool `gorm:"not null;default:false" json:"error_retryable"`
// Evidence is an outcome that arrived after the operation had ended (a
// late result after its deadline): recorded, never applied.
Evidence string `gorm:"type:text;not null;default:''" json:"evidence"`
CancelRequestedAt *time.Time `json:"cancel_requested_at"`
CancelReason string `gorm:"size:255;not null;default:''" json:"cancel_reason"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
AcceptedAt *time.Time `json:"accepted_at"`
FinishedAt *time.Time `gorm:"index" json:"finished_at"`
DeadlineAt time.Time `gorm:"not null;index" json:"deadline_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
KernelNodeOperation is one KernelNodeOps operation (docs/architecture/node-ops-service.md section 3.4): the ledger row a package's SubmitOperation records, keyed by its request id, and the state the kernel moves it through. It never holds a credential: the operation is the canonical OperationSpec (sealed handles normalized), and results and errors are scrubbed before they are stored.
func (KernelNodeOperation) TableName ¶ added in v4.1.0
func (KernelNodeOperation) TableName() string
type KernelNodeOperationEvent ¶ added in v4.1.0
type KernelNodeOperationEvent struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"cursor"`
OperationID string `gorm:"size:64;not null;index" json:"operation_id"`
PackageID string `gorm:"size:120;not null;index" json:"package_id"`
Family string `gorm:"size:32;not null" json:"family"`
State string `gorm:"size:16;not null" json:"state"`
CreatedAt time.Time `gorm:"not null;index" json:"created_at"`
}
KernelNodeOperationEvent is the append-only change log WatchOperations follows: one row per state change, written in the change's transaction. ID is the cursor. Rows are kept 7 days; an older cursor resynchronizes.
func (KernelNodeOperationEvent) TableName ¶ added in v4.1.0
func (KernelNodeOperationEvent) TableName() string
type KernelNodeOperationTarget ¶ added in v4.1.0
type KernelNodeOperationTarget struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"-"`
OperationID string `gorm:"size:64;not null;index" json:"operation_id"`
// NodeKind is proxy (v2_node), forward (v2_forward_node) or clean_agent
// (v2_forward_clean_agent).
NodeKind string `gorm:"size:16;not null;index:idx_kernel_node_operation_target_node,priority:1" json:"node_kind"`
NodeID uint64 `gorm:"not null;index:idx_kernel_node_operation_target_node,priority:2" json:"node_id"`
}
KernelNodeOperationTarget is one node an operation acts on, so that the kernel can count each node's operations (its quota) and list the operations on a node.
func (KernelNodeOperationTarget) TableName ¶ added in v4.1.0
func (KernelNodeOperationTarget) TableName() string
type KernelOperation ¶
type KernelOperation struct {
ID string `gorm:"primaryKey;size:64" json:"id"`
IdempotencyKey string `gorm:"size:160;not null;uniqueIndex" json:"idempotency_key"`
EnvelopeVersion string `gorm:"size:32;not null;default:anixops.operation/v1" json:"envelope_version"`
// SessionID is written by the dispatcher from the active Agent connection.
// It must never be trusted from an HTTP request.
SessionID string `gorm:"size:120;index" json:"session_id"`
NodeID *uint `gorm:"index" json:"node_id"`
PluginID string `gorm:"size:120;index" json:"plugin_id"`
TargetVersion string `gorm:"size:64" json:"target_version"`
TopologyDeploymentID *uint `gorm:"index" json:"topology_deployment_id"`
TopologyStepID *uint `gorm:"index" json:"topology_step_id"`
TopologyRevision int64 `gorm:"not null;default:0" json:"topology_revision"`
Kind string `gorm:"size:80;not null" json:"kind"`
Revision int64 `gorm:"not null" json:"revision"`
ConfigJSON string `gorm:"type:text;not null;default:{}" json:"config"`
ConfigHash string `gorm:"size:64" json:"config_hash"`
DependsOnOperationID string `gorm:"size:64;index" json:"depends_on_operation_id,omitempty"`
// LifecyclePlanID and the following fields group Control-target package
// operations that must be executed as one dependency-aware lifecycle plan.
// They are intentionally empty for legacy and Agent operations.
LifecyclePlanID string `gorm:"size:64;index" json:"lifecycle_plan_id,omitempty"`
LifecyclePlanStepID uint `gorm:"index" json:"lifecycle_plan_step_id,omitempty"`
LifecyclePlanPhase string `gorm:"size:16;index" json:"lifecycle_plan_phase,omitempty"`
LifecyclePlanSequence int `gorm:"not null;default:0;index" json:"lifecycle_plan_sequence"`
State string `gorm:"size:32;not null;index" json:"state"`
DeadlineAt *time.Time `json:"deadline_at"`
DispatchedAt *time.Time `json:"dispatched_at"`
AcknowledgedAt *time.Time `json:"acknowledged_at"`
ObservedAt *time.Time `json:"observed_at"`
CancelAt *time.Time `json:"cancel_at"`
CancelDispatchedAt *time.Time `json:"cancel_dispatched_at"`
ClaimedBy string `gorm:"size:96;index" json:"claimed_by"`
LeaseExpiresAt *time.Time `gorm:"index" json:"lease_expires_at"`
Attempt int `gorm:"not null;default:0" json:"attempt"`
ResultJSON string `gorm:"type:text" json:"result"`
LastError string `gorm:"type:text" json:"last_error"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (KernelOperation) TableName ¶
func (KernelOperation) TableName() string
type Knowledge ¶
type Knowledge struct {
ID uint `gorm:"primaryKey" json:"id"`
Category string `gorm:"size:64" json:"category"`
Title string `gorm:"size:255" json:"title"`
Body string `gorm:"type:text" json:"body"`
Sort int `gorm:"default:0" json:"sort"`
Show int `gorm:"default:1" json:"show"` // 0: hidden, 1: visible
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Knowledge 知识库文章模型
type LoadBalancer ¶
type LoadBalancer struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100" json:"name"`
GroupID uint `gorm:"index" json:"group_id"` // 节点组ID
Strategy string `gorm:"size:20;default:round-robin" json:"strategy"` // round-robin/least-conn/latency/weight/random
HealthCheck bool `gorm:"default:true" json:"health_check"`
CheckInterval int `gorm:"default:60" json:"check_interval"` // 检查间隔(秒)
CheckTimeout int `gorm:"default:10" json:"check_timeout"` // 超时时间(秒)
NodeWeights string `gorm:"type:text" json:"node_weights"` // JSON: {node_id: weight}
Enabled bool `gorm:"default:true" json:"enabled"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
LoadBalancer 负载均衡器
type LoginRequest ¶
type LoginRequest struct {
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required"`
MFACode string `json:"mfa_code"`
MFAMethod string `json:"mfa_method"`
}
LoginRequest 登录请求
type LoginResponse ¶
LoginResponse 登录响应
type MFAConfig ¶
type MFAConfig struct {
Enabled bool `json:"enabled"` // 是否启用MFA
EnforceForAll bool `json:"enforce_for_all"` // 强制所有用户启用
EnforceForAdmin bool `json:"enforce_for_admin"` // 强制管理员启用
AllowedMethods string `json:"allowed_methods"` // 允许的方式 (JSON数组)
TOTPIssuer string `json:"totp_issuer"` // TOTP发行者名称
BackupCodeCount int `json:"backup_code_count"` // 备用码数量
}
MFAConfig MFA全局配置
type MFALoginAttempt ¶
type MFALoginAttempt struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
IP string `gorm:"size:50" json:"ip"`
UserAgent string `gorm:"size:255" json:"user_agent"`
Success bool `json:"success"`
Method string `gorm:"size:20" json:"method"` // totp/sms/email/backup
CreatedAt time.Time `gorm:"index" json:"created_at"`
}
MFALoginAttempt MFA登录尝试
type ModuleCertificate ¶ added in v4.1.0
type ModuleCertificate struct {
Serial string `gorm:"primaryKey;size:40" json:"serial"`
PackageID string `gorm:"size:120;not null;index" json:"package_id"`
Cluster string `gorm:"size:63;not null" json:"cluster"`
EnrollmentID string `gorm:"size:36;not null;index" json:"enrollment_id"`
IssuerKeyID string `gorm:"size:64;not null" json:"issuer_key_id"`
NotAfter time.Time `gorm:"not null;index" json:"not_after"`
RevokedAt *time.Time `json:"revoked_at"`
CreatedAt time.Time `json:"created_at"`
}
ModuleCertificate records every certificate the module PKI issued, so a revoked enrollment stops renewals and the listener can reject revoked serials.
func (ModuleCertificate) TableName ¶ added in v4.1.0
func (ModuleCertificate) TableName() string
type ModuleEnrollment ¶ added in v4.1.0
type ModuleEnrollment struct {
ID string `gorm:"primaryKey;size:36" json:"id"`
PackageID string `gorm:"size:120;not null;index" json:"package_id"`
Cluster string `gorm:"size:63;not null" json:"cluster"`
CredentialHash string `gorm:"size:64;not null;uniqueIndex" json:"-"`
Reusable bool `gorm:"not null" json:"reusable"`
ExpiresAt time.Time `gorm:"not null" json:"expires_at"`
UsedAt *time.Time `json:"used_at"`
UseCount int64 `gorm:"not null;default:0" json:"use_count"`
RevokedAt *time.Time `json:"revoked_at"`
CreatedBy uint `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
}
ModuleEnrollment is a credential a module presents once (or, when Reusable, until revoked or expired) to obtain its first certificate. Only the SHA-256 of the credential is stored.
func (ModuleEnrollment) TableName ¶ added in v4.1.0
func (ModuleEnrollment) TableName() string
type Node ¶
type Node struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:255" json:"name"` // 节点名称
Host string `gorm:"size:255" json:"host"` // 服务器地址 (IP或域名)
Port int `gorm:"default:443" json:"port"` // API通信端口
APIKey string `gorm:"size:64;uniqueIndex" json:"-"` // 节点API密钥 (用于身份验证)
APIKeyHash string `gorm:"size:64" json:"-"` // 密钥哈希 (用于快速查找)
Secret string `gorm:"size:255" json:"-"` // 共享密钥 (用于加密通信)
Status NodeStatus `gorm:"default:0" json:"status"` // 节点状态
Tags *string `gorm:"size:255" json:"tags"` // 标签 (JSON array)
GroupID *uint `gorm:"index" json:"group_id"` // 节点分组
Rate float64 `gorm:"default:1" json:"rate"` // 流量倍率
TrafficRate float64 `gorm:"default:1" json:"traffic_rate"` // 计费倍率
Sort int `gorm:"default:0" json:"sort"` // 排序
Show int `gorm:"default:1" json:"show"` // 是否显示给用户
AutoRegister int `gorm:"default:0" json:"auto_register"` // 是否自动注册的节点
// 父子节点 (中转链路: 落地节点为根, 转发节点为子, 支持多级)
ParentID *uint `gorm:"index" json:"parent_id"` // 上级节点ID, nil=根节点(落地节点)
// 月流量限额 (仅本节点自身, 不含子节点单独限额; 子节点流量会同时累加到父节点)
MonthlyLimit *int64 `json:"monthly_limit"` // 月流量限额(字节), nil=不限
MonthlyUpload int64 `gorm:"default:0" json:"monthly_upload"` // 本月已用上传流量
MonthlyDownload int64 `gorm:"default:0" json:"monthly_download"` // 本月已用下载流量
MonthlyResetDay int `gorm:"default:1" json:"monthly_reset_day"` // 每月流量重置日 (1-28)
// 高级配置 (直接JSON编辑)
RawConfig *string `gorm:"type:text" json:"raw_config"` // 原始配置 (JSON, 优先级最高)
// 服务器信息 (由节点上报)
ServerIP *string `gorm:"size:45" json:"server_ip"` // 实际服务器IP
ServerVersion *string `gorm:"size:50" json:"server_version"` // 节点程序版本
ServerOS *string `gorm:"size:100" json:"server_os"` // 操作系统信息
CPUUsage float64 `gorm:"default:0" json:"cpu_usage"` // CPU使用率
MemoryUsage float64 `gorm:"default:0" json:"memory_usage"` // 内存使用率
DiskUsage float64 `gorm:"default:0" json:"disk_usage"` // 磁盘使用率
Uptime int64 `gorm:"default:0" json:"uptime"` // 运行时间(秒)
OnlineUsers int `gorm:"default:0" json:"online_users"` // 在线用户数
// 运行时健康状态 (由支持运行时自愈的节点上报)
RuntimeHealthy bool `gorm:"default:true" json:"runtime_healthy"`
RuntimeError string `gorm:"type:text" json:"runtime_error"`
RuntimeCheckedAt *int64 `json:"runtime_checked_at"`
// 流量统计
TotalUpload int64 `gorm:"default:0" json:"total_upload"` // 总上传流量
TotalDownload int64 `gorm:"default:0" json:"total_download"` // 总下载流量
// 时间戳
LastCheckAt *int64 `json:"last_check_at"` // 最后心跳时间
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// 关联
Protocols []NodeProtocol `gorm:"foreignKey:NodeID" json:"protocols,omitempty"`
}
Node 节点模型 (物理服务器)
type NodeCredential ¶ added in v4.1.0
type NodeCredential struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
SubjectKind string `gorm:"size:32;not null;uniqueIndex:idx_v4_kernel_node_credential_subject,priority:1" json:"subject_kind"`
SubjectID uint64 `gorm:"not null;uniqueIndex:idx_v4_kernel_node_credential_subject,priority:2" json:"subject_id"`
Kind string `` /* 150-byte string literal not displayed */
Version int `gorm:"not null;default:1;uniqueIndex:idx_v4_kernel_node_credential_subject,priority:4" json:"version"`
// KeyHash is the SHA-256 (hex) the kernel looks a credential up by.
KeyHash string `gorm:"size:64;not null;default:'';index:idx_v4_kernel_node_credential_lookup,priority:2" json:"-"`
// Value is the secret, where the kernel has to present it. It is
// stored in clear, as in the legacy columns (decision D5), unless Sealed.
Value string `gorm:"type:text;not null;default:''" json:"-"`
Sealed bool `gorm:"not null;default:false" json:"sealed"`
KEKID string `gorm:"column:kek_id;size:64;not null;default:''" json:"kek_id"`
// Endpoint is the host:port a forward node token is pinned to.
Endpoint string `gorm:"size:300;not null;default:''" json:"endpoint"`
Status string `gorm:"size:16;not null;default:'active';index" json:"status"`
ExpiresAt *time.Time `json:"expires_at"`
// Source says who wrote the current version: backfill, dual_write or
// issued.
Source string `gorm:"size:16;not null;default:''" json:"source"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
RotatedAt *time.Time `json:"rotated_at"`
RevokedAt *time.Time `json:"revoked_at"`
}
NodeCredential is one credential of a node-facing subject, moved out of the legacy tables by the node credential split (docs/architecture/node-ops-service.md, section 4): a proxy node's API key and shared secret (v2_node), a registration key (v2_authorized_key), a forward node's token (v2_forward_node) and a clean agent's token (v2_forward_clean_agent).
Only internal/nodesecrets writes it. A subject keeps one current row per kind (status active or revoked); replacing its value retires that row, whose value is cleared, and adds the next version.
func (NodeCredential) TableName ¶ added in v4.1.0
func (NodeCredential) TableName() string
type NodeGroup ¶
type NodeGroup struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100" json:"name"`
Sort int `gorm:"default:0" json:"sort"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
NodeGroup 节点分组
type NodeHeartbeatRequest ¶
type NodeHeartbeatRequest struct {
CPUUsage float64 `json:"cpu_usage"`
MemoryUsage float64 `json:"memory_usage"`
DiskUsage float64 `json:"disk_usage"`
Uptime int64 `json:"uptime"`
OnlineUsers int `json:"online_users"`
Upload int64 `json:"upload"` // 本次上传流量增量
Download int64 `json:"download"` // 本次下载流量增量
}
NodeHeartbeatRequest 节点心跳请求
type NodeLog ¶
type NodeLog struct {
ID uint `gorm:"primaryKey" json:"id"`
NodeID uint `gorm:"index;not null" json:"node_id"`
Level string `gorm:"size:20;index;not null" json:"level"`
Source string `gorm:"size:120;index" json:"source"`
Message string `gorm:"type:text;not null" json:"message"`
TraceID string `gorm:"size:120;index" json:"trace_id"`
FieldsJSON string `gorm:"type:text" json:"fields_json"`
LoggedAt *time.Time `gorm:"index" json:"logged_at"`
CreatedAt time.Time `gorm:"index" json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
NodeLog stores runtime logs reported by V2bX parent nodes over gRPC.
type NodeOperationRevision ¶
type NodeOperationRevision struct {
NodeID uint `gorm:"primaryKey" json:"node_id"`
DesiredRevision int64 `gorm:"not null;default:0" json:"desired_revision"`
ObservedRevision int64 `gorm:"not null;default:0" json:"observed_revision"`
UpdatedAt time.Time `json:"updated_at"`
}
NodeOperationRevision is the durable desired/observed revision cursor for a physical node. It is intentionally separate from any plugin-specific state.
func (NodeOperationRevision) TableName ¶
func (NodeOperationRevision) TableName() string
type NodePluginLifecycle ¶
type NodePluginLifecycle struct {
NodeID uint `gorm:"primaryKey" json:"node_id"`
PluginID string `gorm:"primaryKey;size:120" json:"plugin_id"`
DesiredGeneration int64 `gorm:"not null;default:0" json:"desired_generation"`
RetryEpoch int `gorm:"not null;default:0" json:"retry_epoch"`
RetryAfter *time.Time `gorm:"index" json:"retry_after"`
RetryExhausted bool `gorm:"not null;default:false" json:"retry_exhausted"`
DesiredVersion string `gorm:"size:64" json:"desired_version"`
DesiredConfigRevision int64 `gorm:"not null;default:0" json:"desired_config_revision"`
DesiredEnabled bool `gorm:"not null;default:false" json:"desired_enabled"`
ActiveVersion string `gorm:"size:64" json:"active_version"`
ActiveEnabled bool `gorm:"not null;default:false" json:"active_enabled"`
ActiveRevision int64 `gorm:"not null;default:0" json:"active_revision"`
LastError string `gorm:"type:text" json:"last_error"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
NodePluginLifecycle is the aggregate desired/observed boundary for all roles of one plugin on one physical node. The row is also the transaction lock that serializes assignment, configuration, retry and deletion intent.
func (NodePluginLifecycle) TableName ¶
func (NodePluginLifecycle) TableName() string
type NodePluginObservedState ¶
type NodePluginObservedState struct {
NodeID uint `gorm:"primaryKey" json:"node_id"`
PluginID string `gorm:"primaryKey;size:120" json:"plugin_id"`
Version string `gorm:"size:64;not null" json:"version"`
DesiredRevision int64 `gorm:"not null" json:"desired_revision"`
ObservedRevision int64 `gorm:"not null" json:"observed_revision"`
ConfigHash string `gorm:"size:64;not null" json:"config_hash"`
Health string `gorm:"size:32;not null;index" json:"health"`
RulesetSHA256 string `gorm:"size:64;not null" json:"ruleset_sha256"`
CountersJSON string `gorm:"type:text;not null;default:[]" json:"rule_counters"`
ObservedAt time.Time `gorm:"not null;index" json:"observed_at"`
ReceivedAt time.Time `gorm:"not null;index" json:"received_at"`
UpdatedAt time.Time `json:"updated_at"`
}
NodePluginObservedState is a bounded, non-secret snapshot emitted by an Agent plugin. It is intentionally separate from generic telemetry because topology promotion needs a cryptographically bound config/ruleset view, rather than a plugin-defined metric bag.
func (NodePluginObservedState) TableName ¶
func (NodePluginObservedState) TableName() string
type NodeProtocol ¶
type NodeProtocol struct {
ID uint `gorm:"primaryKey" json:"id"`
NodeID uint `gorm:"index" json:"node_id"` // 所属节点
Name string `gorm:"size:100" json:"name"` // 协议名称
Type ProtocolType `gorm:"size:20;index" json:"type"` // 协议类型
Port int `json:"port"` // 监听端口
Enable int `gorm:"default:1" json:"enable"` // 是否启用 (节点端是否运行)
Show int `gorm:"default:1" json:"show"` // 是否显示在订阅中
Sort int `gorm:"default:0" json:"sort"` // 排序
GroupID *uint `gorm:"index" json:"group_id"` // 所属订阅分组 (如果为空则跟随节点)
// 通用配置
Host *string `gorm:"size:255" json:"host"` // 连接地址 (可覆盖节点host)
TLS int `gorm:"default:0" json:"tls"` // TLS模式: 0=无, 1=TLS, 2=Reality
ALPN *string `gorm:"size:100" json:"alpn"` // ALPN设置
// 协议特定配置 (JSON)
Settings *string `gorm:"type:text" json:"settings"` // 协议配置 (JSON)
TLSSettings *string `gorm:"type:text" json:"tls_settings"` // TLS配置 (JSON)
Transport *string `gorm:"size:20" json:"transport"` // 传输层: tcp, ws, grpc, quic, h2
TransportSettings *string `gorm:"type:text" json:"transport_settings"` // 传输层配置 (JSON)
// Reality 配置
RealitySettings *string `gorm:"type:text" json:"reality_settings"` // Reality配置 (JSON)
// 自定义配置 (全量覆盖)
CustomConfig *string `gorm:"type:text" json:"custom_config"` // 自定义配置 (JSON, 优先级最高)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// 关联
Node *Node `gorm:"foreignKey:NodeID" json:"node,omitempty"`
SubscriptionGroups []SubscriptionGroup `gorm:"many2many:v2_subscription_group_node_protocols;" json:"subscription_groups,omitempty"`
}
NodeProtocol 节点协议配置
func (NodeProtocol) TableName ¶
func (NodeProtocol) TableName() string
type NodeRegisterRequest ¶
type NodeRegisterRequest struct {
AuthKey string `json:"auth_key" binding:"required"` // 授权密钥
Name string `json:"name"` // 节点名称
Host string `json:"host"` // 节点地址
Port int `json:"port"` // API端口
ServerVersion string `json:"server_version"` // 节点版本
ServerOS string `json:"server_os"` // 操作系统
}
NodeRegisterRequest 节点注册请求
type NodeRegisterResponse ¶
type NodeRegisterResponse struct {
NodeID uint `json:"node_id"`
APIKey string `json:"api_key"` // 返回给节点的API密钥
Secret string `json:"secret"` // 共享密钥
Message string `json:"message"`
}
NodeRegisterResponse 节点注册响应
type NodeRuntimeHealthRequest ¶
NodeRuntimeHealthRequest reports process-level runtime health separately from the regular system heartbeat metrics.
type NodeSecretSplit ¶ added in v4.1.0
type NodeSecretSplit struct {
Table string `gorm:"column:table_name;primaryKey;size:64" json:"table_name"`
Phase string `gorm:"size:16;not null" json:"phase"`
// BackfilledRows counts the legacy rows the last backfill pass copied.
BackfilledRows int64 `gorm:"not null;default:0" json:"backfilled_rows"`
// BackfillCursor is the last legacy id of the running backfill pass, so
// an interrupted pass resumes after it.
BackfillCursor uint64 `gorm:"not null;default:0" json:"backfill_cursor"`
// BackfilledAt is when the last backfill pass completed; nil while one
// runs.
BackfilledAt *time.Time `json:"backfilled_at"`
// Digest is the digest of every secret of the table, old and new forms
// equal, at the last verification that matched (VerifiedAt).
Digest string `gorm:"size:64;not null;default:''" json:"digest"`
VerifiedAt *time.Time `json:"verified_at"`
// CheckedAt and Mismatches record the last verification, matched or not.
CheckedAt *time.Time `json:"checked_at"`
Mismatches int64 `gorm:"not null;default:0" json:"mismatches"`
FinalizedAt *time.Time `json:"finalized_at"`
FinalizedBy string `gorm:"size:128;not null;default:''" json:"finalized_by"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
NodeSecretSplit is the state of the credential split of one legacy table: its phase (legacy, dual_write, dual_read, finalized), the progress of the backfill, and the outcome of the last verification.
func (NodeSecretSplit) TableName ¶ added in v4.1.0
func (NodeSecretSplit) TableName() string
type NodeServiceAssignment ¶
type NodeServiceAssignment struct {
ID uint `gorm:"primaryKey" json:"id"`
NodeID uint `gorm:"not null;index;uniqueIndex:ux_node_service_assignment" json:"node_id"`
ServiceScope string `gorm:"size:64;not null;uniqueIndex:ux_node_service_assignment" json:"service_scope"`
PluginID string `gorm:"size:120;not null;uniqueIndex:ux_node_service_assignment" json:"plugin_id"`
Role string `gorm:"size:80;not null;uniqueIndex:ux_node_service_assignment" json:"role"`
DesiredVersion string `gorm:"size:64" json:"desired_version"`
DesiredConfigRevision int64 `gorm:"not null;default:0" json:"desired_config_revision"`
Enabled bool `gorm:"not null" json:"enabled"`
LifecycleGeneration int64 `gorm:"not null;default:0" json:"lifecycle_generation"`
DeletePending bool `gorm:"not null;default:false;index" json:"delete_pending"`
RolloutGroup string `gorm:"size:80;index" json:"rollout_group"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (NodeServiceAssignment) TableName ¶
func (NodeServiceAssignment) TableName() string
type NodeStatus ¶
type NodeStatus int
NodeStatus 节点状态
const ( NodeStatusPending NodeStatus = 0 // 待审核 NodeStatusOnline NodeStatus = 1 // 在线 NodeStatusOffline NodeStatus = 2 // 离线 NodeStatusDisabled NodeStatus = 3 // 已禁用 )
type NotificationLog ¶
type NotificationLog struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID *uint `gorm:"index" json:"user_id"`
Type string `gorm:"size:20" json:"type"` // email/telegram/webhook
Event string `gorm:"size:50" json:"event"` // 触发事件
Title string `gorm:"size:200" json:"title"`
Content string `gorm:"type:text" json:"content"`
Status int `json:"status"` // 0=待发送 1=已发送 2=失败
Error string `gorm:"size:500" json:"error"`
SentAt *time.Time `json:"sent_at"`
ReadAt *time.Time `json:"read_at"`
CreatedAt time.Time `gorm:"index" json:"created_at"`
}
NotificationLog 通知日志
type NotificationTemplate ¶
type NotificationTemplate struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;not null" json:"name"`
Type string `gorm:"size:20;not null" json:"type"` // email/telegram/webhook
Event string `gorm:"size:50;not null" json:"event"` // 触发事件
Title string `gorm:"size:200" json:"title"` // 标题模板
Content string `gorm:"type:text" json:"content"` // 内容模板
Enabled bool `gorm:"default:true" json:"enabled"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
NotificationTemplate 通知模板
func (NotificationTemplate) TableName ¶
func (NotificationTemplate) TableName() string
TableName 指定表名
type OnlineLog ¶
type OnlineLog struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
ServerID uint `gorm:"index" json:"server_id"`
ServerType string `gorm:"size:20" json:"server_type"`
Method string `gorm:"size:20" json:"method"`
IP string `gorm:"size:45" json:"ip"`
CreatedAt time.Time `json:"created_at"`
}
OnlineLog 在线日志
type OperationLog ¶
type OperationLog struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID *uint `gorm:"index" json:"user_id"`
Username string `gorm:"size:100" json:"username"`
Action string `gorm:"size:50;index" json:"action"` // create/update/delete/login/logout
Module string `gorm:"size:50;index" json:"module"` // user/node/order/plan...
TargetType string `gorm:"size:50" json:"target_type"` // 目标类型
TargetID *uint `json:"target_id"` // 目标ID
Content string `gorm:"type:text" json:"content"` // 操作内容
IP string `gorm:"size:45" json:"ip"`
UserAgent string `gorm:"size:255" json:"user_agent"`
Status int `gorm:"default:1" json:"status"` // 1=成功 2=失败
CreatedAt time.Time `gorm:"index" json:"created_at"`
}
OperationLog 操作日志
type Order ¶
type Order struct {
ID uint `gorm:"primaryKey" json:"id"`
InviteUserID *uint `gorm:"index" json:"invite_user_id"`
UserID uint `gorm:"index" json:"user_id"`
PlanID uint `gorm:"index" json:"plan_id"`
CouponID *uint `gorm:"index" json:"coupon_id"`
PaymentID *uint `gorm:"index" json:"payment_id"`
Type int `json:"type"` // 1: new, 2: renew, 3: upgrade, 4: reset
Period string `gorm:"size:20" json:"period"`
TradeNo string `gorm:"size:36;uniqueIndex" json:"trade_no"`
CallbackNo *string `gorm:"size:255" json:"callback_no"`
TotalAmount int64 `json:"total_amount"`
DiscountAmount *int64 `json:"discount_amount"`
SurplusAmount *int64 `json:"surplus_amount"`
RefundAmount *int64 `json:"refund_amount"`
Balance *int64 `json:"balance"`
SurplusOrder *string `gorm:"type:text" json:"surplus_order"`
Status int `gorm:"default:0" json:"status"` // 0: pending, 1: paid, 2: cancelled, 3: completed, 4: discounted
CommissionStatus int `gorm:"default:0" json:"commission_status"`
CommissionBalance int64 `gorm:"default:0" json:"commission_balance"`
PaidAt *int64 `json:"paid_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Relations
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
Plan *Plan `gorm:"foreignKey:PlanID" json:"plan,omitempty"`
}
Order 订单模型
type PackageBackupReference ¶
type PackageBackupReference struct {
ID uint `gorm:"primaryKey" json:"id"`
MigrationRunID uint `gorm:"not null;uniqueIndex" json:"migration_run_id"`
PackageID string `gorm:"size:120;not null;index" json:"package_id"`
PackageVersion string `gorm:"size:64;not null" json:"package_version"`
Generation uint64 `gorm:"not null;index" json:"generation"`
Reference string `gorm:"type:text;not null" json:"reference"`
Checksum string `gorm:"size:128" json:"checksum"`
PreviousGenerationID *uint `gorm:"index" json:"previous_generation_id"`
RestoredAt *time.Time `json:"restored_at"`
RestoreReason string `gorm:"type:text" json:"restore_reason"`
CreatedAt time.Time `json:"created_at"`
}
PackageBackupReference records an opaque package backup location. The kernel can retain and audit the reference but never reads package data from it.
func (PackageBackupReference) TableName ¶
func (PackageBackupReference) TableName() string
type PackageMigrationRun ¶
type PackageMigrationRun struct {
ID uint `gorm:"primaryKey" json:"id"`
PackageID string `gorm:"size:120;not null;uniqueIndex:ux_v4_package_migration_generation" json:"package_id"`
PackageVersion string `gorm:"size:64;not null" json:"package_version"`
Generation uint64 `gorm:"not null;uniqueIndex:ux_v4_package_migration_generation" json:"generation"`
MigrationID string `gorm:"size:160;not null" json:"migration_id"`
MigrationChecksum string `gorm:"size:128;not null" json:"migration_checksum"`
BeforeSchemaVersion string `gorm:"size:128;not null" json:"before_schema_version"`
AfterSchemaVersion string `gorm:"size:128;not null" json:"after_schema_version"`
OpaqueCheckpoint string `gorm:"type:text;not null;default:''" json:"opaque_checkpoint"`
ValidationDigest string `gorm:"type:text;not null;default:''" json:"validation_digest"`
State string `gorm:"size:32;not null;index" json:"state"`
Complete bool `gorm:"not null;default:false" json:"complete"`
FailureCode string `gorm:"size:160" json:"failure_code"`
HealthLeaseID string `gorm:"size:160" json:"health_lease_id"`
HealthGeneration uint64 `gorm:"not null;default:0" json:"health_generation"`
HealthVerifiedAt *time.Time `json:"health_verified_at"`
BackupReference string `gorm:"type:text" json:"backup_reference"`
BackupReferenceID *uint `gorm:"index" json:"backup_reference_id"`
PreviousGenerationID *uint `gorm:"index" json:"previous_generation_id"`
CompletedAt *time.Time `json:"completed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PackageMigrationRun is kernel-owned bookkeeping for one opaque package migration. The kernel records package-supplied checkpoints but never interprets them or accesses package-owned schema.
func (PackageMigrationRun) TableName ¶
func (PackageMigrationRun) TableName() string
type PackageReportState ¶ added in v4.2.0
type PackageReportState struct {
NodeKind string `gorm:"primaryKey;size:16" json:"node_kind"`
NodeID uint `gorm:"primaryKey" json:"node_id"`
PluginID string `gorm:"primaryKey;size:120" json:"plugin_id"`
Kind string `gorm:"primaryKey;size:64" json:"kind"`
Version string `gorm:"size:64;not null" json:"version"`
PayloadJSON string `gorm:"type:text;not null" json:"payload"`
ObservedAt time.Time `gorm:"not null;index" json:"observed_at"`
ReceivedAt time.Time `gorm:"not null;index" json:"received_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PackageReportState is the latest PackageReport (package-reports.v1) a node's Agent delivered for one plugin package and report kind: one row per node, plugin and kind, replaced by each newer report. The kernel keeps no history (docs/architecture/package-reports.md). PayloadJSON is the payload as the kind's sanitizer re-encoded it, never the bytes the Agent sent. Packages read their own rows through kapi_package_report_v1.
func (PackageReportState) TableName ¶ added in v4.2.0
func (PackageReportState) TableName() string
type PackageRolloutLock ¶
type PackageRolloutLock struct {
PackageID string `gorm:"primaryKey;size:120" json:"package_id"`
}
PackageRolloutLock is a kernel-owned, package-scoped lock row. It lets rollout transactions serialize lineage changes before a route generation exists, including the first installation of a package.
func (PackageRolloutLock) TableName ¶
func (PackageRolloutLock) TableName() string
type PackageRouteGeneration ¶
type PackageRouteGeneration struct {
ID uint `gorm:"primaryKey" json:"id"`
PackageID string `gorm:"size:120;not null;uniqueIndex:ux_v4_package_route_generation;index" json:"package_id"`
Version string `gorm:"size:64;not null" json:"version"`
Generation uint64 `gorm:"not null;uniqueIndex:ux_v4_package_route_generation" json:"generation"`
CohortPercent uint8 `gorm:"not null" json:"cohort_percent"`
State string `gorm:"size:32;not null;index" json:"state"`
PreviousID *uint `gorm:"index" json:"previous_id"`
MigrationRunID *uint `gorm:"index" json:"migration_run_id"`
ValidationResultID *uint `gorm:"index" json:"validation_result_id"`
BackupReferenceID *uint `gorm:"index" json:"backup_reference_id"`
ActivatedAt *time.Time `json:"activated_at"`
RolledBackAt *time.Time `json:"rolled_back_at"`
RollbackReason string `gorm:"type:text" json:"rollback_reason"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PackageRouteGeneration is an immutable, cohort-specific route generation. Successors link to their predecessor so rollback can restore a previously verified route without deleting any rollout evidence.
func (PackageRouteGeneration) TableName ¶
func (PackageRouteGeneration) TableName() string
type PackageStorage ¶ added in v4.1.0
type PackageStorage struct {
PackageID string `gorm:"primaryKey;size:120" json:"package_id"`
Driver string `gorm:"size:16;not null" json:"driver"`
RoleName string `gorm:"size:63" json:"role_name"`
SchemaName string `gorm:"size:63" json:"schema_name"`
TablePrefix string `gorm:"size:63" json:"table_prefix"`
GrantsJSON string `gorm:"type:text;not null" json:"grants_json"`
PackageVersion string `gorm:"size:64;not null" json:"package_version"`
HostGeneration uint64 `gorm:"not null" json:"host_generation"`
LeaseGeneration int64 `gorm:"not null" json:"lease_generation"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PackageStorage records the least-privilege database storage the kernel provisioned for a package: its role, its schema, the adopted tables and kernel API views it may use, and how many leases have been issued.
func (PackageStorage) TableName ¶ added in v4.1.0
func (PackageStorage) TableName() string
type PackageValidationResult ¶
type PackageValidationResult struct {
ID uint `gorm:"primaryKey" json:"id"`
MigrationRunID uint `gorm:"not null;uniqueIndex:ux_v4_package_validation_run" json:"migration_run_id"`
PackageID string `gorm:"size:120;not null;index" json:"package_id"`
PackageVersion string `gorm:"size:64;not null" json:"package_version"`
Generation uint64 `gorm:"not null;index" json:"generation"`
ValidationDigest string `gorm:"type:text;not null" json:"validation_digest"`
State string `gorm:"size:32;not null;index" json:"state"`
RouteGenerationID *uint `gorm:"uniqueIndex" json:"route_generation_id"`
CreatedAt time.Time `json:"created_at"`
}
PackageValidationResult stores the opaque validation digest supplied by a package host after a completed migration. It contains no domain mapping.
func (PackageValidationResult) TableName ¶
func (PackageValidationResult) TableName() string
type ParsedNode ¶
type ParsedNode struct {
ID string `json:"id"` // 唯一标识 (hash)
Name string `json:"name"` // 节点名称
Type string `json:"type"` // 协议类型: vless, vmess, trojan, shadowsocks, hysteria2, tuic, anytls, wireguard
Server string `json:"server"` // 服务器地址 (host)
Port int `json:"port"` // 服务器端口 (server_port)
// 认证信息 (渲染后填入)
UUID string `json:"uuid,omitempty"` // VMess/VLESS UUID (用户ID)
Password string `json:"password,omitempty"` // Trojan/SS 密码
// TLS 配置 (tls: 0=None, 1=TLS, 2=Reality)
TLSMode int `json:"tls_mode"` // TLS 模式: 0=无, 1=TLS, 2=Reality
TLS bool `json:"tls"` // 是否启用 TLS (兼容字段)
TLSFingerprint string `json:"tls_fingerprint,omitempty"` // TLS 指纹 (fp)
SkipCertVerify bool `json:"skip_cert_verify,omitempty"` // 跳过证书验证
ServerName string `json:"server_name,omitempty"` // SNI 服务器名称
ALPN string `json:"alpn,omitempty"` // ALPN 设置
// Reality 配置 (当 TLSMode=2 时使用)
RealityPublicKey string `json:"reality_public_key,omitempty"` // Reality 公钥 (pbk)
RealityShortID string `json:"reality_short_id,omitempty"` // Reality ShortId (sid)
RealitySpiderX string `json:"reality_spider_x,omitempty"` // Reality SpiderX (spx)
// VLESS 特有配置
Flow string `json:"flow,omitempty"` // VLESS 流控: xtls-rprx-vision
Encryption string `json:"encryption,omitempty"` // VLESS 加密: 空 或 mlkem768x25519plus
// VLESS Encryption Settings (当 Encryption 非空时)
EncryptionSettings *EncryptionSettings `json:"encryption_settings,omitempty"`
// Shadowsocks 配置
Cipher string `json:"cipher,omitempty"` // SS 加密方式
ServerKey string `json:"server_key,omitempty"` // SS2022 服务器密钥
// WireGuard 配置
PrivateKey string `json:"private_key,omitempty"`
PublicKey string `json:"public_key,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
AllowedIPs []string `json:"allowed_ips,omitempty"`
DNS []string `json:"dns,omitempty"`
MTU int `json:"mtu,omitempty"`
// 传输层配置 (network)
Transport string `json:"transport,omitempty"` // 传输协议: tcp, ws, grpc, httpupgrade, xhttp
TransportSettings map[string]any `json:"transport_settings,omitempty"` // 传输层配置
// 协议特定配置 (兼容旧字段)
Settings map[string]any `json:"settings,omitempty"`
// 来源信息
SourceType string `json:"source_type"` // template, node, external
SourceID uint `json:"source_id"` // 来源 ID
SourceName string `json:"source_name"` // 来源名称
GroupID uint `json:"group_id"` // 所属分组
GroupName string `json:"group_name"` // 分组名称
}
ParsedNode 解析后的统一节点格式 符合 AnixOps Agent/Xray 协议配置规范
func (*ParsedNode) IsValid ¶
func (n *ParsedNode) IsValid() bool
IsValid checks whether a parsed node has all required fields populated.
type PayPalConfig ¶
type PayPalConfig struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
WebhookID string `json:"webhook_id"`
SandboxMode bool `json:"sandbox_mode"`
Currency string `json:"currency"`
}
PayPalConfig PayPal 支付配置
type Payment ¶
type Payment struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100" json:"name"` // 支付名称
Icon *string `gorm:"size:255" json:"icon"` // 支付图标
Method string `gorm:"size:20" json:"method"` // crypto 或 fiat
Provider string `gorm:"size:50" json:"provider"` // x402, stripe, paypal 等
Config string `gorm:"type:text" json:"config"` // JSON 配置
Notify *string `gorm:"size:255" json:"notify"` // 回调地址
Sort int `gorm:"default:0" json:"sort"` // 排序
Enable int `gorm:"default:1" json:"enable"` // 是否启用
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Payment 支付配置模型
type PaymentChannel ¶
type PaymentChannel struct {
ID uint `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Icon string `json:"icon"`
MinAmount float64 `json:"min_amount"`
MaxAmount float64 `json:"max_amount"`
FeeRate float64 `json:"fee_rate"`
FeeFixed float64 `json:"fee_fixed"`
Description string `json:"description"`
}
PaymentChannel 支付渠道 (用于前端显示)
type PaymentGateway ¶
type PaymentGateway struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;not null" json:"name"`
Type string `gorm:"size:20;not null" json:"type"` // alipay/wechat/stripe/usdt/epay
Enabled bool `gorm:"default:false" json:"enabled"`
Icon string `gorm:"size:255" json:"icon"` // 图标URL
// 配置 (JSON格式存储不同支付方式的配置)
Config string `gorm:"type:text" json:"config"`
// 费率设置
FeeRate float64 `gorm:"default:0" json:"fee_rate"` // 手续费率 (0-1)
FeeFixed float64 `gorm:"default:0" json:"fee_fixed"` // 固定手续费
// 限额设置
MinAmount float64 `gorm:"default:1" json:"min_amount"` // 最小金额
MaxAmount float64 `gorm:"default:10000" json:"max_amount"` // 最大金额
// 显示设置
Sort int `gorm:"default:0" json:"sort"` // 排序
Description string `gorm:"size:500" json:"description"` // 说明文字
// 统计
TotalOrders int64 `json:"total_orders"`
TotalAmount float64 `json:"total_amount"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PaymentGateway 支付网关配置 (扩展现有Payment模型)
type PaymentLog ¶
type PaymentLog struct {
ID uint `gorm:"primaryKey" json:"id"`
OrderID uint `gorm:"index" json:"order_id"`
PaymentID uint `gorm:"index" json:"payment_id"`
TradeNo string `gorm:"size:64;index" json:"trade_no"` // 内部交易号
CallbackNo *string `gorm:"size:255" json:"callback_no"` // 外部交易号
Method string `gorm:"size:20" json:"method"` // crypto 或 fiat
Provider string `gorm:"size:50" json:"provider"` // 支付提供商
Amount int64 `json:"amount"` // 支付金额 (分)
Currency string `gorm:"size:10" json:"currency"` // 货币类型 (USD, CNY, ETH, USDT等)
Status int `gorm:"default:0" json:"status"` // 支付状态
RawData *string `gorm:"type:text" json:"raw_data"` // 原始回调数据
TxHash *string `gorm:"size:255" json:"tx_hash"` // 区块链交易哈希 (仅虚拟货币)
WalletAddress *string `gorm:"size:255" json:"wallet_address"` // 钱包地址 (仅虚拟货币)
Network *string `gorm:"size:50" json:"network"` // 区块链网络 (仅虚拟货币)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PaymentLog 支付日志
func (PaymentLog) TableName ¶
func (PaymentLog) TableName() string
type PaymentRecord ¶
type PaymentRecord struct {
ID uint `gorm:"primaryKey" json:"id"`
TradeNo string `gorm:"size:64;uniqueIndex" json:"trade_no"` // 商户订单号
GatewayID uint `json:"gateway_id"` // 支付网关ID
GatewayType string `json:"gateway_type"` // 支付类型
GatewayTradeNo string `gorm:"size:100" json:"gateway_trade_no"` // 第三方订单号
Provider string `gorm:"size:50" json:"provider"` // 支付提供商 (x402/stripe/paypal 等)
UserID uint `json:"user_id"`
// 金额信息
Amount float64 `json:"amount"` // 订单金额
FeeAmount float64 `json:"fee_amount"` // 手续费
ActualAmount float64 `json:"actual_amount"` // 实际支付金额
Currency string `gorm:"size:10;default:'CNY'" json:"currency"` // 货币类型
// 状态 (复用 PaymentStatus 常量)
Status int `json:"status"` // 0=待支付 1=已支付 2=已取消 3=已退款
PaidAt *time.Time `json:"paid_at"`
CancelledAt *time.Time `json:"cancelled_at"`
RefundedAt *time.Time `json:"refunded_at"`
// 回调信息
NotifyData string `gorm:"type:text" json:"notify_data"` // 回调原始数据
ClientIP string `gorm:"size:50" json:"client_ip"`
// 区块链相关 (虚拟货币支付)
TxHash *string `gorm:"size:255" json:"tx_hash"` // 区块链交易哈希
WalletAddress *string `gorm:"size:255" json:"wallet_address"` // 钱包地址
Network *string `gorm:"size:50" json:"network"` // 区块链网络
// 关联
OrderID *uint `json:"order_id"` // 关联订单
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PaymentRecord 支付记录
type Plan ¶
type Plan struct {
ID uint `gorm:"primaryKey" json:"id"`
GroupID uint `gorm:"index" json:"group_id"`
TransferEnable int64 `json:"transfer_enable"` // GB
SpeedLimit *int64 `json:"speed_limit"`
DeviceLimit *int `json:"device_limit"`
Name string `gorm:"size:255" json:"name"`
Content *string `gorm:"type:text" json:"content"`
Show int `gorm:"default:0" json:"show"`
Sort *int `json:"sort"`
Renew int `gorm:"default:1" json:"renew"`
ResetPrice *int64 `json:"reset_price"`
ResetTrafficMethod *int `json:"reset_traffic_method"`
CapacityLimit *int `json:"capacity_limit"`
// Prices
MonthPrice *int64 `json:"month_price"`
QuarterPrice *int64 `json:"quarter_price"`
HalfYearPrice *int64 `json:"half_year_price"`
YearPrice *int64 `json:"year_price"`
TwoYearPrice *int64 `json:"two_year_price"`
ThreeYearPrice *int64 `json:"three_year_price"`
OnetimePrice *int64 `json:"onetime_price"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Plan 订阅计划模型
type PlanSubscriptionGroup ¶
type PlanSubscriptionGroup struct {
ID uint `gorm:"primaryKey" json:"id"`
PlanID uint `gorm:"uniqueIndex:idx_plan_group" json:"plan_id"`
GroupID uint `gorm:"uniqueIndex:idx_plan_group" json:"group_id"`
CreatedAt time.Time `json:"created_at"`
// 关联
Plan *Plan `gorm:"foreignKey:PlanID" json:"plan,omitempty"`
Group *SubscriptionGroup `gorm:"foreignKey:GroupID" json:"group,omitempty"`
}
PlanSubscriptionGroup 套餐-订阅分组关联 购买某个套餐自动获得对应分组权限
func (PlanSubscriptionGroup) TableName ¶
func (PlanSubscriptionGroup) TableName() string
type Plugin ¶
type Plugin struct {
ID string `gorm:"primaryKey;size:120" json:"id"`
Name string `gorm:"size:160;not null" json:"name"`
Description string `gorm:"type:text" json:"description"`
Publisher string `gorm:"size:120;not null" json:"publisher"`
Official bool `gorm:"not null;default:false" json:"official"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type PluginArtifact ¶
type PluginArtifact struct {
ID uint `gorm:"primaryKey" json:"id"`
ReleaseID uint `gorm:"not null;uniqueIndex" json:"release_id"`
PluginID string `gorm:"size:120;not null;index;uniqueIndex:ux_plugin_artifact_key" json:"plugin_id"`
Version string `gorm:"size:64;not null;uniqueIndex:ux_plugin_artifact_key" json:"version"`
ArtifactSHA256 string `gorm:"size:64;not null;uniqueIndex:ux_plugin_artifact_key" json:"artifact_sha256"`
SizeBytes int64 `gorm:"not null" json:"size_bytes"`
StorageKey string `gorm:"size:320;not null;uniqueIndex" json:"storage_key"`
Data []byte `json:"-"`
CreatedAt time.Time `json:"created_at"`
}
func (PluginArtifact) TableName ¶
func (PluginArtifact) TableName() string
type PluginConfiguration ¶
type PluginConfiguration struct {
InstallationID uint `gorm:"primaryKey" json:"installation_id"`
Revision int64 `gorm:"not null;default:0" json:"revision"`
ConfigJSON string `gorm:"type:text;not null;default:{}" json:"config"`
ConfigHash string `gorm:"size:64;not null" json:"config_hash"`
UpdatedBy uint `gorm:"not null" json:"updated_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PluginConfiguration is the kernel-owned, revisioned configuration document for one installation. Plugin packages receive a copy through an operation; they never write the shared configuration table directly.
func (PluginConfiguration) TableName ¶
func (PluginConfiguration) TableName() string
type PluginInstallation ¶
type PluginInstallation struct {
ID uint `gorm:"primaryKey" json:"id"`
PluginID string `gorm:"size:120;not null;uniqueIndex:ux_plugin_install_target" json:"plugin_id"`
Target string `gorm:"size:20;not null;uniqueIndex:ux_plugin_install_target" json:"target"`
DesiredVersion string `gorm:"size:64;not null" json:"desired_version"`
ObservedVersion string `gorm:"size:64" json:"observed_version"`
PreviousVersion string `gorm:"size:64" json:"previous_version"`
State string `gorm:"size:32;not null;index" json:"state"`
Enabled bool `gorm:"not null;default:false" json:"enabled"`
LifecycleGeneration int64 `gorm:"not null;default:0" json:"lifecycle_generation"`
ConfigRevision int64 `gorm:"not null;default:0" json:"config_revision"`
LastError string `gorm:"type:text" json:"last_error"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DisabledAt *time.Time `json:"disabled_at"`
}
func (PluginInstallation) TableName ¶
func (PluginInstallation) TableName() string
type PluginLifecyclePlan ¶
type PluginLifecyclePlan struct {
ID string `gorm:"primaryKey;size:64" json:"id"`
IdempotencyKey string `gorm:"size:160;not null;uniqueIndex" json:"idempotency_key"`
Target string `gorm:"size:20;not null;index" json:"target"`
RootPluginID string `gorm:"size:120;not null;index" json:"root_plugin_id"`
RootOperationID string `gorm:"size:64;not null;uniqueIndex" json:"root_operation_id"`
State string `gorm:"size:32;not null;index" json:"state"`
Outcome string `gorm:"size:32" json:"outcome"`
LastError string `gorm:"type:text" json:"last_error"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CompletedAt *time.Time `json:"completed_at"`
}
PluginLifecyclePlan is the durable Control-side transaction boundary for a dependency closure. Individual KernelOperations remain independently observable and cancellable, while the plan supplies dependency ordering and reverse rollback after a failed or cancelled apply phase.
func (PluginLifecyclePlan) TableName ¶
func (PluginLifecyclePlan) TableName() string
type PluginLifecyclePlanStep ¶
type PluginLifecyclePlanStep struct {
ID uint `gorm:"primaryKey" json:"id"`
PlanID string `gorm:"size:64;not null;uniqueIndex:ux_plugin_lifecycle_plan_step" json:"plan_id"`
Sequence int `gorm:"not null;uniqueIndex:ux_plugin_lifecycle_plan_step;index" json:"sequence"`
PluginID string `gorm:"size:120;not null;index" json:"plugin_id"`
TargetVersion string `gorm:"size:64;not null" json:"target_version"`
HadInstallation bool `gorm:"not null" json:"had_installation"`
PreviousDesiredVersion string `gorm:"size:64" json:"previous_desired_version"`
PreviousObservedVersion string `gorm:"size:64" json:"previous_observed_version"`
PreviousPreviousVersion string `gorm:"size:64" json:"previous_previous_version"`
PreviousState string `gorm:"size:32" json:"previous_state"`
PreviousEnabled bool `gorm:"not null" json:"previous_enabled"`
PreviousDisabledAt *time.Time `json:"previous_disabled_at"`
PreviousLastError string `gorm:"type:text" json:"previous_last_error"`
Changed bool `gorm:"not null" json:"changed"`
ApplyState string `gorm:"size:32;not null;default:pending;index" json:"apply_state"`
RollbackState string `gorm:"size:32;not null;default:pending;index" json:"rollback_state"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PluginLifecyclePlanStep stores the old desired state separately from the runtime operation. That lets a restarted worker restore intent precisely after a dependency graph failure without deleting package data.
func (PluginLifecyclePlanStep) TableName ¶
func (PluginLifecyclePlanStep) TableName() string
type PluginRelease ¶
type PluginRelease struct {
ID uint `gorm:"primaryKey" json:"id"`
PluginID string `gorm:"size:120;not null;uniqueIndex:ux_plugin_release" json:"plugin_id"`
Version string `gorm:"size:64;not null;uniqueIndex:ux_plugin_release" json:"version"`
APIVersion string `gorm:"size:32;not null" json:"api_version"`
ManifestJSON string `gorm:"type:text;not null" json:"manifest"`
ArtifactSHA256 string `gorm:"size:64;not null" json:"artifact_sha256"`
Signature string `gorm:"type:text;not null" json:"signature"`
TrustRootFingerprint string `gorm:"size:64;index" json:"trust_root_fingerprint"`
TrustRootKeyID string `gorm:"size:32;index" json:"trust_root_key_id"`
PublishedAt time.Time `json:"published_at"`
CreatedAt time.Time `json:"created_at"`
}
func (PluginRelease) TableName ¶
func (PluginRelease) TableName() string
type PluginRuntime ¶ added in v4.1.0
type PluginRuntime struct {
PluginID string `gorm:"primaryKey;size:120" json:"plugin_id"`
Runtime string `gorm:"size:16;not null" json:"runtime"`
UpdatedBy uint `json:"updated_by"`
UpdatedAt time.Time `json:"updated_at"`
}
PluginRuntime selects how the kernel runs a Control package: as a local child process (the default, also when no row exists) or from network module instances. A change applies at the package's next lifecycle operation.
func (PluginRuntime) TableName ¶ added in v4.1.0
func (PluginRuntime) TableName() string
type PluginTargetLock ¶
type PluginTargetLock struct {
Target string `gorm:"primaryKey;size:20" json:"target"`
UpdatedAt time.Time `json:"updated_at"`
}
PluginTargetLock serializes dependency/conflict validation and installation intent changes for one runtime target across concurrent Control processes.
func (PluginTargetLock) TableName ¶
func (PluginTargetLock) TableName() string
type PluginTelemetryState ¶
type PluginTelemetryState struct {
NodeID uint `gorm:"primaryKey" json:"node_id"`
PluginID string `gorm:"primaryKey;size:120" json:"plugin_id"`
MetricsJSON string `gorm:"type:text;not null" json:"metrics"`
ObservedAt time.Time `gorm:"not null;index" json:"observed_at"`
ReceivedAt time.Time `gorm:"not null;index" json:"received_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PluginTelemetryState stores the latest scalar snapshot received from one enabled Agent plugin. Metrics are namespaced by plugin at the transport boundary and persisted as JSON so the kernel does not need to know every plugin-specific field in advance.
func (PluginTelemetryState) TableName ¶
func (PluginTelemetryState) TableName() string
type PluginTrustRoot ¶
type PluginTrustRoot struct {
Fingerprint string `gorm:"primaryKey;size:64" json:"fingerprint"`
KeyID string `gorm:"size:32;not null;index" json:"key_id"`
PublicKey string `gorm:"type:text;not null" json:"public_key"`
Publisher string `gorm:"size:120;not null;index" json:"publisher"`
Active bool `gorm:"not null;default:true;index" json:"active"`
CreatedAt time.Time `json:"created_at"`
LastSeenAt time.Time `json:"last_seen_at"`
RetiredAt *time.Time `json:"retired_at"`
}
func (PluginTrustRoot) TableName ¶
func (PluginTrustRoot) TableName() string
type PluginWebUIAsset ¶
type PluginWebUIAsset struct {
ID uint `gorm:"primaryKey" json:"id"`
ReleaseID uint `gorm:"not null;uniqueIndex" json:"release_id"`
PluginID string `gorm:"size:120;not null;index;uniqueIndex:ux_plugin_webui_asset_addr" json:"plugin_id"`
Version string `gorm:"size:64;not null;uniqueIndex:ux_plugin_webui_asset_addr" json:"version"`
BundlePath string `gorm:"size:240;not null" json:"bundle_path"`
BundleSHA256 string `gorm:"size:64;not null;index;uniqueIndex:ux_plugin_webui_asset_addr" json:"bundle_sha256"`
SizeBytes int64 `gorm:"not null" json:"size_bytes"`
ContentType string `gorm:"size:120;not null" json:"content_type"`
StorageKey string `gorm:"size:360;not null;uniqueIndex" json:"storage_key"`
Data []byte `json:"-"`
CreatedAt time.Time `json:"created_at"`
}
func (PluginWebUIAsset) TableName ¶
func (PluginWebUIAsset) TableName() string
type ProtocolSecret ¶ added in v4.1.0
type ProtocolSecret struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
Scope string `gorm:"size:32;not null;uniqueIndex:idx_v4_kernel_protocol_secret_position,priority:1" json:"scope"`
OwnerID uint64 `gorm:"not null;uniqueIndex:idx_v4_kernel_protocol_secret_position,priority:2" json:"owner_id"`
ColumnName string `gorm:"size:64;not null;uniqueIndex:idx_v4_kernel_protocol_secret_position,priority:3" json:"column_name"`
JSONPointer string `` /* 128-byte string literal not displayed */
Value string `gorm:"type:text;not null;default:''" json:"-"`
Sealed bool `gorm:"not null;default:false" json:"sealed"`
KEKID string `gorm:"column:kek_id;size:64;not null;default:''" json:"kek_id"`
// Version counts the changes of the value at this position.
Version int `gorm:"not null;default:1" json:"version"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
ProtocolSecret is one secret of a node protocol's settings, a node's raw configuration or a WireGuard peer, moved out of the legacy tables by the node credential split.
JSONPointer (RFC 6901) names the secret's position in the column's JSON document, and Value holds the JSON encoding of the value there. An empty JSONPointer stands for the whole column: a WireGuard peer's key, or a column whose text is not JSON; Value then holds the text itself.
func (ProtocolSecret) TableName ¶ added in v4.1.0
func (ProtocolSecret) TableName() string
type ProtocolTemplate ¶
type ProtocolTemplate struct {
Type ProtocolType `json:"type"`
Name string `json:"name"`
Description string `json:"description"`
DefaultPort int `json:"default_port"`
Settings string `json:"settings"` // 默认配置JSON
TLS int `json:"tls"` // 0=无, 1=TLS, 2=Reality
TLSSettings string `json:"tls_settings"` // TLS配置JSON
Transport string `json:"transport"` // tcp, ws, etc.
Reality string `json:"reality_settings"` // Reality配置JSON
}
ProtocolTemplate 协议模板 (快速添加)
func GetProtocolTemplates ¶
func GetProtocolTemplates() []ProtocolTemplate
GetProtocolTemplates 获取协议模板列表
type ProtocolType ¶
type ProtocolType string
ProtocolType 协议类型
const ( ProtocolVMess ProtocolType = "vmess" ProtocolVLESS ProtocolType = "vless" ProtocolTrojan ProtocolType = "trojan" ProtocolShadowsocks ProtocolType = "shadowsocks" ProtocolHysteria2 ProtocolType = "hysteria2" ProtocolTUIC ProtocolType = "tuic" ProtocolAnyTLS ProtocolType = "anytls" ProtocolWireGuard ProtocolType = "wireguard" )
type QuotaPolicy ¶
type QuotaPolicy struct {
ID uint `gorm:"primaryKey" json:"id"`
GroupID uint `gorm:"not null;index;uniqueIndex:ux_quota_group_key" json:"group_id"`
Key string `gorm:"size:80;not null;uniqueIndex:ux_quota_group_key" json:"key"`
PolicyJSON string `gorm:"type:text;not null" json:"policy"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (QuotaPolicy) TableName ¶
func (QuotaPolicy) TableName() string
type RegisterRequest ¶
type RegisterRequest struct {
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required,min=6"`
InviteCode string `json:"invite_code"`
}
RegisterRequest 注册请求
type ResourceGrant ¶
type ResourceGrant struct {
ID uint `gorm:"primaryKey" json:"id"`
GroupID uint `gorm:"not null;index;uniqueIndex:ux_resource_grant" json:"group_id"`
ResourceType string `gorm:"size:64;not null;uniqueIndex:ux_resource_grant" json:"resource_type"`
ResourceID string `gorm:"size:160;not null;uniqueIndex:ux_resource_grant" json:"resource_id"`
Permissions string `gorm:"type:text;not null" json:"permissions"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (ResourceGrant) TableName ¶
func (ResourceGrant) TableName() string
type RouteModeRevision ¶ added in v4.1.0
type RouteModeRevision struct {
ID uint `gorm:"primaryKey" json:"id"`
GroupID string `gorm:"size:36;not null;index" json:"group_id"`
PackageID string `gorm:"size:120;not null;index" json:"package_id"`
RouteID string `gorm:"size:191;not null" json:"route_id"`
Action string `gorm:"size:16;not null" json:"action"`
FromMode string `gorm:"size:16;not null" json:"from_mode"`
ToMode string `gorm:"size:16;not null" json:"to_mode"`
ActorUserID uint `gorm:"not null;default:0" json:"actor_user_id"`
Actor string `gorm:"size:191;not null;default:''" json:"actor"`
Reason string `gorm:"type:text;not null;default:''" json:"reason"`
ConfigRevision int64 `gorm:"not null" json:"config_revision"`
CreatedAt time.Time `gorm:"not null;index" json:"created_at"`
}
RouteModeRevision records one route's mode change made by the route-mode administration (API, CLI or admin page). The routes of one request share GroupID; ConfigRevision is the package configuration revision that holds the change. The identity cutover records its own changes in IdentityCutoverEvent.
func (RouteModeRevision) TableName ¶ added in v4.1.0
func (RouteModeRevision) TableName() string
type ServerAnyTLS ¶
type ServerAnyTLS struct {
BaseServer
PaddingScheme *string `gorm:"type:text" json:"padding_scheme"` // JSON array
ServerName *string `gorm:"size:255" json:"server_name"`
}
ServerAnyTLS AnyTLS服务器
func (*ServerAnyTLS) GetHost ¶
func (s *ServerAnyTLS) GetHost() string
func (*ServerAnyTLS) GetID ¶
func (s *ServerAnyTLS) GetID() uint
func (*ServerAnyTLS) GetPort ¶
func (s *ServerAnyTLS) GetPort() int
func (*ServerAnyTLS) GetServerPort ¶
func (s *ServerAnyTLS) GetServerPort() int
func (*ServerAnyTLS) GetType ¶
func (s *ServerAnyTLS) GetType() ServerType
func (ServerAnyTLS) TableName ¶
func (ServerAnyTLS) TableName() string
type ServerHysteria ¶
type ServerHysteria struct {
BaseServer
Version int `gorm:"default:2" json:"version"` // 1 or 2
UpMbps int `json:"up_mbps"`
DownMbps int `json:"down_mbps"`
Obfs string `gorm:"size:50" json:"obfs"`
ObfsPassword *string `gorm:"size:255" json:"obfs_password"`
ServerName *string `gorm:"size:255" json:"server_name"`
IgnoreClientBandwidth int `gorm:"default:0" json:"ignore_client_bandwidth"`
}
ServerHysteria Hysteria服务器
func (*ServerHysteria) GetHost ¶
func (s *ServerHysteria) GetHost() string
func (*ServerHysteria) GetID ¶
func (s *ServerHysteria) GetID() uint
func (*ServerHysteria) GetPort ¶
func (s *ServerHysteria) GetPort() int
func (*ServerHysteria) GetServerPort ¶
func (s *ServerHysteria) GetServerPort() int
func (*ServerHysteria) GetType ¶
func (s *ServerHysteria) GetType() ServerType
func (ServerHysteria) TableName ¶
func (ServerHysteria) TableName() string
type ServerInfo ¶
type ServerInfo interface {
GetID() uint
GetType() ServerType
GetHost() string
GetPort() int
GetServerPort() int
GetGroupIDs() []uint
GetRouteIDs() []uint
}
ServerInfo 统一服务器信息接口
type ServerRoute ¶
type ServerRoute struct {
ID uint `gorm:"primaryKey" json:"id"`
Remarks string `gorm:"size:255" json:"remarks"`
Match string `gorm:"type:text" json:"match"`
Action string `gorm:"size:20" json:"action"` // block, dns
ActionValue *string `gorm:"type:text" json:"action_value"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ServerRoute 服务器路由
func (ServerRoute) TableName ¶
func (ServerRoute) TableName() string
type ServerShadowsocks ¶
type ServerShadowsocks struct {
BaseServer
Cipher string `gorm:"size:50" json:"cipher"`
ServerKey *string `gorm:"size:255" json:"server_key"`
Obfs *string `gorm:"size:20" json:"obfs"`
ObfsSettings *string `gorm:"type:text" json:"obfs_settings"`
}
ServerShadowsocks Shadowsocks服务器
func (*ServerShadowsocks) GetHost ¶
func (s *ServerShadowsocks) GetHost() string
func (*ServerShadowsocks) GetID ¶
func (s *ServerShadowsocks) GetID() uint
func (*ServerShadowsocks) GetPort ¶
func (s *ServerShadowsocks) GetPort() int
func (*ServerShadowsocks) GetServerPort ¶
func (s *ServerShadowsocks) GetServerPort() int
func (*ServerShadowsocks) GetType ¶
func (s *ServerShadowsocks) GetType() ServerType
func (ServerShadowsocks) TableName ¶
func (ServerShadowsocks) TableName() string
type ServerTUIC ¶
type ServerTUIC struct {
BaseServer
CongestionControl string `gorm:"size:20;default:bbr" json:"congestion_control"` // bbr, cubic, new_reno
ZeroRTTHandshake int `gorm:"default:0" json:"zero_rtt_handshake"`
ServerName *string `gorm:"size:255" json:"server_name"`
}
ServerTUIC TUIC服务器
func (*ServerTUIC) GetHost ¶
func (s *ServerTUIC) GetHost() string
func (*ServerTUIC) GetID ¶
func (s *ServerTUIC) GetID() uint
func (*ServerTUIC) GetPort ¶
func (s *ServerTUIC) GetPort() int
func (*ServerTUIC) GetServerPort ¶
func (s *ServerTUIC) GetServerPort() int
func (*ServerTUIC) GetType ¶
func (s *ServerTUIC) GetType() ServerType
func (ServerTUIC) TableName ¶
func (ServerTUIC) TableName() string
type ServerTrojan ¶
type ServerTrojan struct {
BaseServer
Network string `gorm:"size:20" json:"network"`
NetworkSettings *string `gorm:"type:text" json:"network_settings"`
ServerName *string `gorm:"size:255" json:"server_name"`
AllowInsecure int `gorm:"default:0" json:"allow_insecure"`
}
ServerTrojan Trojan服务器
func (*ServerTrojan) GetHost ¶
func (s *ServerTrojan) GetHost() string
func (*ServerTrojan) GetID ¶
func (s *ServerTrojan) GetID() uint
func (*ServerTrojan) GetPort ¶
func (s *ServerTrojan) GetPort() int
func (*ServerTrojan) GetServerPort ¶
func (s *ServerTrojan) GetServerPort() int
func (*ServerTrojan) GetType ¶
func (s *ServerTrojan) GetType() ServerType
func (ServerTrojan) TableName ¶
func (ServerTrojan) TableName() string
type ServerType ¶
type ServerType string
ServerType 服务器类型
const ( ServerTypeVMess ServerType = "vmess" ServerTypeVLESS ServerType = "vless" ServerTypeTrojan ServerType = "trojan" ServerTypeShadowsocks ServerType = "shadowsocks" ServerTypeHysteria ServerType = "hysteria" ServerTypeHysteria2 ServerType = "hysteria2" ServerTypeTUIC ServerType = "tuic" ServerTypeAnyTLS ServerType = "anytls" )
type ServerVLESS ¶
type ServerVLESS struct {
BaseServer
Network string `gorm:"size:20" json:"network"`
NetworkSettings *string `gorm:"type:text" json:"network_settings"`
Flow string `gorm:"size:50" json:"flow"` // xtls-rprx-vision
Encryption *string `gorm:"size:50" json:"encryption"`
EncryptionSettings *string `gorm:"type:text" json:"encryption_settings"`
RealitySettings *string `gorm:"type:text" json:"reality_settings"`
}
ServerVLESS VLESS服务器
func (*ServerVLESS) GetHost ¶
func (s *ServerVLESS) GetHost() string
func (*ServerVLESS) GetID ¶
func (s *ServerVLESS) GetID() uint
func (*ServerVLESS) GetPort ¶
func (s *ServerVLESS) GetPort() int
func (*ServerVLESS) GetServerPort ¶
func (s *ServerVLESS) GetServerPort() int
func (*ServerVLESS) GetType ¶
func (s *ServerVLESS) GetType() ServerType
func (ServerVLESS) TableName ¶
func (ServerVLESS) TableName() string
type ServerVMess ¶
type ServerVMess struct {
BaseServer
Network string `gorm:"size:20" json:"network"` // tcp, ws, grpc, http, quic
NetworkSettings *string `gorm:"type:text" json:"network_settings"`
}
ServerVMess VMess服务器
func (*ServerVMess) GetHost ¶
func (s *ServerVMess) GetHost() string
func (*ServerVMess) GetID ¶
func (s *ServerVMess) GetID() uint
func (*ServerVMess) GetPort ¶
func (s *ServerVMess) GetPort() int
func (*ServerVMess) GetServerPort ¶
func (s *ServerVMess) GetServerPort() int
func (*ServerVMess) GetType ¶
func (s *ServerVMess) GetType() ServerType
func (ServerVMess) TableName ¶
func (ServerVMess) TableName() string
type ServiceCA ¶ added in v4.1.0
type ServiceCA struct {
ID uint `gorm:"primaryKey" json:"id"`
Cluster string `gorm:"size:63;not null;index" json:"cluster"`
State string `gorm:"size:16;not null;index" json:"state"`
KeyID string `gorm:"size:64;not null;uniqueIndex" json:"key_id"`
CertificatePEM string `gorm:"type:text;not null" json:"certificate_pem"`
SealedKey string `gorm:"type:text;not null" json:"-"`
NotBefore time.Time `gorm:"not null" json:"not_before"`
NotAfter time.Time `gorm:"not null" json:"not_after"`
ActivatedAt *time.Time `json:"activated_at"`
RetiredAt *time.Time `json:"retired_at"`
CreatedAt time.Time `json:"created_at"`
}
ServiceCA is one certificate authority of the kernel's module PKI. Its private key is stored sealed under the configured key-encryption key.
type ServiceScope ¶
type ServiceScope struct {
ID string `gorm:"primaryKey;size:64" json:"id"`
Name string `gorm:"size:120;not null" json:"name"`
Description string `gorm:"type:text" json:"description"`
PluginID string `gorm:"size:120;index" json:"plugin_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ServiceScope is an authorization namespace. A user may belong to multiple groups in each scope without leaking quota or grants into another service.
func (ServiceScope) TableName ¶
func (ServiceScope) TableName() string
type SettingsRequest ¶ added in v4.1.0
type SettingsRequest struct {
RequestID string `gorm:"primaryKey;size:128" json:"request_id"`
Namespace string `gorm:"size:64;not null" json:"namespace"`
Method string `gorm:"size:32;not null" json:"method"`
PackageID string `gorm:"size:128;not null;default:''" json:"package_id"`
Result string `gorm:"type:text;not null;default:''" json:"result"`
CreatedAt time.Time `gorm:"not null;index" json:"created_at"`
}
SettingsRequest records each applied KernelSettings write by request id, with its namespace, method, calling package and result, so a retried write is applied once. Rows are kept for 90 days.
func (SettingsRequest) TableName ¶ added in v4.1.0
func (SettingsRequest) TableName() string
type ShadowMismatchSample ¶ added in v4.1.0
type ShadowMismatchSample struct {
ID uint `gorm:"primaryKey" json:"id"`
PackageID string `` /* 134-byte string literal not displayed */
// SampleID is the host's id of the sample; the kernel stores each once.
SampleID string `gorm:"size:32;not null;uniqueIndex:idx_v4_shadow_sample_key,priority:2" json:"sample_id"`
RouteID string `gorm:"size:191;not null;index:idx_v4_shadow_sample_route,priority:2" json:"route_id"`
PackageVersion string `gorm:"size:64;not null;default:''" json:"package_version"`
Method string `gorm:"size:16;not null;default:''" json:"method"`
Path string `gorm:"size:512;not null;default:''" json:"path"`
LegacyStatus int `gorm:"not null;default:0" json:"legacy_status"`
NativeStatus int `gorm:"not null;default:0" json:"native_status"`
DiffJSON string `gorm:"type:text;not null" json:"-"`
DiffTruncated bool `gorm:"not null;default:false" json:"diff_truncated"`
RequestID string `gorm:"size:128;not null;default:''" json:"request_id"`
ObservedAt time.Time `gorm:"not null;index;index:idx_v4_shadow_sample_route,priority:3" json:"observed_at"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
}
ShadowMismatchSample is one sanitized shadow-mode mismatch of a package route: the kernel stores what package hosts report in their Health details (sdk/shadowsample) after sanitizing it again. Rows are kept for seven days and at most 100 per route (internal/shadowsamples).
func (ShadowMismatchSample) TableName ¶ added in v4.1.0
func (ShadowMismatchSample) TableName() string
type SpeedLimit ¶
type SpeedLimit struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedTime int64 `gorm:"index;not null" json:"createdTime"`
UpdatedTime int64 `gorm:"index;not null" json:"updatedTime"`
Status int `gorm:"default:1" json:"status"`
Name string `gorm:"size:100;not null" json:"name"`
Speed int64 `gorm:"not null" json:"speed"`
TunnelID uint `gorm:"index;not null" json:"tunnelId"`
TunnelName string `gorm:"size:100;not null" json:"tunnelName"`
}
SpeedLimit mirrors the flux-panel speed-limit resource.
func (SpeedLimit) TableName ¶
func (SpeedLimit) TableName() string
type StatServer ¶
type StatServer struct {
ID uint `gorm:"primaryKey" json:"id"`
ServerID uint `gorm:"index" json:"server_id"`
ServerType string `gorm:"size:20" json:"server_type"`
U int64 `json:"u"`
D int64 `json:"d"`
RecordType string `gorm:"size:1" json:"record_type"` // d: day, m: month
RecordAt int64 `gorm:"index" json:"record_at"`
}
StatServer 服务器统计
func (StatServer) TableName ¶
func (StatServer) TableName() string
type StatUser ¶
type StatUser struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
ServerRate float64 `json:"server_rate"`
U int64 `json:"u"`
D int64 `json:"d"`
RecordType string `gorm:"size:1" json:"record_type"`
RecordAt int64 `gorm:"index" json:"record_at"`
}
StatUser 用户统计
type StripeConfig ¶
type StripeConfig struct {
PublishableKey string `json:"publishable_key"`
SecretKey string `json:"secret_key"`
WebhookSecret string `json:"webhook_secret"`
Currency string `json:"currency"` // USD, EUR 等
}
StripeConfig Stripe 支付配置
type SubscriberChange ¶ added in v4.1.0
type SubscriberChange struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
UserID uint `gorm:"not null;index" json:"user_id"`
Deleted bool `gorm:"not null;default:false" json:"deleted"`
CreatedAt time.Time `gorm:"not null;index" json:"created_at"`
}
SubscriberChange is the change log node user lists follow: a row per change that can alter what a node serves (entitlements, ban, uuid, traffic exhaustion or reset, creation, deletion). ID is the cursor. Consumers read the subscriber's current state; rows are kept 7 days.
func (SubscriberChange) TableName ¶ added in v4.1.0
func (SubscriberChange) TableName() string
type SubscriberRequest ¶ added in v4.1.0
type SubscriberRequest struct {
RequestID string `gorm:"primaryKey;size:128" json:"request_id"`
Method string `gorm:"size:32;not null" json:"method"`
UserID uint `gorm:"not null;index" json:"user_id"`
Result string `gorm:"type:text;not null;default:''" json:"result"`
CreatedAt time.Time `gorm:"not null;index" json:"created_at"`
}
SubscriberRequest records each applied subscriber write (KernelSubscriber and the kernel's own callers) by request id, with its result, so a retried request is applied once.
func (SubscriberRequest) TableName ¶ added in v4.1.0
func (SubscriberRequest) TableName() string
type SubscriptionFormat ¶
type SubscriptionFormat string
SubscriptionFormat 订阅格式类型
const ( FormatV2Ray SubscriptionFormat = "v2ray" // Base64 编码的链接列表 FormatClash SubscriptionFormat = "clash" // Clash YAML FormatStash SubscriptionFormat = "stash" // Stash YAML (兼容 Clash) FormatEgern SubscriptionFormat = "egern" // Egern YAML (兼容 Clash) FormatSurge SubscriptionFormat = "surge" // Surge 配置 FormatLoon SubscriptionFormat = "loon" // Loon 配置 FormatShadowrocket SubscriptionFormat = "shadowrocket" // Shadowrocket 配置 FormatQuantumultX SubscriptionFormat = "quantumultx" // Quantumult X 配置 FormatJSON SubscriptionFormat = "json" // 原始 JSON FormatBase64JSON SubscriptionFormat = "base64json" // Base64 编码的 JSON (你的自定义格式) FormatSingBox SubscriptionFormat = "sing-box" // Sing-box JSON FormatWireGuard SubscriptionFormat = "wireguard" // WireGuard 原生配置 )
type SubscriptionGroup ¶
type SubscriptionGroup struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;uniqueIndex" json:"name"` // 分组名称
Description *string `gorm:"size:500" json:"description"` // 分组描述
Priority int `gorm:"default:0" json:"priority"` // 优先级 (数值越大优先级越高)
Enable int `gorm:"default:1" json:"enable"` // 是否启用
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// 关联
Templates []SubscriptionTemplate `gorm:"foreignKey:GroupID" json:"templates,omitempty"`
Protocols []NodeProtocol `gorm:"many2many:v2_subscription_group_node_protocols;" json:"protocols,omitempty"`
}
SubscriptionGroup 订阅分组 (权限组) 不同分组可以看到不同的节点配置
func (SubscriptionGroup) TableName ¶
func (SubscriptionGroup) TableName() string
type SubscriptionRequest ¶
type SubscriptionRequest struct {
Token string `json:"token"` // 用户 Token
Format SubscriptionFormat `json:"format,omitempty"` // 输出格式
Groups []uint `json:"groups,omitempty"` // 指定分组 (可选)
Include string `json:"include,omitempty"` // 包含关键词
Exclude string `json:"exclude,omitempty"` // 排除关键词
SubscribeURL string `json:"-"` // 当前请求订阅 URL(供格式化器使用)
SubscribeDomain string `json:"-"` // 当前请求订阅域名(供格式化器使用)
}
SubscriptionRequest 订阅请求参数
type SubscriptionResponse ¶
type SubscriptionResponse struct {
Content string `json:"content"` // 订阅内容
ContentType string `json:"content_type"` // MIME 类型
Filename string `json:"filename,omitempty"` // 下载文件名
UpdatedAt int64 `json:"updated_at"` // 更新时间
ExpireAt int64 `json:"expire_at,omitempty"` // 用户过期时间
UsedTraffic int64 `json:"used_traffic,omitempty"` // 已用流量
TotalTraffic int64 `json:"total_traffic,omitempty"` // 总流量
}
SubscriptionResponse 订阅响应
type SubscriptionTemplate ¶
type SubscriptionTemplate struct {
ID uint `gorm:"primaryKey" json:"id"`
GroupID uint `gorm:"index" json:"group_id"` // 所属分组
Name string `gorm:"size:255" json:"name"` // 模板名称 (显示给用户的节点名)
Type string `gorm:"size:30" json:"type"` // 协议类型: vmess, vless, trojan, shadowsocks, hysteria2, tuic, anytls
Enable int `gorm:"default:1" json:"enable"` // 是否启用
Sort int `gorm:"default:0" json:"sort"` // 排序
Tags *string `gorm:"size:255" json:"tags"` // 标签 (JSON array)
// JSON 模板配置 (高级功能)
// 支持变量占位符: {{.UUID}}, {{.UserID}}, {{.Email}}, {{.ExpiredAt}}, {{.SpeedLimit}}, {{.DeviceLimit}}
// 以及自定义变量: {{.Custom.xxx}}
TemplateJSON string `gorm:"type:text" json:"template_json"`
// 服务器基础配置 (对应 AnixOps Agent CommonNode)
Server string `gorm:"size:255" json:"server"` // 服务器地址 (host)
Port int `json:"port"` // 端口 (server_port)
ServerName *string `gorm:"size:255" json:"server_name"` // SNI 服务器名称
// TLS 配置 (对应 AnixOps Agent tls 字段)
TLS int `gorm:"default:0" json:"tls"` // 0=无, 1=TLS, 2=Reality
TLSFingerprint *string `gorm:"size:50" json:"tls_fingerprint"` // TLS 指纹 (chrome, firefox, safari, ios, android, edge, 360, qq, random)
ALPN *string `gorm:"size:100" json:"alpn"` // ALPN (h2,http/1.1)
// Reality 配置 (当 TLS=2 时使用, 对应 AnixOps Agent tls_settings)
RealityPublicKey *string `gorm:"size:100" json:"reality_public_key"` // X25519 公钥 (对应 pbk)
RealityShortID *string `gorm:"size:50" json:"reality_short_id"` // Short ID (对应 sid)
RealitySpiderX *string `gorm:"size:255" json:"reality_spider_x"` // SpiderX (对应 spx)
RealityDest *string `gorm:"size:255" json:"reality_dest"` // 回落目标 (dest)
// 传输层配置 (对应 AnixOps Agent network, network_settings)
Transport string `gorm:"size:20;default:tcp" json:"transport"` // 传输协议: tcp, ws, grpc, httpupgrade, xhttp
TransportSettings *string `gorm:"type:text" json:"transport_settings,omitempty"` // 传输层配置 JSON
// VLESS 特有配置 (对应 AnixOps Agent flow, encryption, encryption_settings)
Flow *string `gorm:"size:50" json:"flow"` // 流控: xtls-rprx-vision
Encryption *string `gorm:"size:50" json:"encryption"` // 加密: 空 或 mlkem768x25519plus
EncryptionSettings *string `gorm:"type:text" json:"encryption_settings"` // 加密配置 JSON
// Shadowsocks 配置 (对应 AnixOps Agent cipher, server_key)
SSCipher *string `gorm:"size:50" json:"ss_cipher"` // SS 加密方式
SSServerKey *string `gorm:"size:100" json:"ss_server_key"` // SS2022 服务器密钥
// 协议特定配置 (存储其他不在通用字段中的配置)
ProtocolSettings *string `gorm:"type:text" json:"protocol_settings"` // 协议配置 JSON
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// 关联
Group *SubscriptionGroup `gorm:"foreignKey:GroupID" json:"group,omitempty"`
}
SubscriptionTemplate 订阅模板 (JSON 配置模板) 每个模板定义一种节点配置,通过函数变量赋值后下发给用户 符合 AnixOps Agent/Xray 协议配置规范
func (*SubscriptionTemplate) GetProtocolSettings ¶
func (t *SubscriptionTemplate) GetProtocolSettings() map[string]any
GetProtocolSettings 获取协议配置
func (*SubscriptionTemplate) GetTags ¶
func (t *SubscriptionTemplate) GetTags() []string
GetTags 获取标签列表
func (*SubscriptionTemplate) GetTransportSettings ¶
func (t *SubscriptionTemplate) GetTransportSettings() map[string]any
GetTransportSettings 获取传输层配置
func (SubscriptionTemplate) TableName ¶
func (SubscriptionTemplate) TableName() string
type SystemConfig ¶
type SystemConfig struct {
ID uint `gorm:"primaryKey" json:"id"`
Key string `gorm:"size:100;uniqueIndex" json:"key"`
Value string `gorm:"type:text" json:"value"`
Type string `gorm:"size:20;default:string" json:"type"` // string/number/boolean/json
Group string `gorm:"size:50;index" json:"group"` // 配置分组
Remark string `gorm:"size:255" json:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SystemConfig 系统配置
type TelegramBot ¶
type TelegramBot struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;not null" json:"name"`
Token string `gorm:"size:200;not null" json:"token"`
Enabled bool `gorm:"default:false" json:"enabled"`
// Webhook配置
WebhookURL string `gorm:"size:255" json:"webhook_url"`
WebhookSet bool `gorm:"default:false" json:"webhook_set"`
// 管理员
AdminIDs string `gorm:"type:text" json:"admin_ids"` // JSON数组
// 欢迎消息
WelcomeMsg string `gorm:"type:text" json:"welcome_msg"`
// 功能开关
AllowBind bool `gorm:"default:true" json:"allow_bind"` // 允许绑定账户
AllowSub bool `gorm:"default:true" json:"allow_sub"` // 允许获取订阅
AllowTicket bool `gorm:"default:true" json:"allow_ticket"` // 允许创建工单
AllowInfo bool `gorm:"default:true" json:"allow_info"` // 允许查看信息
// 统计
TotalUsers int64 `json:"total_users"`
TotalChats int64 `json:"total_chats"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TelegramBot Telegram Bot配置
type TelegramChat ¶
type TelegramChat struct {
ID uint `gorm:"primaryKey" json:"id"`
BotID uint `gorm:"index" json:"bot_id"`
TelegramID int64 `gorm:"index" json:"telegram_id"`
UserID *uint `json:"user_id"`
// 消息
MessageID int64 `json:"message_id"`
MessageType string `gorm:"size:20" json:"message_type"` // text/command/callback
Content string `gorm:"type:text" json:"content"`
// 回复
ReplyToID *uint `json:"reply_to_id"`
CreatedAt time.Time `gorm:"index" json:"created_at"`
}
TelegramChat Telegram聊天记录
type TelegramCommand ¶
type TelegramCommand struct {
ID uint `gorm:"primaryKey" json:"id"`
BotID uint `json:"bot_id"`
Command string `gorm:"size:50;not null" json:"command"` // 命令 (不含/)
Description string `gorm:"size:200" json:"description"` // 描述
Handler string `gorm:"size:100" json:"handler"` // 处理函数名
Enabled bool `gorm:"default:true" json:"enabled"`
IsAdmin bool `gorm:"default:false" json:"is_admin"` // 是否管理员命令
Sort int `gorm:"default:0" json:"sort"`
}
TelegramCommand Bot命令定义
type TelegramNotification ¶
type TelegramNotification struct {
ID uint `gorm:"primaryKey" json:"id"`
TelegramID int64 `gorm:"index" json:"telegram_id"`
UserID *uint `json:"user_id"`
// 通知内容
Type string `gorm:"size:50" json:"type"` // expire/traffic/ticket/system
Title string `gorm:"size:200" json:"title"`
Content string `gorm:"type:text" json:"content"`
// 状态
Status int `json:"status"` // 0=待发送 1=已发送 2=发送失败
Error string `gorm:"size:500" json:"error"`
SentAt *time.Time `json:"sent_at"`
CreatedAt time.Time `json:"created_at"`
}
TelegramNotification Telegram通知记录
func (TelegramNotification) TableName ¶
func (TelegramNotification) TableName() string
TableName 指定表名
type TelegramUser ¶
type TelegramUser struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"uniqueIndex" json:"user_id"` // 系统用户ID
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
TelegramID int64 `gorm:"uniqueIndex" json:"telegram_id"` // Telegram用户ID
Username string `gorm:"size:100" json:"username"` // Telegram用户名
FirstName string `gorm:"size:100" json:"first_name"` // 名
LastName string `gorm:"size:100" json:"last_name"` // 姓
LanguageCode string `gorm:"size:10" json:"language_code"` // 语言代码
// 状态
IsBanned bool `gorm:"default:false" json:"is_banned"`
BannedAt *time.Time `json:"banned_at"`
// 通知设置
NotifyExpire bool `gorm:"default:true" json:"notify_expire"` // 到期通知
NotifyTraffic bool `gorm:"default:true" json:"notify_traffic"` // 流量通知
NotifyTicket bool `gorm:"default:true" json:"notify_ticket"` // 工单通知
// 统计
MessageCount int64 `json:"message_count"`
LastActive time.Time `json:"last_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TelegramUser Telegram用户绑定
type TemplateRenderContext ¶
type TemplateRenderContext struct {
// 用户信息
UUID string `json:"uuid"`
UserID uint `json:"user_id"`
Email string `json:"email"`
ExpiredAt int64 `json:"expired_at"`
SpeedLimit int64 `json:"speed_limit"` // bytes/s
DeviceLimit int `json:"device_limit"`
// 流量信息
TransferEnable int64 `json:"transfer_enable"` // 总流量
UsedTraffic int64 `json:"used_traffic"` // 已用流量
// 自定义变量 (管理员可扩展)
Custom map[string]any `json:"custom,omitempty"`
// 订阅元信息 (用于生成客户端特定配置,如 Surge managed-config)
SubscribeURL string `json:"subscribe_url,omitempty"`
SubscribeDomain string `json:"subscribe_domain,omitempty"`
}
TemplateRenderContext 模板渲染上下文 传递给模板引擎进行变量替换
type Ticket ¶
type Ticket struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
Subject string `gorm:"size:255" json:"subject"`
Level int `gorm:"default:1" json:"level"` // 0: low, 1: medium, 2: high
Status int `gorm:"default:0" json:"status"` // 0: open, 1: answered, 2: closed
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Relations
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
Messages []TicketMessage `gorm:"foreignKey:TicketID" json:"messages,omitempty"`
}
Ticket 工单模型
type TicketMessage ¶
type TicketMessage struct {
ID uint `gorm:"primaryKey" json:"id"`
TicketID uint `gorm:"index" json:"ticket_id"`
UserID uint `gorm:"index" json:"user_id"`
Message string `gorm:"type:text" json:"message"`
IsAdmin int `gorm:"default:0" json:"is_admin"` // 0: user, 1: admin
CreatedAt time.Time `json:"created_at"`
}
TicketMessage 工单消息模型
func (TicketMessage) TableName ¶
func (TicketMessage) TableName() string
type Topology ¶
type Topology struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:160;not null;uniqueIndex" json:"name"`
ServiceScope string `gorm:"size:64;not null;index" json:"service_scope"`
Description string `gorm:"type:text" json:"description"`
ActiveRevisionID *uint `gorm:"index" json:"active_revision_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type TopologyDeployment ¶
type TopologyDeployment struct {
ID uint `gorm:"primaryKey" json:"id"`
TopologyID uint `gorm:"not null;index" json:"topology_id"`
RevisionID uint `gorm:"not null;index" json:"revision_id"`
PreviousRevisionID *uint `json:"previous_revision_id"`
RolloutGroup string `gorm:"size:80" json:"rollout_group"`
State string `gorm:"size:32;not null;index" json:"state"`
FailurePolicy string `gorm:"size:32;not null" json:"failure_policy"`
LastError string `gorm:"type:text" json:"last_error"`
// HealthGateDeadlineAt is a durable grace window for a terminal Agent
// operation to be followed by its independent runtime observation.
HealthGateDeadlineAt *time.Time `json:"health_gate_deadline_at"`
RollbackStartedAt *time.Time `json:"rollback_started_at"`
RollbackCompletedAt *time.Time `json:"rollback_completed_at"`
CreatedBy uint `gorm:"not null" json:"created_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CompletedAt *time.Time `json:"completed_at"`
}
func (TopologyDeployment) TableName ¶
func (TopologyDeployment) TableName() string
type TopologyDeploymentStep ¶
type TopologyDeploymentStep struct {
ID uint `gorm:"primaryKey" json:"id"`
DeploymentID uint `gorm:"not null;index;uniqueIndex:ux_topology_deployment_step" json:"deployment_id"`
VertexID uint `gorm:"not null;uniqueIndex:ux_topology_deployment_step" json:"vertex_id"`
VertexKey string `gorm:"size:120;not null" json:"vertex_key"`
NodeID uint `gorm:"not null;index" json:"node_id"`
PluginID string `gorm:"size:120;not null" json:"plugin_id"`
Role string `gorm:"size:80;not null" json:"role"`
TargetVersion string `gorm:"size:64;not null" json:"target_version"`
ApplyOrder int `gorm:"not null;index" json:"apply_order"`
Removal bool `gorm:"not null;default:false" json:"removal"`
ApplyAction string `gorm:"size:32;not null" json:"apply_action"`
ConfigJSON string `gorm:"type:text;not null;default:{}" json:"config"`
RollbackMode string `gorm:"size:32;not null" json:"rollback_mode"`
RollbackConfigJSON string `gorm:"type:text;not null;default:{}" json:"rollback_config"`
State string `gorm:"size:32;not null;index" json:"state"`
ConfigureOperationID string `gorm:"size:64;index" json:"configure_operation_id"`
EnableOperationID string `gorm:"size:64;index" json:"enable_operation_id"`
DisableOperationID string `gorm:"size:64;index" json:"disable_operation_id"`
RollbackConfigureOperationID string `gorm:"size:64;index" json:"rollback_configure_operation_id"`
RollbackEnableOperationID string `gorm:"size:64;index" json:"rollback_enable_operation_id"`
RollbackDisableOperationID string `gorm:"size:64;index" json:"rollback_disable_operation_id"`
LastError string `gorm:"type:text" json:"last_error"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TopologyDeploymentStep is the durable, per-vertex execution plan for one immutable topology revision. It stores operation identities rather than an in-memory work queue so a Control restart can resume or compensate a partially applied deployment deterministically.
ApplyAction is either configure_enable or disable. RollbackMode is restore (configure the previous active revision and enable it) or disable (there was no previous vertex to restore). States are advanced only by the topology deployment executor.
func (TopologyDeploymentStep) TableName ¶
func (TopologyDeploymentStep) TableName() string
type TopologyEdge ¶
type TopologyEdge struct {
ID uint `gorm:"primaryKey" json:"id"`
RevisionID uint `gorm:"not null;index" json:"revision_id"`
SourceKey string `gorm:"size:120;not null" json:"source_key"`
TargetKey string `gorm:"size:120;not null" json:"target_key"`
Protocol string `gorm:"size:48;not null" json:"protocol"`
SecretID string `gorm:"size:160" json:"secret_id"`
ConfigJSON string `gorm:"type:text;not null" json:"config"`
}
func (TopologyEdge) TableName ¶
func (TopologyEdge) TableName() string
type TopologyObservedState ¶
type TopologyObservedState struct {
ID uint `gorm:"primaryKey" json:"id"`
DeploymentID uint `gorm:"not null;index;uniqueIndex:ux_observed_deployment_node" json:"deployment_id"`
NodeID uint `gorm:"not null;uniqueIndex:ux_observed_deployment_node" json:"node_id"`
DesiredRevision int64 `gorm:"not null" json:"desired_revision"`
ObservedRevision int64 `gorm:"not null" json:"observed_revision"`
State string `gorm:"size:32;not null" json:"state"`
HealthJSON string `gorm:"type:text" json:"health"`
LastError string `gorm:"type:text" json:"last_error"`
UpdatedAt time.Time `json:"updated_at"`
}
func (TopologyObservedState) TableName ¶
func (TopologyObservedState) TableName() string
type TopologyRevision ¶
type TopologyRevision struct {
ID uint `gorm:"primaryKey" json:"id"`
TopologyID uint `gorm:"not null;uniqueIndex:ux_topology_revision" json:"topology_id"`
Revision int64 `gorm:"not null;uniqueIndex:ux_topology_revision" json:"revision"`
State string `gorm:"size:24;not null;index" json:"state"`
ContentHash string `gorm:"size:64;not null" json:"content_hash"`
Message string `gorm:"type:text" json:"message"`
CreatedBy uint `gorm:"not null" json:"created_by"`
CreatedAt time.Time `json:"created_at"`
}
func (TopologyRevision) TableName ¶
func (TopologyRevision) TableName() string
type TopologyVertex ¶
type TopologyVertex struct {
ID uint `gorm:"primaryKey" json:"id"`
RevisionID uint `gorm:"not null;index;uniqueIndex:ux_topology_vertex_key" json:"revision_id"`
Key string `gorm:"size:120;not null;uniqueIndex:ux_topology_vertex_key" json:"key"`
Kind string `gorm:"size:48;not null" json:"kind"`
NodeID *uint `gorm:"index" json:"node_id"`
PluginID string `gorm:"size:120;index" json:"plugin_id"`
Role string `gorm:"size:80" json:"role"`
ConfigJSON string `gorm:"type:text;not null" json:"config"`
}
func (TopologyVertex) TableName ¶
func (TopologyVertex) TableName() string
type TrafficLog ¶
type TrafficLog struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index;index:idx_server_log_log_at_user_id,priority:2" json:"user_id"`
ServerID uint `gorm:"index" json:"server_id"`
ServerType string `gorm:"size:20" json:"server_type"`
U int64 `json:"u"` // upload bytes
D int64 `json:"d"` // download bytes
Rate float64 `gorm:"default:1" json:"rate"`
LogAt int64 `gorm:"index;index:idx_server_log_log_at_user_id,priority:1" json:"log_at"`
CreatedAt time.Time `json:"created_at"`
}
TrafficLog 流量日志
func (TrafficLog) TableName ¶
func (TrafficLog) TableName() string
type USDTConfig ¶
type USDTConfig struct {
Network string `json:"network"` // 网络 (TRC20/ERC20/BEP20)
WalletAddress string `json:"wallet_address"` // 收款钱包地址
APIKey string `json:"api_key"` // 区块链API密钥 (可选)
Confirmations int `json:"confirmations"` // 确认数
}
USDTConfig USDT支付配置
type User ¶
type User struct {
ID uint `gorm:"primaryKey" json:"id"`
InviteUserID *uint `gorm:"index" json:"invite_user_id"`
TelegramID *int64 `json:"telegram_id"`
Email string `gorm:"size:255;uniqueIndex" json:"email"`
Password string `gorm:"size:255" json:"-"`
PasswordAlgo *string `gorm:"size:20" json:"-"`
PasswordSalt *string `gorm:"size:20" json:"-"`
Balance int64 `gorm:"default:0" json:"balance"`
Discount *int `json:"discount"`
CommissionType int `gorm:"default:0" json:"commission_type"`
CommissionRate *int `json:"commission_rate"`
CommissionBalance int64 `gorm:"default:0" json:"commission_balance"`
Token string `gorm:"size:36;uniqueIndex" json:"token"`
UUID string `gorm:"size:36;uniqueIndex" json:"uuid"`
DeviceLimit *int `json:"device_limit"`
SpeedLimit *int64 `json:"speed_limit"`
FlowResetTime int64 `gorm:"default:0" json:"flowResetTime"`
TransferEnable int64 `gorm:"default:0" json:"transfer_enable"` // bytes
U int64 `gorm:"default:0" json:"u"` // upload bytes
D int64 `gorm:"default:0" json:"d"` // download bytes
PlanID *uint `gorm:"index" json:"plan_id"`
GroupID *uint `gorm:"index" json:"group_id"`
ExpiredAt *int64 `json:"expired_at"`
Banned int `gorm:"default:0" json:"banned"`
RemarkContent *string `gorm:"type:text" json:"remark_content"`
IsAdmin int `gorm:"default:0" json:"is_admin"`
IsStaff int `gorm:"default:0" json:"is_staff"`
LastLoginAt *int64 `json:"last_login_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Relations
Plan *Plan `gorm:"foreignKey:PlanID" json:"plan,omitempty"`
}
User 用户模型
type UserActivity ¶ added in v4.2.0
type UserActivity struct {
UserID uint `gorm:"primaryKey;autoIncrement:false" json:"user_id"`
// LastOnlineAt is a Unix time in seconds.
LastOnlineAt int64 `gorm:"not null;index" json:"last_online_at"`
}
UserActivity is when a user was last seen online: the latest traffic report that carried the user's traffic or alive report that listed one of the user's connections, from any node or Agent (subscriber.RecordOnline). It is a table of its own because Control keeps no durable value for it: v2_user has no such column, the online set is a five-minute cache and v2_server_log is purged by the operator. One row per user, written at most once per subscriber.ActivityWriteInterval; a user never seen has no row.
func (UserActivity) TableName ¶ added in v4.2.0
func (UserActivity) TableName() string
type UserLevel ¶
type UserLevel struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:50" json:"name"`
Level int `gorm:"uniqueIndex" json:"level"` // 等级数值
Icon string `gorm:"size:255" json:"icon"` // 图标
Color string `gorm:"size:20" json:"color"` // 颜色
// 权益
Discount int `gorm:"default:0" json:"discount"` // 折扣百分比
SpeedLimit *int64 `json:"speed_limit"` // 专属速度限制
DeviceLimit *int `json:"device_limit"` // 专属设备限制
// 升级条件
MinDays int `gorm:"default:0" json:"min_days"` // 最少使用天数
MinTraffic int64 `gorm:"default:0" json:"min_traffic"` // 最少使用流量
MinOrders int `gorm:"default:0" json:"min_orders"` // 最少订单数
MinAmount float64 `gorm:"default:0" json:"min_amount"` // 最少消费金额
Enabled bool `gorm:"default:true" json:"enabled"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
UserLevel 用户等级
type UserMFA ¶
type UserMFA struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"uniqueIndex" json:"user_id"`
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
Enabled bool `gorm:"default:false" json:"enabled"`
// TOTP配置
TOTPSecret string `gorm:"size:100" json:"totp_secret"` // TOTP密钥 (base32)
BackupCodes string `gorm:"type:text" json:"backup_codes"` // 备用码 (JSON数组)
// 短信/邮箱验证
Phone string `gorm:"size:20" json:"phone"` // 手机号
PhoneVerified bool `gorm:"default:false" json:"phone_verified"`
// 最后使用时间
LastUsed *time.Time `json:"last_used"`
LastMethod string `gorm:"size:20" json:"last_method"` // totp/sms/email
// 恢复信息
RecoveryEmail string `gorm:"size:100" json:"recovery_email"` // 恢复邮箱
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
UserMFA 用户多因素认证
type UserSubscriptionGroup ¶
type UserSubscriptionGroup struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"uniqueIndex:idx_user_group" json:"user_id"`
GroupID uint `gorm:"uniqueIndex:idx_user_group" json:"group_id"`
ExpireAt *int64 `json:"expire_at"` // 分组权限过期时间 (null=永不过期)
TransferEnable *int64 `json:"transfer_enable"` // 自定义总流量 (bytes), null 表示不覆盖用户默认
NextRenewPrice *int64 `json:"next_renew_price"` // 下次续费价格 (单位分)
CreatedAt time.Time `json:"created_at"`
// 关联
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
Group *SubscriptionGroup `gorm:"foreignKey:GroupID" json:"group,omitempty"`
}
UserSubscriptionGroup 用户-订阅分组关联 (多对多) 用户可以属于多个分组,拥有多个分组的权限
func (UserSubscriptionGroup) TableName ¶
func (UserSubscriptionGroup) TableName() string
type WechatPayConfig ¶
type WechatPayConfig struct {
AppID string `json:"app_id"` // 应用ID
MchID string `json:"mch_id"` // 商户号
APIKey string `json:"api_key"` // API密钥
APIV3Key string `json:"api_v3_key"` // APIv3密钥
CertPath string `json:"cert_path"` // 商户证书路径
KeyPath string `json:"key_path"` // 商户私钥路径
NotifyURL string `json:"notify_url"` // 异步通知地址
Sandbox bool `json:"sandbox"` // 沙箱模式
}
WechatPayConfig 微信支付配置
type WireGuardPeer ¶
type WireGuardPeer struct {
ID uint `gorm:"primaryKey" json:"id"`
NodeProtocolID uint `gorm:"uniqueIndex:idx_wg_peer_protocol_user;index;uniqueIndex:idx_wg_peer_protocol_ip" json:"node_protocol_id"`
UserID uint `gorm:"uniqueIndex:idx_wg_peer_protocol_user;index" json:"user_id"`
PeerIP string `gorm:"size:64;uniqueIndex:idx_wg_peer_protocol_ip" json:"peer_ip"`
PrivateKey string `gorm:"size:64" json:"-"`
PublicKey string `gorm:"size:64" json:"public_key"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
NodeProtocol *NodeProtocol `gorm:"foreignKey:NodeProtocolID" json:"node_protocol,omitempty"`
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
}
WireGuardPeer stores the panel-managed per-user WireGuard credentials for a concrete node protocol. It is keyed by protocol+user so subscriptions stay stable across refreshes.
func (WireGuardPeer) TableName ¶
func (WireGuardPeer) TableName() string
type X402Config ¶
type X402Config struct {
WalletAddress string `json:"wallet_address"` // 收款钱包地址
Network string `json:"network"` // 网络 (ethereum, polygon, arbitrum, base, sepolia等)
AcceptTokens []string `json:"accept_tokens"` // 接受的代币 (ETH, USDT, USDC等)
TestMode bool `json:"test_mode"` // 是否测试模式 (使用测试链)
WebhookSecret string `json:"webhook_secret"` // Webhook 密钥
ConfirmBlocks int `json:"confirm_blocks"` // 确认区块数
}
X402Config X402 虚拟货币支付配置
Source Files
¶
- admin_api_token.go
- agent_diagnostic_task.go
- agent_pki.go
- agent_report.go
- agent_transport.go
- agent_upgrade.go
- audit_log.go
- auth.go
- coupon.go
- event.go
- forward.go
- forward_agent_bridge.go
- forward_clean_agent.go
- forward_legacy.go
- forward_link_pki.go
- forward_observability.go
- forward_panel.go
- forward_runtime.go
- identity_account.go
- identity_revocation.go
- identity_token_key.go
- invite.go
- kernel.go
- kernel_alert.go
- kernel_forward.go
- kernel_forward_dns.go
- knowledge.go
- mfa.go
- module_pki.go
- node.go
- node_config_status.go
- node_desired_config.go
- node_log.go
- node_operation.go
- node_secret.go
- notification.go
- order.go
- package_report.go
- payment.go
- payment_gateway.go
- plan.go
- plugin_rollout.go
- route_mode_revision.go
- server.go
- settings.go
- shadow_mismatch_sample.go
- speed_limit.go
- subscriber.go
- subscription.go
- system.go
- telegram.go
- ticket.go
- user.go