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

+39 -23
View File
@@ -13,8 +13,7 @@ import (
// 批量操作域:批量导入 + 批量删除 // Logan.Li
// BatchCreateServers 批量导入服务器 // Logan.Li
// 接收 {servers:[...], region_id, auth_type, credential_id},逐条校验并创建,跳过重复(主机名或IP已存在)
// BatchCreateServers 批量导入服务器,Linux 默认 SSH 凭据,Windows 默认 RDP 凭据 // Logan.Li
func (h *ServerHandler) BatchCreateServers(c *gin.Context) {
var req model.BatchCreateServerRequest
if err := c.ShouldBindJSON(&req); err != nil {
@@ -30,24 +29,19 @@ func (h *ServerHandler) BatchCreateServers(c *gin.Context) {
authType = "password"
}
// 如果指定了凭据,提前解密(plain 在循环内由 applyCredential 解析填充) // Logan.Li
var (
hasCred bool
cred model.Credential
credPlain string
)
if req.CredentialID != nil && *req.CredentialID > 0 {
if err := h.db.First(&cred, *req.CredentialID).Error; err != nil {
c.JSON(http.StatusBadRequest, model.Response{Code: 400, Message: "凭据不存在"})
return
}
p, err := h.crypt.Decrypt(cred.Content)
if err != nil {
c.JSON(http.StatusInternalServerError, model.Response{Code: 500, Message: "凭据解密失败"})
return
}
credPlain = p
hasCred = true
sshCredentialID := req.SSHCredentialID
if sshCredentialID == nil {
sshCredentialID = req.CredentialID
}
sshCred, sshPlain, hasSSHCred, err := h.loadImportCredential(sshCredentialID, "ssh")
if err != nil {
c.JSON(http.StatusBadRequest, model.Response{Code: 400, Message: err.Error()})
return
}
rdpCred, rdpPlain, hasRDPCred, err := h.loadImportCredential(req.RDPCredentialID, "rdp")
if err != nil {
c.JSON(http.StatusBadRequest, model.Response{Code: 400, Message: err.Error()})
return
}
result := model.BatchCreateResult{Errors: []string{}}
@@ -68,13 +62,30 @@ func (h *ServerHandler) BatchCreateServers(c *gin.Context) {
continue
}
osType := normalizeImportOSType(item.OSType, item.OS)
protocol := strings.TrimSpace(strings.ToLower(item.Protocol))
if protocol == "" {
if osType == "windows" {
protocol = "rdp"
} else {
protocol = "ssh"
}
}
port := item.Port
if port == 0 {
port = 22
}
rdpPort := item.RDPPort
if rdpPort == 0 {
rdpPort = 3389
}
username := strings.TrimSpace(item.Username)
if username == "" {
username = "root"
if protocol == "rdp" {
username = "Administrator"
} else {
username = "root"
}
}
server := model.Server{
@@ -83,6 +94,9 @@ func (h *ServerHandler) BatchCreateServers(c *gin.Context) {
Port: port,
Username: username,
AuthType: authType, // 无凭证时用请求 authType(默认 password)
OSType: osType,
Protocol: protocol,
RDPPort: rdpPort,
OS: item.OS,
CPU: item.CPU,
Memory: item.Memory * 1024, // GB → MB
@@ -91,8 +105,10 @@ func (h *ServerHandler) BatchCreateServers(c *gin.Context) {
RegionID: req.RegionID,
Status: "stopped",
}
if hasCred {
applyCredential(cred, credPlain, &server) // 有凭证则覆盖认证字段(ssh→私钥/ssh_user/ssh_port) // Logan.Li
if protocol == "rdp" && hasRDPCred {
applyCredential(rdpCred, rdpPlain, &server)
} else if protocol != "rdp" && hasSSHCred {
applyCredential(sshCred, sshPlain, &server)
}
if err := h.db.Create(&server).Error; err != nil {
result.Failed++