mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-17 19:00:24 +08:00
增加DNS服务商账号管理
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -138,6 +139,12 @@ func (this *ServerDAO) CreateServer(adminId int64, userId int64, serverType serv
|
||||
op.GroupIds = groupIdsJSON
|
||||
}
|
||||
|
||||
dnsName, err := this.genDNSName()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
op.DnsName = dnsName
|
||||
|
||||
op.Version = 1
|
||||
op.IsOn = 1
|
||||
op.State = ServerStateEnabled
|
||||
@@ -795,3 +802,19 @@ func (this *ServerDAO) CountAllEnabledServersWithGroupId(groupId int64) (int64,
|
||||
func (this *ServerDAO) createEvent() error {
|
||||
return SharedSysEventDAO.CreateEvent(NewServerChangeEvent())
|
||||
}
|
||||
|
||||
// 生成DNS Name
|
||||
func (this *ServerDAO) genDNSName() (string, error) {
|
||||
for {
|
||||
dnsName := rands.HexString(8)
|
||||
exist, err := this.Query().
|
||||
Attr("dnsName", dnsName).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !exist {
|
||||
return dnsName, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user