feat: 新增机器授权凭证管理与其他优化

This commit is contained in:
meilin.huang
2023-03-06 16:59:57 +08:00
parent 7c086bbec8
commit 0695ad9a85
73 changed files with 1666 additions and 811 deletions

View File

@@ -3,8 +3,7 @@ package form
type Mongo struct {
Id uint64
Uri string `binding:"required" json:"uri"`
EnableSshTunnel int8 `json:"enableSshTunnel"` // 是否启用ssh隧道
SshTunnelMachineId uint64 `json:"sshTunnelMachineId"` // ssh隧道机器id
SshTunnelMachineId int `json:"sshTunnelMachineId"` // ssh隧道机器id
Name string `binding:"required" json:"name"`
TagId uint64 `binding:"required" json:"tagId"`
TagPath string `json:"tagPath"`

View File

@@ -108,7 +108,7 @@ var mongoCliCache = cache.NewTimedCache(constant.MongoConnExpireTime, 5*time.Sec
})
func init() {
machine.AddCheckSshTunnelMachineUseFunc(func(machineId uint64) bool {
machine.AddCheckSshTunnelMachineUseFunc(func(machineId int) bool {
// 遍历所有mongo连接实例若存在redis实例使用该ssh隧道机器则返回true表示还在使用中...
items := mongoCliCache.Items()
for _, v := range items {
@@ -144,7 +144,7 @@ type MongoInfo struct {
Id uint64
Name string
TagPath string
SshTunnelMachineId uint64 // ssh隧道机器id
SshTunnelMachineId int // ssh隧道机器id
}
func (m *MongoInfo) GetLogDesc() string {
@@ -177,7 +177,7 @@ func connect(me *entity.Mongo) (*MongoInstance, error) {
mongoOptions := options.Client().ApplyURI(me.Uri).
SetMaxPoolSize(1)
// 启用ssh隧道则连接隧道机器
if me.EnableSshTunnel == 1 {
if me.SshTunnelMachineId > 0 {
mongoOptions.SetDialer(&MongoSshDialer{machineId: me.SshTunnelMachineId})
}
@@ -206,7 +206,7 @@ func toMongiInfo(me *entity.Mongo) *MongoInfo {
}
type MongoSshDialer struct {
machineId uint64
machineId int
}
func (sd *MongoSshDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {

View File

@@ -7,8 +7,7 @@ type Mongo struct {
Name string `orm:"column(name)" json:"name"`
Uri string `orm:"column(uri)" json:"uri"`
EnableSshTunnel int8 `orm:"column(enable_ssh_tunnel)" json:"enableSshTunnel"` // 是否启用ssh隧道
SshTunnelMachineId uint64 `orm:"column(ssh_tunnel_machine_id)" json:"sshTunnelMachineId"` // ssh隧道机器id
SshTunnelMachineId int `orm:"column(ssh_tunnel_machine_id)" json:"sshTunnelMachineId"` // ssh隧道机器id
TagId uint64 `json:"tagId"`
TagPath string `json:"tagPath"`
}

View File

@@ -7,7 +7,6 @@ type MongoQuery struct {
Name string
Uri string
EnableSshTunnel int8 // 是否启用ssh隧道
SshTunnelMachineId uint64 // ssh隧道机器id
TagId uint64 `json:"tagId"`
TagPath string `json:"tagPath"`