实现在域名解析中使用EdgeDNS

This commit is contained in:
GoEdgeLab
2021-06-02 18:14:00 +08:00
parent 949a20f684
commit 21d2e7e924
8 changed files with 144 additions and 17 deletions

View File

@@ -27,8 +27,9 @@ func (this *CreatePopupAction) RunGet(params struct{}) {
typeMaps := []maps.Map{}
for _, t := range typesResp.ProviderTypes {
typeMaps = append(typeMaps, maps.Map{
"name": t.Name,
"code": t.Code,
"name": t.Name,
"code": t.Code,
"description": t.Description,
})
}
this.Data["types"] = typeMaps
@@ -36,6 +37,21 @@ func (this *CreatePopupAction) RunGet(params struct{}) {
// 自动生成CustomHTTP私钥
this.Data["paramCustomHTTPSecret"] = rands.HexString(32)
// EdgeDNS集群列表
nsClustersResp, err := this.RPC().NSClusterRPC().FindAllEnabledNSClusters(this.AdminContext(), &pb.FindAllEnabledNSClustersRequest{})
if err != nil {
this.ErrorPage(err)
return
}
nsClusterMaps := []maps.Map{}
for _, nsCluster := range nsClustersResp.NsClusters {
nsClusterMaps = append(nsClusterMaps, maps.Map{
"id": nsCluster.Id,
"name": nsCluster.Name,
})
}
this.Data["nsClusters"] = nsClusterMaps
this.Show()
}
@@ -59,6 +75,9 @@ func (this *CreatePopupAction) RunPost(params struct {
CloudFlareAPIKey string
CloudFlareEmail string
// Local EdgeDNS
ParamLocalEdgeDNSClusterId int64
// CustomHTTP
ParamCustomHTTPURL string
ParamCustomHTTPSecret string
@@ -109,6 +128,11 @@ func (this *CreatePopupAction) RunPost(params struct {
Email("请输入正确格式的邮箱地址")
apiParams["apiKey"] = params.CloudFlareAPIKey
apiParams["email"] = params.CloudFlareEmail
case "localEdgeDNS":
params.Must.
Field("ParamLocalEdgeDNSClusterId", params.ParamLocalEdgeDNSClusterId).
Gt(0, "请选择域名服务集群")
apiParams["clusterId"] = params.ParamLocalEdgeDNSClusterId
case "customHTTP":
params.Must.
Field("paramCustomHTTPURL", params.ParamCustomHTTPURL).