支持阿里云DNS

This commit is contained in:
刘祥超
2020-11-15 11:57:43 +08:00
parent 9ce8c83798
commit 5d652c2f77
14 changed files with 178 additions and 27 deletions

View File

@@ -68,10 +68,13 @@ func (this *ClusterAction) RunGet(params struct {
nodeMaps := []maps.Map{}
for _, node := range nodesResp.Nodes {
nodeMaps = append(nodeMaps, maps.Map{
"id": node.Id,
"name": node.Name,
"ipAddr": node.IpAddr,
"route": node.Route,
"id": node.Id,
"name": node.Name,
"ipAddr": node.IpAddr,
"route": maps.Map{
"name": node.Route.Name,
"code": node.Route.Code,
},
"clusterId": node.ClusterId,
})
}

View File

@@ -3,6 +3,7 @@ package domains
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type RoutesPopupAction struct {
@@ -21,10 +22,14 @@ func (this *RoutesPopupAction) RunGet(params struct {
this.ErrorPage(err)
return
}
if len(routesResp.Routes) == 0 {
routesResp.Routes = []string{}
routeMaps := []maps.Map{}
for _, route := range routesResp.Routes {
routeMaps = append(routeMaps, maps.Map{
"name": route.Name,
"code": route.Code,
})
}
this.Data["routes"] = routesResp.Routes
this.Data["routes"] = routeMaps
this.Show()
}

View File

@@ -5,7 +5,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/maps"
"net"
)
@@ -33,12 +33,12 @@ func (this *UpdateNodePopupAction) RunGet(params struct {
return
}
this.Data["ipAddr"] = dnsInfo.IpAddr
this.Data["route"] = dnsInfo.Route
this.Data["route"] = dnsInfo.Route.Code
this.Data["domainId"] = dnsInfo.DnsDomainId
this.Data["domainName"] = dnsInfo.DnsDomainName
// 读取所有线路
routes := []string{}
routeMaps := []maps.Map{}
if dnsInfo.DnsDomainId > 0 {
routesResp, err := this.RPC().DNSDomainRPC().FindAllDNSDomainRoutes(this.AdminContext(), &pb.FindAllDNSDomainRoutesRequest{DnsDomainId: dnsInfo.DnsDomainId})
if err != nil {
@@ -46,13 +46,28 @@ func (this *UpdateNodePopupAction) RunGet(params struct {
return
}
if len(routesResp.Routes) > 0 {
routes = routesResp.Routes
for _, route := range routesResp.Routes {
routeMaps = append(routeMaps, maps.Map{
"name": route.Name,
"code": route.Code,
})
}
}
}
this.Data["routes"] = routes
this.Data["routes"] = routeMaps
if len(routes) > 0 && !lists.ContainsString(routes, dnsInfo.Route) {
this.Data["route"] = routes[0]
// 是否包含现有线路
if len(routeMaps) > 0 {
isRouteValid := false
for _, route := range routeMaps {
if route.GetString("code") == dnsInfo.Route.Code {
isRouteValid = true
break
}
}
if !isRouteValid {
this.Data["route"] = routeMaps[0].GetString("code")
}
}
this.Show()

View File

@@ -39,10 +39,18 @@ func (this *CreatePopupAction) RunPost(params struct {
Name string
Type string
// dnspod
// DNSPod
ParamId string
ParamToken string
// AliDNS
ParamAccessKeyId string
ParamAccessKeySecret string
// DNS.COM
ParamApiKey string
ParamApiSecret string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
@@ -63,6 +71,24 @@ func (this *CreatePopupAction) RunPost(params struct {
apiParams["id"] = params.ParamId
apiParams["token"] = params.ParamToken
case "alidns":
params.Must.
Field("paramAccessKeyId", params.ParamAccessKeyId).
Require("请输入AccessKeyId").
Field("paramAccessKeySecret", params.ParamAccessKeySecret).
Require("请输入AccessKeySecret")
apiParams["accessKeyId"] = params.ParamAccessKeyId
apiParams["accessKeySecret"] = params.ParamAccessKeySecret
case "dnscom":
params.Must.
Field("paramApiKey", params.ParamApiKey).
Require("请输入ApiKey").
Field("paramApiSecret", params.ParamApiSecret).
Require("请输入ApiSecret")
apiParams["apiKey"] = params.ParamApiKey
apiParams["apiSecret"] = params.ParamApiSecret
default:
this.Fail("暂时不支持此服务商'" + params.Type + "'")
}

View File

@@ -72,10 +72,18 @@ func (this *UpdatePopupAction) RunPost(params struct {
Name string
Type string
// dnspod
// DNSPod
ParamId string
ParamToken string
// AliDNS
ParamAccessKeyId string
ParamAccessKeySecret string
// DNS.COM
ParamApiKey string
ParamApiSecret string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
@@ -98,6 +106,24 @@ func (this *UpdatePopupAction) RunPost(params struct {
apiParams["id"] = params.ParamId
apiParams["token"] = params.ParamToken
case "alidns":
params.Must.
Field("paramAccessKeyId", params.ParamAccessKeyId).
Require("请输入AccessKeyId").
Field("paramAccessKeySecret", params.ParamAccessKeySecret).
Require("请输入AccessKeySecret")
apiParams["accessKeyId"] = params.ParamAccessKeyId
apiParams["accessKeySecret"] = params.ParamAccessKeySecret
case "dnscom":
params.Must.
Field("paramApiKey", params.ParamApiKey).
Require("请输入ApiKey").
Field("paramApiSecret", params.ParamApiSecret).
Require("请输入ApiSecret")
apiParams["apiKey"] = params.ParamApiKey
apiParams["apiSecret"] = params.ParamApiSecret
default:
this.Fail("暂时不支持此服务商'" + params.Type + "'")
}