mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-23 18:00:27 +08:00
修复域名解析--集群中单节点多IP时无法修改IP的Bug
This commit is contained in:
@@ -43,7 +43,7 @@ func (this *ClusterAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
var defaultRoute = dnsResp.DefaultRoute
|
var defaultRoute = dnsResp.DefaultRoute
|
||||||
domainName := ""
|
domainName := ""
|
||||||
dnsMap := maps.Map{
|
var dnsMap = maps.Map{
|
||||||
"dnsName": dnsResp.Name,
|
"dnsName": dnsResp.Name,
|
||||||
"domainId": 0,
|
"domainId": 0,
|
||||||
"domainName": "",
|
"domainName": "",
|
||||||
@@ -76,14 +76,14 @@ func (this *ClusterAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nodeMaps := []maps.Map{}
|
var nodeMaps = []maps.Map{}
|
||||||
for _, node := range nodesResp.Nodes {
|
for _, node := range nodesResp.Nodes {
|
||||||
if len(node.Routes) > 0 {
|
if len(node.Routes) > 0 {
|
||||||
for _, route := range node.Routes {
|
for _, route := range node.Routes {
|
||||||
// 检查是否已解析
|
// 检查是否已解析
|
||||||
isResolved := false
|
var isResolved = false
|
||||||
if cluster.DnsDomainId > 0 && len(cluster.DnsName) > 0 && len(node.IpAddr) > 0 {
|
if cluster.DnsDomainId > 0 && len(cluster.DnsName) > 0 && len(node.IpAddr) > 0 {
|
||||||
recordType := "A"
|
var recordType = "A"
|
||||||
if utils.IsIPv6(node.IpAddr) {
|
if utils.IsIPv6(node.IpAddr) {
|
||||||
recordType = "AAAA"
|
recordType = "AAAA"
|
||||||
}
|
}
|
||||||
@@ -105,6 +105,7 @@ func (this *ClusterAction) RunGet(params struct {
|
|||||||
"id": node.Id,
|
"id": node.Id,
|
||||||
"name": node.Name,
|
"name": node.Name,
|
||||||
"ipAddr": node.IpAddr,
|
"ipAddr": node.IpAddr,
|
||||||
|
"ipAddrId": node.NodeIPAddressId,
|
||||||
"route": maps.Map{
|
"route": maps.Map{
|
||||||
"name": route.Name,
|
"name": route.Name,
|
||||||
"code": route.Code,
|
"code": route.Code,
|
||||||
@@ -117,7 +118,7 @@ func (this *ClusterAction) RunGet(params struct {
|
|||||||
// 默认线路
|
// 默认线路
|
||||||
var isResolved = false
|
var isResolved = false
|
||||||
if len(defaultRoute) > 0 {
|
if len(defaultRoute) > 0 {
|
||||||
recordType := "A"
|
var recordType = "A"
|
||||||
if utils.IsIPv6(node.IpAddr) {
|
if utils.IsIPv6(node.IpAddr) {
|
||||||
recordType = "AAAA"
|
recordType = "AAAA"
|
||||||
}
|
}
|
||||||
@@ -138,6 +139,7 @@ func (this *ClusterAction) RunGet(params struct {
|
|||||||
"id": node.Id,
|
"id": node.Id,
|
||||||
"name": node.Name,
|
"name": node.Name,
|
||||||
"ipAddr": node.IpAddr,
|
"ipAddr": node.IpAddr,
|
||||||
|
"ipAddrId": node.NodeIPAddressId,
|
||||||
"route": maps.Map{
|
"route": maps.Map{
|
||||||
"name": "",
|
"name": "",
|
||||||
"code": "",
|
"code": "",
|
||||||
@@ -155,7 +157,7 @@ func (this *ClusterAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
serverMaps := []maps.Map{}
|
var serverMaps = []maps.Map{}
|
||||||
for _, server := range serversResp.Servers {
|
for _, server := range serversResp.Servers {
|
||||||
// 检查是否已解析
|
// 检查是否已解析
|
||||||
isResolved := false
|
isResolved := false
|
||||||
@@ -198,7 +200,7 @@ func (this *ClusterAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
issueMaps := []maps.Map{}
|
var issueMaps = []maps.Map{}
|
||||||
for _, issue := range issuesResp.Issues {
|
for _, issue := range issuesResp.Issues {
|
||||||
issueMaps = append(issueMaps, maps.Map{
|
issueMaps = append(issueMaps, maps.Map{
|
||||||
"target": issue.Target,
|
"target": issue.Target,
|
||||||
@@ -218,7 +220,7 @@ func (this *ClusterAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
taskMaps := []maps.Map{}
|
var taskMaps = []maps.Map{}
|
||||||
for _, task := range resp.DnsTasks {
|
for _, task := range resp.DnsTasks {
|
||||||
var clusterMap maps.Map = nil
|
var clusterMap maps.Map = nil
|
||||||
var nodeMap maps.Map = nil
|
var nodeMap maps.Map = nil
|
||||||
|
|||||||
@@ -22,12 +22,14 @@ func (this *UpdateNodePopupAction) Init() {
|
|||||||
func (this *UpdateNodePopupAction) RunGet(params struct {
|
func (this *UpdateNodePopupAction) RunGet(params struct {
|
||||||
ClusterId int64
|
ClusterId int64
|
||||||
NodeId int64
|
NodeId int64
|
||||||
|
IpAddrId int64
|
||||||
}) {
|
}) {
|
||||||
this.Data["nodeId"] = params.NodeId
|
this.Data["nodeId"] = params.NodeId
|
||||||
|
|
||||||
dnsInfoResp, err := this.RPC().NodeRPC().FindEnabledNodeDNS(this.AdminContext(), &pb.FindEnabledNodeDNSRequest{
|
dnsInfoResp, err := this.RPC().NodeRPC().FindEnabledNodeDNS(this.AdminContext(), &pb.FindEnabledNodeDNSRequest{
|
||||||
NodeId: params.NodeId,
|
NodeId: params.NodeId,
|
||||||
NodeClusterId: params.ClusterId,
|
NodeClusterId: params.ClusterId,
|
||||||
|
NodeIPAddrId: params.IpAddrId,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -39,12 +41,13 @@ func (this *UpdateNodePopupAction) RunGet(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.Data["ipAddr"] = dnsInfo.IpAddr
|
this.Data["ipAddr"] = dnsInfo.IpAddr
|
||||||
|
this.Data["ipAddrId"] = dnsInfo.NodeIPAddressId
|
||||||
this.Data["routes"] = domainutils.ConvertRoutesToMaps(dnsInfo)
|
this.Data["routes"] = domainutils.ConvertRoutesToMaps(dnsInfo)
|
||||||
this.Data["domainId"] = dnsInfo.DnsDomainId
|
this.Data["domainId"] = dnsInfo.DnsDomainId
|
||||||
this.Data["domainName"] = dnsInfo.DnsDomainName
|
this.Data["domainName"] = dnsInfo.DnsDomainName
|
||||||
|
|
||||||
// 读取所有线路
|
// 读取所有线路
|
||||||
allRouteMaps := []maps.Map{}
|
var allRouteMaps = []maps.Map{}
|
||||||
if dnsInfo.DnsDomainId > 0 {
|
if dnsInfo.DnsDomainId > 0 {
|
||||||
routesResp, err := this.RPC().DNSDomainRPC().FindAllDNSDomainRoutes(this.AdminContext(), &pb.FindAllDNSDomainRoutesRequest{DnsDomainId: dnsInfo.DnsDomainId})
|
routesResp, err := this.RPC().DNSDomainRPC().FindAllDNSDomainRoutes(this.AdminContext(), &pb.FindAllDNSDomainRoutesRequest{DnsDomainId: dnsInfo.DnsDomainId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -75,6 +78,7 @@ func (this *UpdateNodePopupAction) RunGet(params struct {
|
|||||||
func (this *UpdateNodePopupAction) RunPost(params struct {
|
func (this *UpdateNodePopupAction) RunPost(params struct {
|
||||||
NodeId int64
|
NodeId int64
|
||||||
IpAddr string
|
IpAddr string
|
||||||
|
IpAddrId int64
|
||||||
DomainId int64
|
DomainId int64
|
||||||
DnsRoutesJSON []byte
|
DnsRoutesJSON []byte
|
||||||
|
|
||||||
@@ -84,7 +88,7 @@ func (this *UpdateNodePopupAction) RunPost(params struct {
|
|||||||
// 操作日志
|
// 操作日志
|
||||||
defer this.CreateLog(oplogs.LevelInfo, "修改节点 %d 的DNS设置", params.NodeId)
|
defer this.CreateLog(oplogs.LevelInfo, "修改节点 %d 的DNS设置", params.NodeId)
|
||||||
|
|
||||||
routes := []string{}
|
var routes = []string{}
|
||||||
if len(params.DnsRoutesJSON) > 0 {
|
if len(params.DnsRoutesJSON) > 0 {
|
||||||
err := json.Unmarshal(params.DnsRoutesJSON, &routes)
|
err := json.Unmarshal(params.DnsRoutesJSON, &routes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -105,6 +109,7 @@ func (this *UpdateNodePopupAction) RunPost(params struct {
|
|||||||
_, err := this.RPC().NodeRPC().UpdateNodeDNS(this.AdminContext(), &pb.UpdateNodeDNSRequest{
|
_, err := this.RPC().NodeRPC().UpdateNodeDNS(this.AdminContext(), &pb.UpdateNodeDNSRequest{
|
||||||
NodeId: params.NodeId,
|
NodeId: params.NodeId,
|
||||||
IpAddr: params.IpAddr,
|
IpAddr: params.IpAddr,
|
||||||
|
NodeIPAddressId: params.IpAddrId,
|
||||||
DnsDomainId: params.DomainId,
|
DnsDomainId: params.DomainId,
|
||||||
Routes: routes,
|
Routes: routes,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -157,18 +157,18 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span v-if="node.ipAddr.length > 0">{{node.ipAddr}}</span>
|
<span v-if="node.ipAddr.length > 0">{{node.ipAddr}}</span>
|
||||||
<link-red title="点击设置" v-else @click.prevent="updateNode(node.clusterId, node.id)">没有设置</link-red>
|
<link-red title="点击设置" v-else @click.prevent="updateNode(node.clusterId, node.id, node.ipAddrId)">没有设置</link-red>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span v-if="node.route.code.length > 0">{{node.route.name}}</span>
|
<span v-if="node.route.code.length > 0">{{node.route.name}}</span>
|
||||||
<link-red v-else title="点击设置" @click.prevent="updateNode(node.clusterId, node.id)">没有设置</link-red>
|
<link-red v-else title="点击设置" @click.prevent="updateNode(node.clusterId, node.id, node.ipAddrId)">没有设置</link-red>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="green" v-if="node.isResolved">已解析</span>
|
<span class="green" v-if="node.isResolved">已解析</span>
|
||||||
<span v-else class="red">未解析</span>
|
<span v-else class="red">未解析</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<link-popup @click.prevent="updateNode(node.clusterId, node.id)">修改</link-popup>
|
<link-popup @click.prevent="updateNode(node.clusterId, node.id, node.ipAddrId)">修改</link-popup>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ Tea.context(function () {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateNode = function (clusterId, nodeId) {
|
this.updateNode = function (clusterId, nodeId, ipAddrId) {
|
||||||
teaweb.popup("/dns/issues/updateNodePopup?clusterId=" + clusterId + "&nodeId=" + nodeId, {
|
teaweb.popup("/dns/issues/updateNodePopup?clusterId=" + clusterId + "&nodeId=" + nodeId + "&ipAddrId=" + (ipAddrId ? ipAddrId : 0), {
|
||||||
width: "46em",
|
width: "46em",
|
||||||
height: "26em",
|
height: "26em",
|
||||||
callback: function () {
|
callback: function () {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||||
<input type="hidden" name="nodeId" :value="nodeId"/>
|
<input type="hidden" name="nodeId" :value="nodeId"/>
|
||||||
<input type="hidden" name="domainId" :value="domainId"/>
|
<input type="hidden" name="domainId" :value="domainId"/>
|
||||||
|
<input type="hidden" name="ipAddrId" :value="ipAddrId"/>
|
||||||
<csrf-token></csrf-token>
|
<csrf-token></csrf-token>
|
||||||
|
|
||||||
<table class="ui table definition selectable">
|
<table class="ui table definition selectable">
|
||||||
|
|||||||
Reference in New Issue
Block a user