From a25b0e6c9daa62855af6a18f7ab17b513de87d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 8 Sep 2022 11:02:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=9B=86=E7=BE=A4=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E5=8F=AF=E4=BB=A5=E8=AE=BE=E7=BD=AEDNS?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E9=BB=98=E8=AE=A4TTL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/node_cluster_dao.go | 6 +++--- internal/rpc/services/service_node_cluster.go | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/db/models/node_cluster_dao.go b/internal/db/models/node_cluster_dao.go index 449025cc..5076900f 100644 --- a/internal/db/models/node_cluster_dao.go +++ b/internal/db/models/node_cluster_dao.go @@ -125,13 +125,13 @@ func (this *NodeClusterDAO) FindAllEnableClusterIds(tx *dbs.Tx) (result []int64, } // CreateCluster 创建集群 -func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, cachePolicyId int64, httpFirewallPolicyId int64, systemServices map[string]maps.Map) (clusterId int64, err error) { +func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, dnsTTL int32, cachePolicyId int64, httpFirewallPolicyId int64, systemServices map[string]maps.Map) (clusterId int64, err error) { uniqueId, err := this.GenUniqueId(tx) if err != nil { return 0, err } - secret := rands.String(32) + var secret = rands.String(32) err = SharedApiTokenDAO.CreateAPIToken(tx, uniqueId, secret, nodeconfigs.NodeRoleCluster) if err != nil { return 0, err @@ -151,7 +151,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string ServersAutoSync: true, CNameRecords: []string{}, CNameAsDomain: true, - TTL: 0, + TTL: dnsTTL, IncludingLnNodes: true, } dnsJSON, err := json.Marshal(dnsConfig) diff --git a/internal/rpc/services/service_node_cluster.go b/internal/rpc/services/service_node_cluster.go index 22640fc3..ea2db270 100644 --- a/internal/rpc/services/service_node_cluster.go +++ b/internal/rpc/services/service_node_cluster.go @@ -33,7 +33,7 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C } // 系统服务 - systemServices := map[string]maps.Map{} + var systemServices = map[string]maps.Map{} if len(req.SystemServicesJSON) > 0 { err = json.Unmarshal(req.SystemServicesJSON, &systemServices) if err != nil { @@ -61,7 +61,12 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C req.HttpFirewallPolicyId = policyId } - clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.NodeGrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices) + // DNS + if req.DnsTTL < 0 { + req.DnsTTL = 0 + } + + clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.NodeGrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.DnsTTL, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices) if err != nil { return err }