增加DNS服务商账号管理

This commit is contained in:
刘祥超
2020-11-11 21:32:25 +08:00
parent ea10e2e3c1
commit e1aa11cdb7
17 changed files with 488 additions and 0 deletions

View File

@@ -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
}
}
}