mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 00:10:25 +08:00 
			
		
		
		
	feat: 新增机器授权凭证管理与其他优化
This commit is contained in:
		@@ -1,7 +1,6 @@
 | 
			
		||||
package entity
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"mayfly-go/internal/common/utils"
 | 
			
		||||
	"mayfly-go/pkg/model"
 | 
			
		||||
)
 | 
			
		||||
@@ -11,24 +10,21 @@ type Machine struct {
 | 
			
		||||
 | 
			
		||||
	Name               string `json:"name"`
 | 
			
		||||
	Ip                 string `json:"ip"`         // IP地址
 | 
			
		||||
	Port               int    `json:"port"`       // 端口号
 | 
			
		||||
	Username           string `json:"username"`   // 用户名
 | 
			
		||||
	AuthMethod         int8   `json:"authMethod"` // 授权认证方式
 | 
			
		||||
	Password           string `json:"-"`
 | 
			
		||||
	Port               int    `json:"port"`               // 端口号
 | 
			
		||||
	Password           string `json:"password"`   // 密码
 | 
			
		||||
	AuthCertId         int    `json:"authCertId"` // 授权凭证id
 | 
			
		||||
	TagId              uint64
 | 
			
		||||
	TagPath            string
 | 
			
		||||
	Status             int8   `json:"status"`             // 状态 1:启用;2:停用
 | 
			
		||||
	Remark             string `json:"remark"`             // 备注
 | 
			
		||||
	EnableSshTunnel    int8   `json:"enableSshTunnel"`    // 是否启用ssh隧道
 | 
			
		||||
	SshTunnelMachineId uint64 `json:"sshTunnelMachineId"` // ssh隧道机器id
 | 
			
		||||
	SshTunnelMachineId int    `json:"sshTunnelMachineId"` // ssh隧道机器id
 | 
			
		||||
	EnableRecorder     int8   `json:"enableRecorder"`     // 是否启用终端回放记录
 | 
			
		||||
	TagId              uint64 `json:"tagId"`
 | 
			
		||||
	TagPath            string `json:"tagPath"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	MachineStatusEnable        int8 = 1  // 启用状态
 | 
			
		||||
	MachineStatusDisable       int8 = -1 // 禁用状态
 | 
			
		||||
	MachineAuthMethodPassword  int8 = 1  // 密码登录
 | 
			
		||||
	MachineAuthMethodPublicKey int8 = 2  // 公钥免密登录
 | 
			
		||||
	MachineStatusEnable  int8 = 1  // 启用状态
 | 
			
		||||
	MachineStatusDisable int8 = -1 // 禁用状态
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (m *Machine) PwdEncrypt() {
 | 
			
		||||
@@ -41,7 +37,6 @@ func (m *Machine) PwdDecrypt() {
 | 
			
		||||
	m.Password = utils.PwdAesDecrypt(m.Password)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 获取记录日志的描述
 | 
			
		||||
func (m *Machine) GetLogDesc() string {
 | 
			
		||||
	return fmt.Sprintf("Machine[id=%d, tag=%s, name=%s, ip=%s:%d]", m.Id, m.TagPath, m.Name, m.Ip, m.Port)
 | 
			
		||||
func (m *Machine) UseAuthCert() bool {
 | 
			
		||||
	return m.AuthCertId > 0
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user