集群DNS设置中增加”包含Ln节点“选项

This commit is contained in:
GoEdgeLab
2022-08-25 19:18:34 +08:00
parent 8cd0195cbc
commit 58dfbceb1e
6 changed files with 107 additions and 65 deletions

View File

@@ -26,6 +26,7 @@ func (this *DetailAction) Init() {
func (this *DetailAction) RunGet(params struct {
NodeId int64
ClusterId int64
}) {
this.Data["nodeId"] = params.NodeId
@@ -43,13 +44,13 @@ func (this *DetailAction) RunGet(params struct {
// 主集群
var clusterMap maps.Map = nil
if node.NodeCluster != nil {
clusterId := node.NodeCluster.Id
var clusterId = node.NodeCluster.Id
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId})
if err != nil {
this.ErrorPage(err)
return
}
cluster := clusterResp.NodeCluster
var cluster = clusterResp.NodeCluster
if cluster != nil {
clusterMap = maps.Map{
"id": cluster.Id,
@@ -69,6 +70,14 @@ func (this *DetailAction) RunGet(params struct {
})
}
// 当前访问集群的DNS设置
clusterDNSInfo, err := this.RPC().NodeClusterRPC().FindEnabledNodeClusterDNS(this.AdminContext(), &pb.FindEnabledNodeClusterDNSRequest{NodeClusterId: params.ClusterId})
if err != nil {
this.ErrorPage(err)
return
}
this.Data["dnsIsExcludingLnNode"] = clusterDNSInfo != nil && !clusterDNSInfo.IncludingLnNodes && node.Level > 1
// IP地址
ipAddressesResp, err := this.RPC().NodeIPAddressRPC().FindAllEnabledNodeIPAddressesWithNodeId(this.AdminContext(), &pb.FindAllEnabledNodeIPAddressesWithNodeIdRequest{
NodeId: params.NodeId,

View File

@@ -53,6 +53,7 @@ func (this *IndexAction) RunGet(params struct {
}
this.Data["ttl"] = dnsInfoResp.Ttl
this.Data["cnameAsDomain"] = dnsInfoResp.CnameAsDomain
this.Data["includingLnNodes"] = dnsInfoResp.IncludingLnNodes
this.Show()
}
@@ -67,6 +68,7 @@ func (this *IndexAction) RunPost(params struct {
CnameRecords []string
Ttl int32
CnameAsDomain bool
IncludingLnNodes bool
ConfirmResetDomain bool // 是否确认重置域名
@@ -115,6 +117,7 @@ func (this *IndexAction) RunPost(params struct {
CnameRecords: params.CnameRecords,
Ttl: params.Ttl,
CnameAsDomain: params.CnameAsDomain,
IncludingLnNodes: params.IncludingLnNodes,
})
if err != nil {
this.ErrorPage(err)

View File

@@ -23,36 +23,38 @@ func (this *UpdateClusterPopupAction) RunGet(params struct {
}) {
this.Data["clusterId"] = params.ClusterId
dnsResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeClusterDNS(this.AdminContext(), &pb.FindEnabledNodeClusterDNSRequest{NodeClusterId: params.ClusterId})
dnsInfoResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeClusterDNS(this.AdminContext(), &pb.FindEnabledNodeClusterDNSRequest{NodeClusterId: params.ClusterId})
if err != nil {
this.ErrorPage(err)
return
}
this.Data["dnsName"] = dnsResp.Name
this.Data["nodesAutoSync"] = dnsResp.NodesAutoSync
this.Data["serversAutoSync"] = dnsResp.ServersAutoSync
if dnsResp.Domain != nil {
this.Data["domainId"] = dnsResp.Domain.Id
this.Data["domain"] = dnsResp.Domain.Name
this.Data["dnsName"] = dnsInfoResp.Name
this.Data["nodesAutoSync"] = dnsInfoResp.NodesAutoSync
this.Data["serversAutoSync"] = dnsInfoResp.ServersAutoSync
if dnsInfoResp.Domain != nil {
this.Data["domainId"] = dnsInfoResp.Domain.Id
this.Data["domain"] = dnsInfoResp.Domain.Name
} else {
this.Data["domainId"] = 0
this.Data["domain"] = ""
}
if dnsResp.Provider != nil {
this.Data["providerType"] = dnsResp.Provider.Type
this.Data["providerId"] = dnsResp.Provider.Id
if dnsInfoResp.Provider != nil {
this.Data["providerType"] = dnsInfoResp.Provider.Type
this.Data["providerId"] = dnsInfoResp.Provider.Id
} else {
this.Data["providerType"] = ""
this.Data["providerId"] = 0
}
if len(dnsResp.CnameRecords) == 0 {
if len(dnsInfoResp.CnameRecords) == 0 {
this.Data["cnameRecords"] = []string{}
} else {
this.Data["cnameRecords"] = dnsResp.CnameRecords
this.Data["cnameRecords"] = dnsInfoResp.CnameRecords
}
this.Data["ttl"] = dnsResp.Ttl
this.Data["ttl"] = dnsInfoResp.Ttl
this.Data["cnameAsDomain"] = dnsInfoResp.CnameAsDomain
this.Data["includingLnNodes"] = dnsInfoResp.IncludingLnNodes
// 所有服务商
providerTypesResp, err := this.RPC().DNSProviderRPC().FindAllDNSProviderTypes(this.AdminContext(), &pb.FindAllDNSProviderTypesRequest{})
@@ -80,6 +82,8 @@ func (this *UpdateClusterPopupAction) RunPost(params struct {
ServersAutoSync bool
CnameRecords []string
Ttl int32
CnameAsDomain bool
IncludingLnNodes bool
Must *actions.Must
CSRF *actionutils.CSRF
@@ -115,6 +119,8 @@ func (this *UpdateClusterPopupAction) RunPost(params struct {
ServersAutoSync: params.ServersAutoSync,
CnameRecords: params.CnameRecords,
Ttl: params.Ttl,
CnameAsDomain: params.CnameAsDomain,
IncludingLnNodes: params.IncludingLnNodes,
})
if err != nil {
this.ErrorPage(err)

View File

@@ -47,6 +47,7 @@
<tr v-if="node.records.length > 0">
<td>DNS记录</td>
<td>
<div :style="{opacity: dnsIsExcludingLnNode ? 0.5 : 1.0}">
<table class="ui table celled">
<thead class="full-width">
<tr>
@@ -67,7 +68,9 @@
<td>{{record.value}}</td>
</tr>
</table>
<p class="comment">通过设置A记录可以将集群上的服务请求转发到不同线路的节点上。</p>
<p class="comment" v-if="!dnsIsExcludingLnNode">通过设置A记录可以将集群上的服务请求转发到不同线路的节点上。</p>
</div>
<p class="comment" v-if="dnsIsExcludingLnNode"><span class="red">当前集群DNS已设置不解析Ln节点所以当前节点不会加入DNS解析如需加入请修改"集群设置" -- "DNS设置" -- "更多选项" -- "包含Ln节点"。</span></p>
</td>
</tr>
<tr>

View File

@@ -52,6 +52,13 @@
<p class="comment">选中后表示允许使用CNAME直接访问网站服务如果取消选中则表示CNAME只作为DNS解析记录使用。</p>
</td>
</tr>
<tr v-show="teaIsPlus">
<td>包含Ln节点</td>
<td>
<checkbox name="includingLnNodes" v-model="includingLnNodes"></checkbox>
<p class="comment">选中后表示域名解析中包含L2及以上级别节点。</p>
</td>
</tr>
<tr>
<td>记录TTL</td>
<td>

View File

@@ -55,6 +55,20 @@
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>允许通过CNAME访问网站服务</td>
<td>
<checkbox name="cnameAsDomain" v-model="cnameAsDomain"></checkbox>
<p class="comment">选中后表示允许使用CNAME直接访问网站服务如果取消选中则表示CNAME只作为DNS解析记录使用。</p>
</td>
</tr>
<tr v-show="teaIsPlus">
<td>包含Ln节点</td>
<td>
<checkbox name="includingLnNodes" v-model="includingLnNodes"></checkbox>
<p class="comment">选中后表示域名解析中包含L2及以上级别节点。</p>
</td>
</tr>
<tr>
<td>记录TTL</td>
<td>