diff --git a/internal/web/actions/default/dns/clusters/cluster.go b/internal/web/actions/default/dns/clusters/cluster.go
index c9344a6e..300ca285 100644
--- a/internal/web/actions/default/dns/clusters/cluster.go
+++ b/internal/web/actions/default/dns/clusters/cluster.go
@@ -25,7 +25,7 @@ func (this *ClusterAction) RunGet(params struct {
this.ErrorPage(err)
return
}
- cluster := clusterResp.NodeCluster
+ var cluster = clusterResp.NodeCluster
if cluster == nil {
this.NotFound("nodeCluster", params.ClusterId)
return
@@ -42,7 +42,7 @@ func (this *ClusterAction) RunGet(params struct {
return
}
var defaultRoute = dnsResp.DefaultRoute
- domainName := ""
+ var domainName = ""
var dnsMap = maps.Map{
"dnsName": dnsResp.Name,
"domainId": 0,
@@ -70,19 +70,42 @@ func (this *ClusterAction) RunGet(params struct {
this.Data["dnsInfo"] = dnsMap
- // 节点DNS解析记录
- nodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{NodeClusterId: params.ClusterId})
+ // 未安装的节点
+ notInstalledNodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{
+ NodeClusterId: params.ClusterId,
+ IsInstalled: false,
+ })
if err != nil {
this.ErrorPage(err)
return
}
- var nodeMaps = []maps.Map{}
+ var allNodes = notInstalledNodesResp.Nodes
+
+ // 节点DNS解析记录
+ nodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{
+ NodeClusterId: params.ClusterId,
+ IsInstalled: true,
+ })
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ var installedNodeIdsMap = map[int64]bool{}
for _, node := range nodesResp.Nodes {
+ installedNodeIdsMap[node.Id] = true
+ }
+
+ allNodes = append(allNodes, nodesResp.Nodes...)
+
+ var nodeMaps = []maps.Map{}
+ for _, node := range allNodes {
+ var isInstalled = installedNodeIdsMap[node.Id]
+
if len(node.Routes) > 0 {
for _, route := range node.Routes {
// 检查是否已解析
var isResolved = false
- if cluster.DnsDomainId > 0 && len(cluster.DnsName) > 0 && len(node.IpAddr) > 0 {
+ if isInstalled && cluster.DnsDomainId > 0 && len(cluster.DnsName) > 0 && len(node.IpAddr) > 0 {
var recordType = "A"
if utils.IsIPv6(node.IpAddr) {
recordType = "AAAA"
@@ -110,14 +133,15 @@ func (this *ClusterAction) RunGet(params struct {
"name": route.Name,
"code": route.Code,
},
- "clusterId": node.NodeClusterId,
- "isResolved": isResolved,
+ "clusterId": node.NodeClusterId,
+ "isResolved": isResolved,
+ "isInstalled": isInstalled,
})
}
} else {
// 默认线路
var isResolved = false
- if len(defaultRoute) > 0 {
+ if isInstalled && len(defaultRoute) > 0 {
var recordType = "A"
if utils.IsIPv6(node.IpAddr) {
recordType = "AAAA"
@@ -144,8 +168,9 @@ func (this *ClusterAction) RunGet(params struct {
"name": "",
"code": "",
},
- "clusterId": node.NodeClusterId,
- "isResolved": isResolved,
+ "clusterId": node.NodeClusterId,
+ "isResolved": isResolved,
+ "isInstalled": isInstalled,
})
}
}
diff --git a/internal/web/actions/default/dns/domains/nodesPopup.go b/internal/web/actions/default/dns/domains/nodesPopup.go
index 8bfdc276..c277c51f 100644
--- a/internal/web/actions/default/dns/domains/nodesPopup.go
+++ b/internal/web/actions/default/dns/domains/nodesPopup.go
@@ -18,6 +18,8 @@ func (this *NodesPopupAction) Init() {
func (this *NodesPopupAction) RunGet(params struct {
DomainId int64
}) {
+ this.Data["domainId"] = params.DomainId
+
// 域名信息
domainResp, err := this.RPC().DNSDomainRPC().FindBasicDNSDomain(this.AdminContext(), &pb.FindBasicDNSDomainRequest{
DnsDomainId: params.DomainId,
@@ -26,7 +28,7 @@ func (this *NodesPopupAction) RunGet(params struct {
this.ErrorPage(err)
return
}
- domain := domainResp.DnsDomain
+ var domain = domainResp.DnsDomain
if domain == nil {
this.NotFound("dnsDomain", params.DomainId)
return
@@ -35,7 +37,7 @@ func (this *NodesPopupAction) RunGet(params struct {
this.Data["domain"] = domain.Name
// 集群
- clusterMaps := []maps.Map{}
+ var clusterMaps = []maps.Map{}
clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithDNSDomainId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithDNSDomainIdRequest{DnsDomainId: params.DomainId})
if err != nil {
this.ErrorPage(err)
@@ -43,18 +45,24 @@ func (this *NodesPopupAction) RunGet(params struct {
}
for _, cluster := range clustersResp.NodeClusters {
+ // 默认值
+ var defaultRoute = cluster.DnsDefaultRoute
+
// 节点DNS解析记录
- nodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{NodeClusterId: cluster.Id})
+ nodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesDNSWithNodeClusterId(this.AdminContext(), &pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest{
+ NodeClusterId: cluster.Id,
+ IsInstalled: true,
+ })
if err != nil {
this.ErrorPage(err)
return
}
- nodeMaps := []maps.Map{}
+ var nodeMaps = []maps.Map{}
for _, node := range nodesResp.Nodes {
if len(node.Routes) > 0 {
for _, route := range node.Routes {
// 检查是否有域名解析记录
- isOk := false
+ var isResolved = false
if len(route.Name) > 0 && len(node.IpAddr) > 0 && len(cluster.DnsName) > 0 {
var recordType = "A"
if utils.IsIPv6(node.IpAddr) {
@@ -71,7 +79,7 @@ func (this *NodesPopupAction) RunGet(params struct {
this.ErrorPage(err)
return
}
- isOk = checkResp.IsOk
+ isResolved = checkResp.IsOk
}
nodeMaps = append(nodeMaps, maps.Map{
@@ -83,10 +91,30 @@ func (this *NodesPopupAction) RunGet(params struct {
"code": route.Code,
},
"clusterId": node.NodeClusterId,
- "isOk": isOk,
+ "isOk": isResolved,
})
}
} else {
+ // 默认线路
+ var isResolved = false
+ if len(defaultRoute) > 0 {
+ var recordType = "A"
+ if utils.IsIPv6(node.IpAddr) {
+ recordType = "AAAA"
+ }
+ checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{
+ DnsDomainId: cluster.DnsDomainId,
+ Name: cluster.DnsName,
+ Type: recordType,
+ Route: defaultRoute,
+ Value: node.IpAddr,
+ })
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ isResolved = checkResp.IsOk
+ }
nodeMaps = append(nodeMaps, maps.Map{
"id": node.Id,
"name": node.Name,
@@ -96,7 +124,7 @@ func (this *NodesPopupAction) RunGet(params struct {
"code": "",
},
"clusterId": node.NodeClusterId,
- "isOk": false,
+ "isOk": isResolved,
})
}
}
diff --git a/internal/web/actions/default/dns/domains/serversPopup.go b/internal/web/actions/default/dns/domains/serversPopup.go
index afabe526..d0e88ecd 100644
--- a/internal/web/actions/default/dns/domains/serversPopup.go
+++ b/internal/web/actions/default/dns/domains/serversPopup.go
@@ -17,6 +17,8 @@ func (this *ServersPopupAction) Init() {
func (this *ServersPopupAction) RunGet(params struct {
DomainId int64
}) {
+ this.Data["domainId"] = params.DomainId
+
// 域名信息
domainResp, err := this.RPC().DNSDomainRPC().FindBasicDNSDomain(this.AdminContext(), &pb.FindBasicDNSDomainRequest{
DnsDomainId: params.DomainId,
@@ -25,7 +27,7 @@ func (this *ServersPopupAction) RunGet(params struct {
this.ErrorPage(err)
return
}
- domain := domainResp.DnsDomain
+ var domain = domainResp.DnsDomain
if domain == nil {
this.NotFound("dnsDomain", params.DomainId)
return
@@ -34,7 +36,7 @@ func (this *ServersPopupAction) RunGet(params struct {
this.Data["domain"] = domain.Name
// 服务信息
- clusterMaps := []maps.Map{}
+ var clusterMaps = []maps.Map{}
clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithDNSDomainId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithDNSDomainIdRequest{DnsDomainId: params.DomainId})
if err != nil {
this.ErrorPage(err)
@@ -46,9 +48,9 @@ func (this *ServersPopupAction) RunGet(params struct {
this.ErrorPage(err)
return
}
- serverMaps := []maps.Map{}
+ var serverMaps = []maps.Map{}
for _, server := range serversResp.Servers {
- isOk := false
+ var isOk = false
if len(cluster.DnsName) > 0 && len(server.DnsName) > 0 {
checkResp, err := this.RPC().DNSDomainRPC().ExistDNSDomainRecord(this.AdminContext(), &pb.ExistDNSDomainRecordRequest{
DnsDomainId: params.DomainId,
diff --git a/web/public/js/components/common/links.js b/web/public/js/components/common/links.js
index 5873e075..ae808f51 100644
--- a/web/public/js/components/common/links.js
+++ b/web/public/js/components/common/links.js
@@ -24,6 +24,10 @@ Vue.component("link-red", {
methods: {
clickPrevent: function () {
emitClick(this, arguments)
+
+ if (this.vHref.length > 0) {
+ window.location = this.vHref
+ }
}
},
template: `
通过设置A记录可以将集群上的服务请求转发到不同线路的节点上。
当前集群DNS已设置不解析Ln节点,所以当前节点不会加入DNS解析;如需加入,请修改"集群设置" -- "DNS设置" -- "更多选项" -- "包含Ln节点"。
+当前节点尚未完成安装,DNS解析记录将不会生效,[点此安装]。