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:
1 parent
777d9e4e71
commit
76ec9387f0
202 files changed
+16555
-2543
No files matched your search
@@ -46,6 +46,25 @@ func buildContent(req model.CreateSecretRequest) (string, string, error) {
|
||||
}
|
||||
b, _ := json.Marshal(data)
|
||||
return string(b), fmt.Sprintf("SSH %s@%d", req.SSHUser, req.SSHPort), nil
|
||||
case "rdp":
|
||||
if strings.TrimSpace(req.RDPUsername) == "" {
|
||||
return "", "", fmt.Errorf("RDP 用户不能为空")
|
||||
}
|
||||
if strings.TrimSpace(req.RDPPassword) == "" {
|
||||
return "", "", fmt.Errorf("RDP 密码不能为空")
|
||||
}
|
||||
security := req.RDPSecurity
|
||||
if security == "" {
|
||||
security = "nla"
|
||||
}
|
||||
data := map[string]string{
|
||||
"username": strings.TrimSpace(req.RDPUsername),
|
||||
"password": req.RDPPassword,
|
||||
"domain": strings.TrimSpace(req.RDPDomain),
|
||||
"security": security,
|
||||
}
|
||||
b, _ := json.Marshal(data)
|
||||
return string(b), rdpSummary(req.RDPUsername, req.RDPDomain, security), nil
|
||||
case "docker":
|
||||
data := map[string]string{
|
||||
"server": req.DockerServer,
|
||||
@@ -90,6 +109,20 @@ func buildContent(req model.CreateSecretRequest) (string, string, error) {
|
||||
return "{}", "", fmt.Errorf("unknown type: %s", req.SecretType)
|
||||
}
|
||||
|
||||
func rdpSummary(username, domain, security string) string {
|
||||
username = strings.TrimSpace(username)
|
||||
domain = strings.TrimSpace(domain)
|
||||
security = strings.TrimSpace(security)
|
||||
if security == "" || security == "<nil>" {
|
||||
security = "nla"
|
||||
}
|
||||
account := username
|
||||
if domain != "" && domain != "<nil>" {
|
||||
account = username + "@" + domain
|
||||
}
|
||||
return fmt.Sprintf("Windows RDP %s / %s", account, strings.ToUpper(security))
|
||||
}
|
||||
|
||||
// ────── List ──────
|
||||
|
||||
func (h *CredentialHandler) ListCredentials(c *gin.Context) {
|
||||
@@ -117,9 +150,13 @@ func (h *CredentialHandler) ListCredentials(c *gin.Context) {
|
||||
db.Count(&total)
|
||||
|
||||
page := query.Page
|
||||
if page < 1 { page = 1 }
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
pageSize := query.PageSize
|
||||
if pageSize < 1 || pageSize > 100 { pageSize = 20 }
|
||||
if pageSize < 1 || pageSize > 100 {
|
||||
pageSize = 20
|
||||
}
|
||||
|
||||
var creds []model.Credential
|
||||
db.Order("updated_at DESC").Offset((page - 1) * pageSize).Limit(pageSize).Find(&creds)
|
||||
@@ -175,7 +212,9 @@ func (h *CredentialHandler) CreateCredential(c *gin.Context) {
|
||||
tagsJSON, _ := json.Marshal(req.Tags)
|
||||
|
||||
isActive := true
|
||||
if req.IsActive != nil { isActive = *req.IsActive }
|
||||
if req.IsActive != nil {
|
||||
isActive = *req.IsActive
|
||||
}
|
||||
|
||||
cred := model.Credential{
|
||||
Name: req.Name,
|
||||
@@ -219,7 +258,9 @@ func (h *CredentialHandler) GetCredential(c *gin.Context) {
|
||||
json.Unmarshal([]byte(plain), &contentData)
|
||||
|
||||
tags := []string{}
|
||||
if cred.Tags != "" { json.Unmarshal([]byte(cred.Tags), &tags) }
|
||||
if cred.Tags != "" {
|
||||
json.Unmarshal([]byte(cred.Tags), &tags)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, model.Response{Code: 200, Data: gin.H{
|
||||
"id": cred.ID,
|
||||
@@ -255,11 +296,21 @@ func (h *CredentialHandler) UpdateCredential(c *gin.Context) {
|
||||
|
||||
updates := map[string]interface{}{}
|
||||
|
||||
if req.Name != nil { updates["name"] = *req.Name }
|
||||
if req.VariableName != nil { updates["variable_name"] = *req.VariableName }
|
||||
if req.Description != nil { updates["description"] = *req.Description }
|
||||
if req.ExpiresAt != nil { updates["expires_at"] = req.ExpiresAt }
|
||||
if req.IsActive != nil { updates["is_active"] = *req.IsActive }
|
||||
if req.Name != nil {
|
||||
updates["name"] = *req.Name
|
||||
}
|
||||
if req.VariableName != nil {
|
||||
updates["variable_name"] = *req.VariableName
|
||||
}
|
||||
if req.Description != nil {
|
||||
updates["description"] = *req.Description
|
||||
}
|
||||
if req.ExpiresAt != nil {
|
||||
updates["expires_at"] = req.ExpiresAt
|
||||
}
|
||||
if req.IsActive != nil {
|
||||
updates["is_active"] = *req.IsActive
|
||||
}
|
||||
|
||||
if len(req.Tags) > 0 {
|
||||
b, _ := json.Marshal(req.Tags)
|
||||
@@ -272,7 +323,9 @@ func (h *CredentialHandler) UpdateCredential(c *gin.Context) {
|
||||
oldPlain, _ := h.crypt.Decrypt(cred.Content)
|
||||
var old map[string]interface{}
|
||||
json.Unmarshal([]byte(oldPlain), &old)
|
||||
if old == nil { old = map[string]interface{}{} }
|
||||
if old == nil {
|
||||
old = map[string]interface{}{}
|
||||
}
|
||||
|
||||
mergeUpdate(req, old)
|
||||
|
||||
@@ -297,6 +350,7 @@ func (h *CredentialHandler) UpdateCredential(c *gin.Context) {
|
||||
|
||||
func hasTypeFieldUpdate(req model.UpdateSecretRequest) bool {
|
||||
return req.SSHPrivateKey != nil || req.SSHPublicKey != nil || req.SSHUser != nil || req.SSHPort != nil || req.SSHPassword != nil ||
|
||||
req.RDPUsername != nil || req.RDPPassword != nil || req.RDPDomain != nil || req.RDPSecurity != nil ||
|
||||
req.DockerServer != nil || req.DockerUsername != nil || req.DockerPassword != nil ||
|
||||
req.TLSCert != nil || req.TLSKey != nil || req.TLSCA != nil ||
|
||||
req.AKSKProvider != nil || req.AKSKAccessKey != nil || req.AKSKSecretKey != nil || req.AKSKRegion != nil ||
|
||||
@@ -306,37 +360,105 @@ func hasTypeFieldUpdate(req model.UpdateSecretRequest) bool {
|
||||
}
|
||||
|
||||
func mergeUpdate(req model.UpdateSecretRequest, old map[string]interface{}) {
|
||||
if req.SSHPrivateKey != nil { old["private_key"] = *req.SSHPrivateKey }
|
||||
if req.SSHPublicKey != nil { old["public_key"] = *req.SSHPublicKey }
|
||||
if req.SSHUser != nil { old["ssh_user"] = *req.SSHUser }
|
||||
if req.SSHPort != nil { old["ssh_port"] = *req.SSHPort }
|
||||
if req.SSHPassword != nil { old["password"] = *req.SSHPassword }
|
||||
if req.DockerServer != nil { old["server"] = *req.DockerServer }
|
||||
if req.DockerUsername != nil { old["username"] = *req.DockerUsername }
|
||||
if req.DockerPassword != nil { old["password"] = *req.DockerPassword }
|
||||
if req.TLSCert != nil { old["cert"] = *req.TLSCert }
|
||||
if req.TLSKey != nil { old["key"] = *req.TLSKey }
|
||||
if req.TLSCA != nil { old["ca"] = *req.TLSCA }
|
||||
if req.AKSKProvider != nil { old["provider"] = *req.AKSKProvider }
|
||||
if req.AKSKAccessKey != nil { old["access_key"] = *req.AKSKAccessKey }
|
||||
if req.AKSKSecretKey != nil { old["secret_key"] = *req.AKSKSecretKey }
|
||||
if req.AKSKRegion != nil { old["region"] = *req.AKSKRegion }
|
||||
if req.DBType != nil { old["db_type"] = *req.DBType }
|
||||
if req.DBHost != nil { old["host"] = *req.DBHost }
|
||||
if req.DBPort != nil { old["port"] = *req.DBPort }
|
||||
if req.DBName != nil { old["db_name"] = *req.DBName }
|
||||
if req.DBUsername != nil { old["username"] = *req.DBUsername }
|
||||
if req.DBPassword != nil { old["password"] = *req.DBPassword }
|
||||
if req.APIKey != nil { old["api_key"] = *req.APIKey }
|
||||
if req.APIEndpoint != nil { old["endpoint"] = *req.APIEndpoint }
|
||||
if req.GenericKey != nil { old["generic_key"] = *req.GenericKey }
|
||||
if req.GenericValue != nil { old["generic_value"] = *req.GenericValue }
|
||||
if req.SSHPrivateKey != nil {
|
||||
old["private_key"] = *req.SSHPrivateKey
|
||||
}
|
||||
if req.SSHPublicKey != nil {
|
||||
old["public_key"] = *req.SSHPublicKey
|
||||
}
|
||||
if req.SSHUser != nil {
|
||||
old["ssh_user"] = *req.SSHUser
|
||||
}
|
||||
if req.SSHPort != nil {
|
||||
old["ssh_port"] = *req.SSHPort
|
||||
}
|
||||
if req.SSHPassword != nil {
|
||||
old["password"] = *req.SSHPassword
|
||||
}
|
||||
if req.RDPUsername != nil {
|
||||
old["username"] = *req.RDPUsername
|
||||
}
|
||||
if req.RDPPassword != nil {
|
||||
old["password"] = *req.RDPPassword
|
||||
}
|
||||
if req.RDPDomain != nil {
|
||||
old["domain"] = *req.RDPDomain
|
||||
}
|
||||
if req.RDPSecurity != nil {
|
||||
security := strings.TrimSpace(*req.RDPSecurity)
|
||||
if security == "" {
|
||||
security = "nla"
|
||||
}
|
||||
old["security"] = security
|
||||
}
|
||||
if req.DockerServer != nil {
|
||||
old["server"] = *req.DockerServer
|
||||
}
|
||||
if req.DockerUsername != nil {
|
||||
old["username"] = *req.DockerUsername
|
||||
}
|
||||
if req.DockerPassword != nil {
|
||||
old["password"] = *req.DockerPassword
|
||||
}
|
||||
if req.TLSCert != nil {
|
||||
old["cert"] = *req.TLSCert
|
||||
}
|
||||
if req.TLSKey != nil {
|
||||
old["key"] = *req.TLSKey
|
||||
}
|
||||
if req.TLSCA != nil {
|
||||
old["ca"] = *req.TLSCA
|
||||
}
|
||||
if req.AKSKProvider != nil {
|
||||
old["provider"] = *req.AKSKProvider
|
||||
}
|
||||
if req.AKSKAccessKey != nil {
|
||||
old["access_key"] = *req.AKSKAccessKey
|
||||
}
|
||||
if req.AKSKSecretKey != nil {
|
||||
old["secret_key"] = *req.AKSKSecretKey
|
||||
}
|
||||
if req.AKSKRegion != nil {
|
||||
old["region"] = *req.AKSKRegion
|
||||
}
|
||||
if req.DBType != nil {
|
||||
old["db_type"] = *req.DBType
|
||||
}
|
||||
if req.DBHost != nil {
|
||||
old["host"] = *req.DBHost
|
||||
}
|
||||
if req.DBPort != nil {
|
||||
old["port"] = *req.DBPort
|
||||
}
|
||||
if req.DBName != nil {
|
||||
old["db_name"] = *req.DBName
|
||||
}
|
||||
if req.DBUsername != nil {
|
||||
old["username"] = *req.DBUsername
|
||||
}
|
||||
if req.DBPassword != nil {
|
||||
old["password"] = *req.DBPassword
|
||||
}
|
||||
if req.APIKey != nil {
|
||||
old["api_key"] = *req.APIKey
|
||||
}
|
||||
if req.APIEndpoint != nil {
|
||||
old["endpoint"] = *req.APIEndpoint
|
||||
}
|
||||
if req.GenericKey != nil {
|
||||
old["generic_key"] = *req.GenericKey
|
||||
}
|
||||
if req.GenericValue != nil {
|
||||
old["generic_value"] = *req.GenericValue
|
||||
}
|
||||
}
|
||||
|
||||
func buildSummaryFromRaw(data map[string]interface{}, stype string) string {
|
||||
switch stype {
|
||||
case "ssh":
|
||||
return fmt.Sprintf("SSH %v@%v", data["ssh_user"], data["ssh_port"])
|
||||
case "rdp":
|
||||
return rdpSummary(fmt.Sprint(data["username"]), fmt.Sprint(data["domain"]), fmt.Sprint(data["security"]))
|
||||
case "docker":
|
||||
return fmt.Sprintf("%v", data["server"])
|
||||
case "aksk":
|
||||
@@ -391,10 +513,14 @@ func (h *CredentialHandler) GetTags(c *gin.Context) {
|
||||
for _, r := range rows {
|
||||
var tags []string
|
||||
if json.Unmarshal([]byte(r), &tags) == nil {
|
||||
for _, t := range tags { tagSet[t] = true }
|
||||
for _, t := range tags {
|
||||
tagSet[t] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
tags := make([]string, 0, len(tagSet))
|
||||
for t := range tagSet { tags = append(tags, t) }
|
||||
for t := range tagSet {
|
||||
tags = append(tags, t)
|
||||
}
|
||||
c.JSON(http.StatusOK, model.Response{Code: 200, Data: tags})
|
||||
}
|
||||
Reference in new issue
Block a user