feat: 机器新增支持加密方法等

This commit is contained in:
meilin.huang
2025-01-18 13:43:01 +08:00
parent 5a6e9d81a7
commit 30ea36a722
33 changed files with 208 additions and 148 deletions

View File

@@ -1,8 +1,13 @@
package form
import tagentity "mayfly-go/internal/tag/domain/entity"
import (
tagentity "mayfly-go/internal/tag/domain/entity"
"mayfly-go/pkg/model"
)
type MachineForm struct {
model.ExtraData
Id uint64 `json:"id"`
Protocol int `json:"protocol" binding:"required"`
Name string `json:"name" binding:"required"`

View File

@@ -7,6 +7,7 @@ import (
)
type MachineVO struct {
model.ExtraData
tagentity.ResourceTags // 标签信息
tagentity.AuthCerts // 授权凭证信息

View File

@@ -327,6 +327,7 @@ func (m *machineAppImpl) getMachineAndAuthCert(machineId uint64) (*entity.Machin
func (m *machineAppImpl) toMi(me *entity.Machine, authCert *tagentity.ResourceAuthCert) (*mcm.MachineInfo, error) {
mi := new(mcm.MachineInfo)
mi.ExtraData = me.ExtraData
mi.Id = me.Id
mi.Code = me.Code
mi.Name = me.Name

View File

@@ -6,6 +6,7 @@ import (
type Machine struct {
model.Model
model.ExtraData
Code string `json:"code"`
Name string `json:"name"`

View File

@@ -5,8 +5,10 @@ import (
tagentity "mayfly-go/internal/tag/domain/entity"
"mayfly-go/pkg/errorx"
"mayfly-go/pkg/logx"
"mayfly-go/pkg/model"
"mayfly-go/pkg/utils/netx"
"net"
"strings"
"time"
"golang.org/x/crypto/ssh"
@@ -14,6 +16,8 @@ import (
// 机器信息
type MachineInfo struct {
model.ExtraData
Key string `json:"key"` // 缓存key
Id uint64 `json:"id"`
Name string `json:"name"`
@@ -130,6 +134,13 @@ func GetSshClient(m *MachineInfo, jumpClient *ssh.Client) (*ssh.Client, error) {
},
Timeout: 5 * time.Second,
}
if ciphers := m.GetExtraString("ciphers"); ciphers != "" {
config.Ciphers = strings.Split(ciphers, ",")
}
if keyExchanges := m.GetExtraString("keyExchanges"); keyExchanges != "" {
config.KeyExchanges = strings.Split(keyExchanges, ",")
}
if m.AuthMethod == int8(tagentity.AuthCertCiphertextTypePassword) {
config.Auth = []ssh.AuthMethod{ssh.Password(m.Password)}
} else if m.AuthMethod == int8(tagentity.AuthCertCiphertextTypePrivateKey) {

View File

@@ -54,6 +54,7 @@ type ResourceManageVO struct {
Type int `json:"type"`
Status int `json:"status"`
Weight int `json:"weight"`
Meta string `json:"meta"`
Creator string `json:"creator"`
CreateTime *time.Time `json:"createTime"`
}

View File

@@ -26,8 +26,8 @@ func (m *roleResourceRepoImpl) GetRoleResourceIds(roleId uint64) []uint64 {
}
func (m *roleResourceRepoImpl) GetRoleResources(roleId uint64, toEntity any) {
sql := "select rr.creator AS creator, rr.create_time AS CreateTime, rr.resource_id AS id, r.pid AS pid, " +
"r.name AS name, r.type AS type, r.status AS status " +
sql := "SELECT rr.creator AS creator, rr.create_time AS CreateTime, rr.resource_id AS id, r.pid AS pid, " +
"r.name AS name, r.type AS type, r.status AS status, r.meta " +
"FROM t_sys_role_resource rr JOIN t_sys_resource r ON rr.resource_id = r.id " +
"WHERE rr.role_id = ? AND rr.is_deleted = 0 AND r.is_deleted = 0 " +
"ORDER BY r.pid ASC, r.weight ASC"