95 lines
3.4 KiB
Go
95 lines
3.4 KiB
Go
package models
|
|
|
|
// CPUInfo 结构体用于存储 CPU 信息
|
|
type CPUInfo struct {
|
|
ModelName string `json:"model_name"`
|
|
Cores int `json:"cores"`
|
|
Architecture string `json:"architecture"`
|
|
UUID string `json:"uuid"`
|
|
}
|
|
|
|
// MemoryInfo holds the memory information.
|
|
type MemoryInfo struct {
|
|
Total uint64 `json:"total"`
|
|
Free uint64 `json:"free"`
|
|
Available uint64 `json:"available"`
|
|
Used uint64 `json:"used"` // 已用内存
|
|
Buffers uint64 `json:"buffers"` // 缓冲区内存
|
|
Cached uint64 `json:"cached"` // 缓存内存
|
|
Shared uint64 `json:"shared"` // 共享内存
|
|
}
|
|
|
|
// DiskInfo holds the disk information similar to df -Th output.
|
|
type DiskInfo struct {
|
|
Device string `json:"device"` // 逻辑分区设备名称
|
|
Filesystem string `json:"filesystem"` // 逻辑分区
|
|
Type string `json:"type"` // 文件系统类型
|
|
Size uint64 `json:"size"` // 总大小
|
|
Used uint64 `json:"used"` // 已用空间
|
|
Available uint64 `json:"available"` // 可用空间
|
|
UsePercent string `json:"use_percent"` // 使用百分比
|
|
MountPoint string `json:"mount_point"`
|
|
PhysicalDevice string `json:"physical_device"` // 物理设备名称
|
|
PhysicalSize uint64 `json:"physical_size"` // 物理盘大小
|
|
}
|
|
|
|
// NetworkInterfaceInfo 结构体用于存储网卡信息
|
|
type NetworkInterfaceInfo struct {
|
|
Name string `json:"name"`
|
|
MACAddress string `json:"mac_address"`
|
|
IPAddresses []string `json:"ip_addresses"`
|
|
}
|
|
|
|
// MotherboardInfo holds the motherboard information.
|
|
type MotherboardInfo struct {
|
|
Manufacturer string `json:"manufacturer"`
|
|
Product string `json:"product"`
|
|
Version string `json:"version"`
|
|
Serial string `json:"serial"`
|
|
}
|
|
|
|
type SystemInfo struct {
|
|
MachineID string `json:"machine_id"` // 唯一标识符
|
|
OS OSInfo `json:"os"` // 操作系统
|
|
KernelVersion string `json:"kernel_version"` // 内核版本
|
|
}
|
|
|
|
type OSInfo struct {
|
|
Name string `json:"name"`
|
|
Version string `json:"version"`
|
|
ID string `json:"id"`
|
|
IDLike string `json:"id_like"`
|
|
VersionID string `json:"version_id"`
|
|
PrettyName string `json:"pretty_name"`
|
|
HomeURL string `json:"home_url"`
|
|
SupportURL string `json:"support_url"`
|
|
BugReportURL string `json:"bug_report_url"`
|
|
PrivacyURL string `json:"privacy_url"`
|
|
}
|
|
|
|
// HostInfo 主机信息模型
|
|
type HostInfo struct {
|
|
SystemInfo SystemInfo `json:"system_info"`
|
|
CPUInfo CPUInfo `json:"cpu_info"`
|
|
DiskInfo []DiskInfo `json:"disk_info"`
|
|
MemoryInfo MemoryInfo `json:"memory_info"`
|
|
NetInfo []NetworkInterfaceInfo `json:"net_info"`
|
|
MotherboardInfo MotherboardInfo `json:"motherboard_info"`
|
|
}
|
|
|
|
// HeartbeatRequest 心跳请求
|
|
type HeartbeatRequest struct {
|
|
HostInfo HostInfo `json:"host_info"` // 主机信息
|
|
Timestamp int64 `json:"timestamp"` // 时间戳
|
|
TOTPCode string `json:"totp_code"` // TOTP验证码
|
|
AppName string `json:"app_name"` // 应用名称
|
|
}
|
|
|
|
// HeartbeatResponse 心跳响应
|
|
type HeartbeatResponse struct {
|
|
Authorized bool `json:"authorized"` // 是否已授权
|
|
TOTPCode string `json:"totp_code"` // TOTP验证码
|
|
Timestamp int64 `json:"timestamp"` // 时间戳
|
|
SecondTOTPSecret string `json:"second_totp_secret"` // 第二级的totp密钥
|
|
}
|