mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-15 21:20:25 +08:00
支持阿里云DNS
This commit is contained in:
@@ -301,11 +301,16 @@ func (this *RPCClient) pickConn() *grpc.ClientConn {
|
||||
// 检查连接状态
|
||||
if len(this.conns) > 0 {
|
||||
availableConns := []*grpc.ClientConn{}
|
||||
for _, state := range []connectivity.State{connectivity.Ready, connectivity.Idle, connectivity.Connecting} {
|
||||
for _, conn := range this.conns {
|
||||
if conn.GetState() == connectivity.Ready {
|
||||
if conn.GetState() == state {
|
||||
availableConns = append(availableConns, conn)
|
||||
}
|
||||
}
|
||||
if len(availableConns) > 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(availableConns) > 0 {
|
||||
return availableConns[rands.Int(0, len(availableConns)-1)]
|
||||
|
||||
@@ -71,7 +71,10 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"ipAddr": node.IpAddr,
|
||||
"route": node.Route,
|
||||
"route": maps.Map{
|
||||
"name": node.Route.Name,
|
||||
"code": node.Route.Code,
|
||||
},
|
||||
"clusterId": node.ClusterId,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 + "'")
|
||||
}
|
||||
|
||||
@@ -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 + "'")
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<link-red title="点击设置" v-else @click.prevent="updateNode(node.id)">没有设置</link-red>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="node.route.length > 0">{{node.route}}</span>
|
||||
<span v-if="node.route.code.length > 0">{{node.route.name}}</span>
|
||||
<link-red v-else title="点击设置" @click.prevent="updateNode(node.id)">没有设置</link-red>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
<td>
|
||||
<p class="comment" v-if="routes.length == 0">暂时还没有支持的线路。</p>
|
||||
<div v-if="routes.length > 0">
|
||||
<div class="ui label tiny" v-for="route in routes" style="margin-bottom: 0.5em">{{route}}</div>
|
||||
<div class="ui label tiny" v-for="route in routes" style="margin-bottom: 0.5em">{{route.name}}<span v-if="route.code.length > 0 && route.code != route.name"> ({{route.code}})</span></div>
|
||||
</div>
|
||||
<p class="comment">注意:有些DNS服务商会根据账号的会员级别等限制线路的使用。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<td>
|
||||
<p class="comment" v-if="routes.length == 0">没有可选的线路。</p>
|
||||
<select class="ui dropdown auto-width" name="route" v-if="routes.length > 0" v-model="route">
|
||||
<option v-for="route in routes" :value="route">{{route}}</option>
|
||||
<option v-for="route in routes" :value="route.code">{{route.name}}</option>
|
||||
</select>
|
||||
<p class="comment" v-if="routes.length > 0">当前节点IP对应的线路。</p>
|
||||
</td>
|
||||
|
||||
@@ -31,12 +31,50 @@
|
||||
<td>密钥ID *</td>
|
||||
<td>
|
||||
<input type="text" name="paramId" maxlength="100"/>
|
||||
<p class="comment">获取方法参考:<a href="https://docs.dnspod.cn/account/5f2d466de8320f1a740d9ff3/" target="_blank">文档</a> </p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>密钥Token *</td>
|
||||
<td>
|
||||
<input type="text" name="paramToken" maxlength="100"/>
|
||||
<p class="comment">获取方法参考:<a href="https://docs.dnspod.cn/account/5f2d466de8320f1a740d9ff3/" target="_blank">文档</a> </p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- AliDNS -->
|
||||
<tbody v-if="type == 'alidns'">
|
||||
<tr>
|
||||
<td>AccessKeyId *</td>
|
||||
<td>
|
||||
<input type="text" name="paramAccessKeyId" maxlength="100"/>
|
||||
<p class="comment">登录阿里云控制台 -- 在"访问控制"中创建和获取。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>AccessKeySecret *</td>
|
||||
<td>
|
||||
<input type="text" name="paramAccessKeySecret" maxlength="100"/>
|
||||
<p class="comment">登录阿里云控制台 -- 在"访问控制"中创建和获取。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- DNS.COM -->
|
||||
<tbody v-if="type == 'dnscom'">
|
||||
<tr>
|
||||
<td>AccessKeyId *</td>
|
||||
<td>
|
||||
<input type="text" name="paramApiKey" maxlength="100"/>
|
||||
<p class="comment">登录DNS.COM控制台 -- 在"账户中心" -- "API设置"中创建和获取。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>AccessKeySecret *</td>
|
||||
<td>
|
||||
<input type="text" name="paramApiSecret" maxlength="100"/>
|
||||
<p class="comment">登录DNS.COM控制台 -- 在"账户中心" -- "API设置"中创建和获取。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Tea.context(function () {
|
||||
this.createProvider = function () {
|
||||
teaweb.popup(Tea.url(".createPopup"), {
|
||||
height: "26em",
|
||||
height: "28em",
|
||||
callback: function () {
|
||||
teaweb.success("保存成功", function () {
|
||||
teaweb.reload()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<td>服务商</td>
|
||||
<td>{{provider.typeName}}</td>
|
||||
</tr>
|
||||
|
||||
<!-- DNSPod -->
|
||||
<tbody v-if="provider.type == 'dnspod'">
|
||||
<tr>
|
||||
@@ -29,6 +30,18 @@
|
||||
<td>{{provider.apiParams.token}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- AliDNS -->
|
||||
<tbody v-if="provider.type == 'alidns'">
|
||||
<tr>
|
||||
<td>AccessKeyId</td>
|
||||
<td>{{provider.apiParams.accessKeyId}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>AccessKeySecret</td>
|
||||
<td>{{provider.apiParams.accessKeySecret}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Tea.context(function () {
|
||||
this.updateProvider = function (providerId) {
|
||||
teaweb.popup(Tea.url(".updatePopup?providerId=" + providerId), {
|
||||
height: "26em",
|
||||
height: "28em",
|
||||
callback: function () {
|
||||
teaweb.success("保存成功", function () {
|
||||
teaweb.reload()
|
||||
@@ -65,7 +65,6 @@ Tea.context(function () {
|
||||
})
|
||||
})
|
||||
.done(function () {
|
||||
domain.isSyncing = false
|
||||
Vue.set(that.domains, index, domain)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -29,13 +29,33 @@
|
||||
<tr>
|
||||
<td>密钥ID *</td>
|
||||
<td>
|
||||
<input type="text" name="paramId" maxlength="100" :value="provider.params.id"/>
|
||||
<input type="text" name="paramId" maxlength="100" v-model="provider.params.id"/>
|
||||
<p class="comment">获取方法参考:<a href="https://docs.dnspod.cn/account/5f2d466de8320f1a740d9ff3/" target="_blank">文档</a> </p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>密钥Token *</td>
|
||||
<td>
|
||||
<input type="text" name="paramToken" maxlength="100" :value="provider.params.token"/>
|
||||
<input type="text" name="paramToken" maxlength="100" v-model="provider.params.token"/>
|
||||
<p class="comment">获取方法参考:<a href="https://docs.dnspod.cn/account/5f2d466de8320f1a740d9ff3/" target="_blank">文档</a> </p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- AliDNS -->
|
||||
<tbody v-if="provider.type == 'alidns'">
|
||||
<tr>
|
||||
<td>AccessKeyId *</td>
|
||||
<td>
|
||||
<input type="text" name="paramAccessKeyId" maxlength="100" v-model="provider.params.accessKeyId"/>
|
||||
<p class="comment">登录阿里云控制台 -- 在"访问控制"中创建和获取。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>AccessKeySecret *</td>
|
||||
<td>
|
||||
<input type="text" name="paramAccessKeySecret" maxlength="100" v-model="provider.params.accessKeySecret"/>
|
||||
<p class="comment">登录阿里云控制台 -- 在"访问控制"中创建和获取。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user