增加SSH登录建议端口接口

This commit is contained in:
GoEdgeLab
2021-08-14 18:07:20 +08:00
parent 09b1c65463
commit af90487eaa
8 changed files with 131 additions and 14 deletions

View File

@@ -136,3 +136,22 @@ func (this *NodeLoginDAO) DisableNodeLogins(tx *dbs.Tx, role nodeconfigs.NodeRol
Update()
return err
}
func (this *NodeLoginDAO) FindFrequentPorts(tx *dbs.Tx) ([]int32, error) {
ones, _, err := this.Query(tx).
Attr("state", NodeLoginStateEnabled).
Result("JSON_EXTRACT(params, '$.port') as `port`", "COUNT(*) AS c").
Having("port>0").
Desc("c").
Limit(10).
Group("port").
FindOnes()
if err != nil {
return nil, err
}
var ports = []int32{}
for _, one := range ones {
ports = append(ports, one.GetInt32("port"))
}
return ports, nil
}