feat(rdp): 新增 RDP 远程桌面/SMB/账单同步能力 + 清理编译产物

主要变更:
- RDP 远程桌面:新增 backend/pkg/rdp(RDP 引擎 + credssp/display/rle/trace)、
  backend/controller/rdp*(连接/凭证/文件/会话/实时)、frontend RDP 组件与 API
- Windows SMB 文件传输:backend/pkg/winsmb
- 云账单同步:backend/pkg/billingsync + billing_sync/aliyun_billing,前端账单详情
- Agent CLI Kubernetes 工具:kubernetes_action/get、pod_execute/logs
- 服务器导入助手:server_import_helpers、ImportCredentialSettings
- 国际化与组件重构(cloud/deploy/monitor/server/system 等多模块)
- 清理编译产物二进制:移除 backend/server、backend/agent/bin/aiops-agent-*
- .gitignore:新增 backend/agent/ 与 .cache/(避免 334MB go-build 缓存误入库)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
LoganandClaude committed 2026-07-04 01:50:36 +08:00
1 parent 777d9e4e71
commit 76ec9387f0
202 files changed
+16555 -2543

No files matched your search

+7 -1
View File
@@ -9,9 +9,15 @@ import "time"
type AgentCLISession struct {
ID uint `gorm:"primarykey" json:"id"`
UserID uint `gorm:"index" json:"user_id"` // 发起用户
ServerID uint `gorm:"index" json:"server_id"` // 目标主机
Mode string `gorm:"size:16;default:host;index" json:"mode"` // host | kubernetes
ServerID uint `gorm:"index" json:"server_id"` // 主机模式目标主机
ServerName string `gorm:"size:128" json:"server_name"` // 主机名快照
ServerHost string `gorm:"size:64" json:"server_host"` // 主机 IP 快照
ClusterID uint `gorm:"index" json:"cluster_id"` // K8s 模式集群 ID
ClusterName string `gorm:"size:128" json:"cluster_name"` // 集群名快照
Namespace string `gorm:"size:128" json:"namespace"` // K8s 命名空间
PodName string `gorm:"size:128" json:"pod_name"` // 可选目标 Pod
Container string `gorm:"size:128" json:"container"` // 可选目标容器
Title string `gorm:"size:255" json:"title"` // 任务标题(query 截断)
Status string `gorm:"size:32;default:running" json:"status"` // running/done/aborted/error
Provider string `gorm:"size:50" json:"provider"` // LLM 提供商
+72 -53
View File
@@ -9,27 +9,29 @@ import (
// 核心加密字段 content 存储类型特有数据(JSON),API 不返回
//
// 类型与内容 JSON 映射:
// ssh → {"private_key":"...","public_key":"...","ssh_user":"...","ssh_port":22}
// docker → {"server":"...","username":"...","password":"..."}
// tls → {"cert":"...","key":"...","ca":"..."}
// aksk → {"provider":"...","access_key":"...","secret_key":"...","region":"..."}
// database → {"db_type":"...","host":"...","port":3306,"db_name":"...","username":"...","password":"..."}
// api → {"key":"...","endpoint":"..."}
// generic → {"key":"...","value":"..."}
//
// ssh → {"private_key":"...","public_key":"...","ssh_user":"...","ssh_port":22}
// rdp → {"username":"...","password":"...","domain":"...","security":"nla"}
// docker → {"server":"...","username":"...","password":"..."}
// tls → {"cert":"...","key":"...","ca":"..."}
// aksk → {"provider":"...","access_key":"...","secret_key":"...","region":"..."}
// database → {"db_type":"...","host":"...","port":3306,"db_name":"...","username":"...","password":"..."}
// api → {"key":"...","endpoint":"..."}
// generic → {"key":"...","value":"..."}
type Credential struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:128;not null" json:"name"` // 凭据名称
VariableName string `gorm:"size:64;index" json:"variable_name,omitempty"` // 环境变量别名 e.g. MYSQL_PROD
SecretType string `gorm:"size:32;not null;index" json:"secret_type"` // ssh/docker/tls/aksk/database/api/generic
Summary string `gorm:"size:255" json:"summary,omitempty"` // 关键信息摘要(脱敏展示)
Content string `gorm:"type:text;not null" json:"-"` // AES 加密后的 JSON,API 不返回
Tags string `gorm:"type:text" json:"tags,omitempty"` // JSON 数组: ["生产环境","阿里云"]
Description string `gorm:"size:500" json:"description,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"` // 过期时间
IsActive bool `gorm:"default:true" json:"is_active"` // 启用/禁用
EnvPrefix string `gorm:"size:32" json:"env_prefix,omitempty"` // 引用 ID(可复制)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:128;not null" json:"name"` // 凭据名称
VariableName string `gorm:"size:64;index" json:"variable_name,omitempty"` // 环境变量别名 e.g. MYSQL_PROD
SecretType string `gorm:"size:32;not null;index" json:"secret_type"` // ssh/rdp/docker/tls/aksk/database/api/generic
Summary string `gorm:"size:255" json:"summary,omitempty"` // 关键信息摘要(脱敏展示)
Content string `gorm:"type:text;not null" json:"-"` // AES 加密后的 JSON,API 不返回
Tags string `gorm:"type:text" json:"tags,omitempty"` // JSON 数组: ["生产环境","阿里云"]
Description string `gorm:"size:500" json:"description,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"` // 过期时间
IsActive bool `gorm:"default:true" json:"is_active"` // 启用/禁用
EnvPrefix string `gorm:"size:32" json:"env_prefix,omitempty"` // 引用 ID(可复制)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (Credential) TableName() string {
@@ -47,6 +49,14 @@ type SSHSecretContent struct {
Password string `json:"password,omitempty"`
}
// RDPSecretContent RDP 凭据 content,后端渲染模式下仅服务端解密使用 // Logan.Li
type RDPSecretContent struct {
Username string `json:"username"`
Password string `json:"password"`
Domain string `json:"domain,omitempty"`
Security string `json:"security,omitempty"`
}
// DockerSecretContent Docker 凭据 content
type DockerSecretContent struct {
Server string `json:"server"`
@@ -95,13 +105,13 @@ type GenericSecretContent struct {
// CreateSecretRequest 创建凭据请求
type CreateSecretRequest struct {
Name string `json:"name" binding:"required"`
VariableName string `json:"variable_name"`
SecretType string `json:"secret_type" binding:"required,oneof=ssh docker tls aksk database api generic"`
Tags []string `json:"tags"`
Description string `json:"description"`
Name string `json:"name" binding:"required"`
VariableName string `json:"variable_name"`
SecretType string `json:"secret_type" binding:"required,oneof=ssh rdp docker tls aksk database api generic"`
Tags []string `json:"tags"`
Description string `json:"description"`
ExpiresAt *time.Time `json:"expires_at"`
IsActive *bool `json:"is_active"`
IsActive *bool `json:"is_active"`
// 类型特有字段(明文,后端组装成 JSON 加密存储)
// SSH
@@ -110,6 +120,11 @@ type CreateSecretRequest struct {
SSHUser string `json:"ssh_user,omitempty"`
SSHPort int `json:"ssh_port,omitempty"`
SSHPassword string `json:"ssh_password,omitempty"`
// RDP
RDPUsername string `json:"rdp_username,omitempty"`
RDPPassword string `json:"rdp_password,omitempty"`
RDPDomain string `json:"rdp_domain,omitempty"`
RDPSecurity string `json:"rdp_security,omitempty"`
// Docker
DockerServer string `json:"docker_server,omitempty"`
DockerUsername string `json:"docker_username,omitempty"`
@@ -140,39 +155,43 @@ type CreateSecretRequest struct {
// UpdateSecretRequest 更新凭据请求
type UpdateSecretRequest struct {
Name *string `json:"name"`
VariableName *string `json:"variable_name"`
Tags []string `json:"tags"`
Description *string `json:"description"`
Name *string `json:"name"`
VariableName *string `json:"variable_name"`
Tags []string `json:"tags"`
Description *string `json:"description"`
ExpiresAt *time.Time `json:"expires_at"`
IsActive *bool `json:"is_active"`
IsActive *bool `json:"is_active"`
// 类型特有字段 — 传了才更新
SSHPrivateKey *string `json:"ssh_private_key,omitempty"`
SSHPublicKey *string `json:"ssh_public_key,omitempty"`
SSHUser *string `json:"ssh_user,omitempty"`
SSHPort *int `json:"ssh_port,omitempty"`
SSHPassword *string `json:"ssh_password,omitempty"`
SSHPrivateKey *string `json:"ssh_private_key,omitempty"`
SSHPublicKey *string `json:"ssh_public_key,omitempty"`
SSHUser *string `json:"ssh_user,omitempty"`
SSHPort *int `json:"ssh_port,omitempty"`
SSHPassword *string `json:"ssh_password,omitempty"`
RDPUsername *string `json:"rdp_username,omitempty"`
RDPPassword *string `json:"rdp_password,omitempty"`
RDPDomain *string `json:"rdp_domain,omitempty"`
RDPSecurity *string `json:"rdp_security,omitempty"`
DockerServer *string `json:"docker_server,omitempty"`
DockerUsername *string `json:"docker_username,omitempty"`
DockerPassword *string `json:"docker_password,omitempty"`
TLSCert *string `json:"tls_cert,omitempty"`
TLSKey *string `json:"tls_key,omitempty"`
TLSCA *string `json:"tls_ca,omitempty"`
AKSKProvider *string `json:"aksk_provider,omitempty"`
AKSKAccessKey *string `json:"aksk_access_key,omitempty"`
AKSKSecretKey *string `json:"aksk_secret_key,omitempty"`
AKSKRegion *string `json:"aksk_region,omitempty"`
DBType *string `json:"db_type,omitempty"`
DBHost *string `json:"db_host,omitempty"`
DBPort *int `json:"db_port,omitempty"`
DBName *string `json:"db_name,omitempty"`
DBUsername *string `json:"db_username,omitempty"`
DBPassword *string `json:"db_password,omitempty"`
APIKey *string `json:"api_key,omitempty"`
APIEndpoint *string `json:"api_endpoint,omitempty"`
GenericKey *string `json:"generic_key,omitempty"`
GenericValue *string `json:"generic_value,omitempty"`
TLSCert *string `json:"tls_cert,omitempty"`
TLSKey *string `json:"tls_key,omitempty"`
TLSCA *string `json:"tls_ca,omitempty"`
AKSKProvider *string `json:"aksk_provider,omitempty"`
AKSKAccessKey *string `json:"aksk_access_key,omitempty"`
AKSKSecretKey *string `json:"aksk_secret_key,omitempty"`
AKSKRegion *string `json:"aksk_region,omitempty"`
DBType *string `json:"db_type,omitempty"`
DBHost *string `json:"db_host,omitempty"`
DBPort *int `json:"db_port,omitempty"`
DBName *string `json:"db_name,omitempty"`
DBUsername *string `json:"db_username,omitempty"`
DBPassword *string `json:"db_password,omitempty"`
APIKey *string `json:"api_key,omitempty"`
APIEndpoint *string `json:"api_endpoint,omitempty"`
GenericKey *string `json:"generic_key,omitempty"`
GenericValue *string `json:"generic_value,omitempty"`
}
// SecretListResponse 列表返回(内容脱敏)
+42
View File
@@ -0,0 +1,42 @@
package model
import "time"
// RDPSession RDP 图形会话记录,独立于 SSH 终端审计表便于后续录屏扩展 // Logan.Li
type RDPSession struct {
ID uint `gorm:"primarykey" json:"id"`
UserID *uint `json:"user_id"`
Username string `gorm:"size:64" json:"username"`
ServerID uint `json:"server_id"`
ServerName string `gorm:"size:128" json:"server_name"`
ServerIP string `gorm:"size:64" json:"server_ip"`
ServerPort int `json:"server_port"`
ClientIP string `gorm:"size:64" json:"client_ip"`
Width int `gorm:"default:1280" json:"width"`
Height int `gorm:"default:800" json:"height"`
Status string `gorm:"size:32" json:"status"` // active, closed, failed // Logan.Li
Duration int `json:"duration"`
Error string `gorm:"size:500" json:"error,omitempty"`
RecordData string `gorm:"type:mediumtext" json:"-"` // 图形帧录制 JSON,回放接口单独返回 // Logan.Li
RecordSize int `json:"record_size"` // 录制字节数 // Logan.Li
StartTime time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time"`
CreatedAt time.Time `json:"created_at"`
}
func (RDPSession) TableName() string {
return "sys_rdp_sessions"
}
// RDPSessionQuery Windows RDP 图形会话查询 // Logan.Li
type RDPSessionQuery struct {
ServerID uint `form:"server_id"`
Username string `form:"username"`
Status string `form:"status"`
Keyword string `form:"keyword"`
StartDate string `form:"start_date"`
EndDate string `form:"end_date"`
HasRecord string `form:"has_record"`
Page int `form:"page,default=1"`
PageSize int `form:"page_size,default=20"`
}
+132 -119
View File
@@ -2,42 +2,44 @@ package model
import (
"time"
)
// Server 服务器模型
type Server struct {
ID uint `gorm:"primarykey" json:"id"`
Hostname string `gorm:"size:128;not null" json:"hostname"`
IP string `gorm:"size:64;not null" json:"ip"`
PublicIP string `gorm:"size:64" json:"public_ip"`
Port int `gorm:"default:22" json:"port"`
Username string `gorm:"size:64;default:root" json:"username"`
Password string `gorm:"size:255" json:"-"`
SSHKey string `gorm:"type:text" json:"-"`
AuthType string `gorm:"size:32;default:password" json:"auth_type"` // password, key
OS string `gorm:"size:64" json:"os"`
Kernel string `gorm:"size:64" json:"kernel"`
OSVersion string `gorm:"size:64" json:"os_version"`
Arch string `gorm:"size:32" json:"arch"`
CPU int `json:"cpu"`
Memory int64 `json:"memory"` // MB
Disk int64 `json:"disk"` // GB
Status string `gorm:"size:32;default:stopped" json:"status"` // running, stopped, maintenance, error
CPUUsage float64 `json:"cpu_usage"`
MemoryUsage float64 `json:"memory_usage"`
DiskUsage float64 `json:"disk_usage"`
Uptime int64 `json:"uptime"` // seconds
AgentVersion string `gorm:"size:32" json:"agent_version"`
AgentStatus string `gorm:"size:32;default:offline" json:"agent_status"` // online, offline
HasAuth bool `gorm:"-" json:"has_auth"` // 是否有认证凭据(密码或SSH密钥) — 不存DB,handler 计算后返回 // Logan.Li
RegionID *uint `json:"region_id"`
CloudID *uint `json:"cloud_id"`
Tags string `gorm:"type:text" json:"tags"` // JSON
Description string `gorm:"size:500" json:"description"`
LastCheckAt *time.Time `json:"last_check_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ID uint `gorm:"primarykey" json:"id"`
Hostname string `gorm:"size:128;not null" json:"hostname"`
IP string `gorm:"size:64;not null" json:"ip"`
PublicIP string `gorm:"size:64" json:"public_ip"`
Port int `gorm:"default:22" json:"port"`
Username string `gorm:"size:64;default:root" json:"username"`
Password string `gorm:"size:255" json:"-"`
SSHKey string `gorm:"type:text" json:"-"`
AuthType string `gorm:"size:32;default:password" json:"auth_type"` // password, key
OSType string `gorm:"size:32;default:linux" json:"os_type"` // 操作系统类型:linux/windows // Logan.Li
Protocol string `gorm:"size:32;default:ssh" json:"protocol"` // 远程协议:ssh/rdp // Logan.Li
RDPPort int `gorm:"default:3389" json:"rdp_port"` // Windows RDP 端口 // Logan.Li
OS string `gorm:"size:64" json:"os"`
Kernel string `gorm:"size:64" json:"kernel"`
OSVersion string `gorm:"size:64" json:"os_version"`
Arch string `gorm:"size:32" json:"arch"`
CPU int `json:"cpu"`
Memory int64 `json:"memory"` // MB
Disk int64 `json:"disk"` // GB
Status string `gorm:"size:32;default:stopped" json:"status"` // running, stopped, maintenance, error
CPUUsage float64 `json:"cpu_usage"`
MemoryUsage float64 `json:"memory_usage"`
DiskUsage float64 `json:"disk_usage"`
Uptime int64 `json:"uptime"` // seconds
AgentVersion string `gorm:"size:32" json:"agent_version"`
AgentStatus string `gorm:"size:32;default:offline" json:"agent_status"` // online, offline
HasAuth bool `gorm:"-" json:"has_auth"` // 是否有认证凭据(密码或SSH密钥) — 不存DB,handler 计算后返回 // Logan.Li
RegionID *uint `json:"region_id"`
CloudID *uint `json:"cloud_id"`
Tags string `gorm:"type:text" json:"tags"` // JSON
Description string `gorm:"size:500" json:"description"`
LastCheckAt *time.Time `json:"last_check_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// 关联
Region *Region `json:"region,omitempty"`
@@ -51,15 +53,15 @@ func (Server) TableName() string {
// Cloud 云平台模型
type Cloud struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:64;not null" json:"name"`
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
Type string `gorm:"size:32;default:public" json:"type"` // public, private, hybrid
Status string `gorm:"size:32;default:active" json:"status"`
Website string `gorm:"size:255" json:"website"`
Description string `gorm:"size:500" json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:64;not null" json:"name"`
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
Type string `gorm:"size:32;default:public" json:"type"` // public, private, hybrid
Status string `gorm:"size:32;default:active" json:"status"`
Website string `gorm:"size:255" json:"website"`
Description string `gorm:"size:500" json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 表名
@@ -69,18 +71,18 @@ func (Cloud) TableName() string {
// CloudAccount 云账号模型
type CloudAccount struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:128;not null" json:"name"`
Provider string `gorm:"size:64;not null" json:"provider"` // aws, aliyun, tencent, huawei, azure
AccessKey string `gorm:"size:255;not null" json:"-"`
SecretKey string `gorm:"size:255;not null" json:"-"`
Status string `gorm:"size:32;default:active" json:"status"` // active, inactive, error
RegionCount int `gorm:"default:0" json:"region_count"`
ServerCount int `gorm:"default:0" json:"server_count"`
MonthlyCost float64 `gorm:"default:0" json:"monthly_cost"` // 月费用(元),驱动仪表盘成本统计
LastSyncAt *time.Time `json:"last_sync_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:128;not null" json:"name"`
Provider string `gorm:"size:64;not null" json:"provider"` // aws, aliyun, tencent, huawei, azure
AccessKey string `gorm:"size:255;not null" json:"-"`
SecretKey string `gorm:"size:255;not null" json:"-"`
Status string `gorm:"size:32;default:active" json:"status"` // active, inactive, error
RegionCount int `gorm:"default:0" json:"region_count"`
ServerCount int `gorm:"default:0" json:"server_count"`
MonthlyCost float64 `gorm:"default:0" json:"monthly_cost"` // 月费用(元),驱动仪表盘成本统计
LastSyncAt *time.Time `json:"last_sync_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 表名
@@ -90,16 +92,16 @@ func (CloudAccount) TableName() string {
// Region 区域模型
type Region struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:64;not null" json:"name"`
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
Provider string `gorm:"size:64;not null" json:"provider"`
Location string `gorm:"size:128" json:"location"`
Status string `gorm:"size:32;default:active" json:"status"`
Endpoint string `gorm:"size:255" json:"endpoint"`
VPCCount int `gorm:"default:0" json:"vpc_count"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:64;not null" json:"name"`
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
Provider string `gorm:"size:64;not null" json:"provider"`
Location string `gorm:"size:128" json:"location"`
Status string `gorm:"size:32;default:active" json:"status"`
Endpoint string `gorm:"size:255" json:"endpoint"`
VPCCount int `gorm:"default:0" json:"vpc_count"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 表名
@@ -109,17 +111,17 @@ func (Region) TableName() string {
// Domain 域名模型
type Domain struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;uniqueIndex;not null" json:"name"`
Registrar string `gorm:"size:128" json:"registrar"`
Status string `gorm:"size:32;default:active" json:"status"` // active, expired, pending
ExpireDate *time.Time `json:"expire_date"`
DNSProvider string `gorm:"size:128" json:"dns_provider"`
RecordCount int `gorm:"default:0" json:"record_count"`
SSLEnabled bool `gorm:"default:false" json:"ssl_enabled"`
SSLExpireDate *time.Time `json:"ssl_expire_date"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;uniqueIndex;not null" json:"name"`
Registrar string `gorm:"size:128" json:"registrar"`
Status string `gorm:"size:32;default:active" json:"status"` // active, expired, pending
ExpireDate *time.Time `json:"expire_date"`
DNSProvider string `gorm:"size:128" json:"dns_provider"`
RecordCount int `gorm:"default:0" json:"record_count"`
SSLEnabled bool `gorm:"default:false" json:"ssl_enabled"`
SSLExpireDate *time.Time `json:"ssl_expire_date"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 表名
@@ -129,46 +131,52 @@ func (Domain) TableName() string {
// CreateServerRequest 创建服务器请求
type CreateServerRequest struct {
Hostname string `json:"hostname" binding:"required"`
IP string `json:"ip" binding:"required,ip"`
PublicIP string `json:"public_ip" binding:"omitempty,ip"`
Port int `json:"port" binding:"omitempty,min=1,max=65535"`
Username string `json:"username"`
Password string `json:"password"`
SSHKey string `json:"ssh_key"`
AuthType string `json:"auth_type" binding:"omitempty,oneof=password key"`
CredentialID *uint `json:"credential_id,omitempty"` // 关联 SSH 凭证,非空则后端解密覆盖认证字段
OS string `json:"os"`
CPU int `json:"cpu"`
Memory int64 `json:"memory"`
Disk int64 `json:"disk"`
Status string `json:"status" binding:"omitempty,oneof=running stopped maintenance error"`
RegionID *uint `json:"region_id"`
CloudID *uint `json:"cloud_id"`
Tags string `json:"tags"`
Description string `json:"description"`
Hostname string `json:"hostname" binding:"required"`
IP string `json:"ip" binding:"required,ip"`
PublicIP string `json:"public_ip" binding:"omitempty,ip"`
Port int `json:"port" binding:"omitempty,min=1,max=65535"`
Username string `json:"username"`
Password string `json:"password"`
SSHKey string `json:"ssh_key"`
AuthType string `json:"auth_type" binding:"omitempty,oneof=password key"`
CredentialID *uint `json:"credential_id,omitempty"` // 关联 SSH 凭证,非空则后端解密覆盖认证字段
OSType string `json:"os_type" binding:"omitempty,oneof=linux windows"` // 操作系统类型 // Logan.Li
Protocol string `json:"protocol" binding:"omitempty,oneof=ssh rdp"` // 远程协议 // Logan.Li
RDPPort int `json:"rdp_port" binding:"omitempty,min=1,max=65535"` // RDP 端口 // Logan.Li
OS string `json:"os"`
CPU int `json:"cpu"`
Memory int64 `json:"memory"`
Disk int64 `json:"disk"`
Status string `json:"status" binding:"omitempty,oneof=running stopped maintenance error"`
RegionID *uint `json:"region_id"`
CloudID *uint `json:"cloud_id"`
Tags string `json:"tags"`
Description string `json:"description"`
}
// UpdateServerRequest 更新服务器请求
type UpdateServerRequest struct {
Hostname string `json:"hostname"`
IP string `json:"ip" binding:"omitempty,ip"`
PublicIP string `json:"public_ip" binding:"omitempty,ip"`
Port int `json:"port" binding:"omitempty,min=1,max=65535"`
Username string `json:"username"`
Password string `json:"password"`
SSHKey string `json:"ssh_key"`
AuthType string `json:"auth_type" binding:"omitempty,oneof=password key"`
CredentialID *uint `json:"credential_id,omitempty"` // 关联 SSH 凭证,非空则后端解密覆盖认证字段
OS string `json:"os"`
CPU int `json:"cpu"`
Memory int64 `json:"memory"`
Disk int64 `json:"disk"`
Status string `json:"status" binding:"omitempty,oneof=running stopped maintenance error"`
RegionID *uint `json:"region_id"`
CloudID *uint `json:"cloud_id"`
Tags string `json:"tags"`
Description string `json:"description"`
Hostname string `json:"hostname"`
IP string `json:"ip" binding:"omitempty,ip"`
PublicIP string `json:"public_ip" binding:"omitempty,ip"`
Port int `json:"port" binding:"omitempty,min=1,max=65535"`
Username string `json:"username"`
Password string `json:"password"`
SSHKey string `json:"ssh_key"`
AuthType string `json:"auth_type" binding:"omitempty,oneof=password key"`
CredentialID *uint `json:"credential_id,omitempty"` // 关联 SSH 凭证,非空则后端解密覆盖认证字段
OSType string `json:"os_type" binding:"omitempty,oneof=linux windows"` // 操作系统类型 // Logan.Li
Protocol string `json:"protocol" binding:"omitempty,oneof=ssh rdp"` // 远程协议 // Logan.Li
RDPPort int `json:"rdp_port" binding:"omitempty,min=1,max=65535"` // RDP 端口 // Logan.Li
OS string `json:"os"`
CPU int `json:"cpu"`
Memory int64 `json:"memory"`
Disk int64 `json:"disk"`
Status string `json:"status" binding:"omitempty,oneof=running stopped maintenance error"`
RegionID *uint `json:"region_id"`
CloudID *uint `json:"cloud_id"`
Tags string `json:"tags"`
Description string `json:"description"`
}
// BatchServerItem 批量导入单条服务器 // Logan.Li
@@ -177,6 +185,9 @@ type BatchServerItem struct {
IP string `json:"ip"`
Port int `json:"port"`
Username string `json:"username"`
OSType string `json:"os_type"` // linux/windows // Logan.Li
Protocol string `json:"protocol"` // ssh/rdp // Logan.Li
RDPPort int `json:"rdp_port"` // Windows RDP 端口 // Logan.Li
OS string `json:"os"`
CPU int `json:"cpu"`
Memory int64 `json:"memory"` // GB(后端转 MB 存储)
@@ -186,10 +197,12 @@ type BatchServerItem struct {
// BatchCreateServerRequest 批量导入服务器请求 // Logan.Li
type BatchCreateServerRequest struct {
Servers []BatchServerItem `json:"servers"`
RegionID *uint `json:"region_id"`
AuthType string `json:"auth_type"`
CredentialID *uint `json:"credential_id"` // 凭据ID,非空则解密后写入每台服务器
Servers []BatchServerItem `json:"servers"`
RegionID *uint `json:"region_id"`
AuthType string `json:"auth_type"`
CredentialID *uint `json:"credential_id"` // 兼容旧字段:默认 SSH 凭据 // Logan.Li
SSHCredentialID *uint `json:"ssh_credential_id"` // Linux 默认 SSH 凭据 // Logan.Li
RDPCredentialID *uint `json:"rdp_credential_id"` // Windows 默认 RDP 凭据 // Logan.Li
}
// BatchCreateResult 批量导入结果 // Logan.Li
@@ -217,9 +230,9 @@ type ServerStats struct {
AvgMemory float64 `json:"avg_memory"`
AvgDisk float64 `json:"avg_disk"`
// 总资源概览(GB/核),用于仪表盘资源使用率卡片展示具体容量 // Logan.Li
TotalCPU int64 `json:"total_cpu"` // CPU 核心数合计
TotalMemory int64 `json:"total_memory"` // 内存总量 GB
UsedMemory int64 `json:"used_memory"` // 内存已用 GB
TotalDisk int64 `json:"total_disk"` // 磁盘总量 GB
UsedDisk int64 `json:"used_disk"` // 磁盘已用 GB
TotalCPU int64 `json:"total_cpu"` // CPU 核心数合计
TotalMemory int64 `json:"total_memory"` // 内存总量 GB
UsedMemory int64 `json:"used_memory"` // 内存已用 GB
TotalDisk int64 `json:"total_disk"` // 磁盘总量 GB
UsedDisk int64 `json:"used_disk"` // 磁盘已用 GB
}
+11 -10
View File
@@ -4,16 +4,17 @@ import "time"
// SessionCommand 会话命令记录(JumpServer 式命令审计) // Logan.Li
type SessionCommand struct {
ID uint `gorm:"primarykey" json:"id"`
SessionID uint `gorm:"index" json:"session_id"` // 关联终端会话
UserID *uint `json:"user_id"`
Username string `gorm:"size:64" json:"username"`
ServerID uint `json:"server_id"`
ServerName string `gorm:"size:128" json:"server_name"`
Command string `gorm:"type:text" json:"command"` // 执行的原始命令
OutputSize *int `json:"output_size"` // 下一条命令前累计的终端输出字节数,nil=历史未统计 // Logan.Li
Timestamp time.Time `json:"timestamp"` // 命令执行时间
CreatedAt time.Time `json:"created_at"`
ID uint `gorm:"primarykey" json:"id"`
SessionID uint `gorm:"index" json:"session_id"` // 关联终端会话
SessionType string `gorm:"size:32;default:terminal" json:"session_type"` // terminal/rdp,用于区分回放入口 // Logan.Li
UserID *uint `json:"user_id"`
Username string `gorm:"size:64" json:"username"`
ServerID uint `json:"server_id"`
ServerName string `gorm:"size:128" json:"server_name"`
Command string `gorm:"type:text" json:"command"` // 执行的原始命令
OutputSize *int `json:"output_size"` // 下一条命令前累计的终端输出字节数,nil=历史未统计 // Logan.Li
Timestamp time.Time `json:"timestamp"` // 命令执行时间
CreatedAt time.Time `json:"created_at"`
}
func (SessionCommand) TableName() string {