mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-16 13:40:24 +08:00
支持阿里云DNS
This commit is contained in:
@@ -301,9 +301,14 @@ func (this *RPCClient) pickConn() *grpc.ClientConn {
|
|||||||
// 检查连接状态
|
// 检查连接状态
|
||||||
if len(this.conns) > 0 {
|
if len(this.conns) > 0 {
|
||||||
availableConns := []*grpc.ClientConn{}
|
availableConns := []*grpc.ClientConn{}
|
||||||
for _, conn := range this.conns {
|
for _, state := range []connectivity.State{connectivity.Ready, connectivity.Idle, connectivity.Connecting} {
|
||||||
if conn.GetState() == connectivity.Ready {
|
for _, conn := range this.conns {
|
||||||
availableConns = append(availableConns, conn)
|
if conn.GetState() == state {
|
||||||
|
availableConns = append(availableConns, conn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(availableConns) > 0 {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,10 +68,13 @@ func (this *ClusterAction) RunGet(params struct {
|
|||||||
nodeMaps := []maps.Map{}
|
nodeMaps := []maps.Map{}
|
||||||
for _, node := range nodesResp.Nodes {
|
for _, node := range nodesResp.Nodes {
|
||||||
nodeMaps = append(nodeMaps, maps.Map{
|
nodeMaps = append(nodeMaps, maps.Map{
|
||||||
"id": node.Id,
|
"id": node.Id,
|
||||||
"name": node.Name,
|
"name": node.Name,
|
||||||
"ipAddr": node.IpAddr,
|
"ipAddr": node.IpAddr,
|
||||||
"route": node.Route,
|
"route": maps.Map{
|
||||||
|
"name": node.Route.Name,
|
||||||
|
"code": node.Route.Code,
|
||||||
|
},
|
||||||
"clusterId": node.ClusterId,
|
"clusterId": node.ClusterId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package domains
|
|||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RoutesPopupAction struct {
|
type RoutesPopupAction struct {
|
||||||
@@ -21,10 +22,14 @@ func (this *RoutesPopupAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(routesResp.Routes) == 0 {
|
routeMaps := []maps.Map{}
|
||||||
routesResp.Routes = []string{}
|
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()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/lists"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,12 +33,12 @@ func (this *UpdateNodePopupAction) RunGet(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.Data["ipAddr"] = dnsInfo.IpAddr
|
this.Data["ipAddr"] = dnsInfo.IpAddr
|
||||||
this.Data["route"] = dnsInfo.Route
|
this.Data["route"] = dnsInfo.Route.Code
|
||||||
this.Data["domainId"] = dnsInfo.DnsDomainId
|
this.Data["domainId"] = dnsInfo.DnsDomainId
|
||||||
this.Data["domainName"] = dnsInfo.DnsDomainName
|
this.Data["domainName"] = dnsInfo.DnsDomainName
|
||||||
|
|
||||||
// 读取所有线路
|
// 读取所有线路
|
||||||
routes := []string{}
|
routeMaps := []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 {
|
||||||
@@ -46,13 +46,28 @@ func (this *UpdateNodePopupAction) RunGet(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(routesResp.Routes) > 0 {
|
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()
|
this.Show()
|
||||||
|
|||||||
@@ -39,10 +39,18 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
|
|
||||||
// dnspod
|
// DNSPod
|
||||||
ParamId string
|
ParamId string
|
||||||
ParamToken string
|
ParamToken string
|
||||||
|
|
||||||
|
// AliDNS
|
||||||
|
ParamAccessKeyId string
|
||||||
|
ParamAccessKeySecret string
|
||||||
|
|
||||||
|
// DNS.COM
|
||||||
|
ParamApiKey string
|
||||||
|
ParamApiSecret string
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
CSRF *actionutils.CSRF
|
CSRF *actionutils.CSRF
|
||||||
}) {
|
}) {
|
||||||
@@ -63,6 +71,24 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
|
|
||||||
apiParams["id"] = params.ParamId
|
apiParams["id"] = params.ParamId
|
||||||
apiParams["token"] = params.ParamToken
|
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:
|
default:
|
||||||
this.Fail("暂时不支持此服务商'" + params.Type + "'")
|
this.Fail("暂时不支持此服务商'" + params.Type + "'")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,10 +72,18 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
|
|
||||||
// dnspod
|
// DNSPod
|
||||||
ParamId string
|
ParamId string
|
||||||
ParamToken string
|
ParamToken string
|
||||||
|
|
||||||
|
// AliDNS
|
||||||
|
ParamAccessKeyId string
|
||||||
|
ParamAccessKeySecret string
|
||||||
|
|
||||||
|
// DNS.COM
|
||||||
|
ParamApiKey string
|
||||||
|
ParamApiSecret string
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
CSRF *actionutils.CSRF
|
CSRF *actionutils.CSRF
|
||||||
}) {
|
}) {
|
||||||
@@ -98,6 +106,24 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
|
|
||||||
apiParams["id"] = params.ParamId
|
apiParams["id"] = params.ParamId
|
||||||
apiParams["token"] = params.ParamToken
|
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:
|
default:
|
||||||
this.Fail("暂时不支持此服务商'" + params.Type + "'")
|
this.Fail("暂时不支持此服务商'" + params.Type + "'")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
<link-red title="点击设置" v-else @click.prevent="updateNode(node.id)">没有设置</link-red>
|
<link-red title="点击设置" v-else @click.prevent="updateNode(node.id)">没有设置</link-red>
|
||||||
</td>
|
</td>
|
||||||
<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>
|
<link-red v-else title="点击设置" @click.prevent="updateNode(node.id)">没有设置</link-red>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
<td>
|
<td>
|
||||||
<p class="comment" v-if="routes.length == 0">暂时还没有支持的线路。</p>
|
<p class="comment" v-if="routes.length == 0">暂时还没有支持的线路。</p>
|
||||||
<div v-if="routes.length > 0">
|
<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>
|
</div>
|
||||||
|
<p class="comment">注意:有些DNS服务商会根据账号的会员级别等限制线路的使用。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<p class="comment" v-if="routes.length == 0">没有可选的线路。</p>
|
<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">
|
<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>
|
</select>
|
||||||
<p class="comment" v-if="routes.length > 0">当前节点IP对应的线路。</p>
|
<p class="comment" v-if="routes.length > 0">当前节点IP对应的线路。</p>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -31,12 +31,50 @@
|
|||||||
<td>密钥ID *</td>
|
<td>密钥ID *</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="paramId" maxlength="100"/>
|
<input type="text" name="paramId" maxlength="100"/>
|
||||||
|
<p class="comment">获取方法参考:<a href="https://docs.dnspod.cn/account/5f2d466de8320f1a740d9ff3/" target="_blank">文档</a> </p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>密钥Token *</td>
|
<td>密钥Token *</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="paramToken" maxlength="100"/>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
this.createProvider = function () {
|
this.createProvider = function () {
|
||||||
teaweb.popup(Tea.url(".createPopup"), {
|
teaweb.popup(Tea.url(".createPopup"), {
|
||||||
height: "26em",
|
height: "28em",
|
||||||
callback: function () {
|
callback: function () {
|
||||||
teaweb.success("保存成功", function () {
|
teaweb.success("保存成功", function () {
|
||||||
teaweb.reload()
|
teaweb.reload()
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<td>服务商</td>
|
<td>服务商</td>
|
||||||
<td>{{provider.typeName}}</td>
|
<td>{{provider.typeName}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<!-- DNSPod -->
|
<!-- DNSPod -->
|
||||||
<tbody v-if="provider.type == 'dnspod'">
|
<tbody v-if="provider.type == 'dnspod'">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -29,6 +30,18 @@
|
|||||||
<td>{{provider.apiParams.token}}</td>
|
<td>{{provider.apiParams.token}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</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>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
this.updateProvider = function (providerId) {
|
this.updateProvider = function (providerId) {
|
||||||
teaweb.popup(Tea.url(".updatePopup?providerId=" + providerId), {
|
teaweb.popup(Tea.url(".updatePopup?providerId=" + providerId), {
|
||||||
height: "26em",
|
height: "28em",
|
||||||
callback: function () {
|
callback: function () {
|
||||||
teaweb.success("保存成功", function () {
|
teaweb.success("保存成功", function () {
|
||||||
teaweb.reload()
|
teaweb.reload()
|
||||||
@@ -65,7 +65,6 @@ Tea.context(function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.done(function () {
|
.done(function () {
|
||||||
domain.isSyncing = false
|
|
||||||
Vue.set(that.domains, index, domain)
|
Vue.set(that.domains, index, domain)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -29,13 +29,33 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>密钥ID *</td>
|
<td>密钥ID *</td>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>密钥Token *</td>
|
<td>密钥Token *</td>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user