diff --git a/internal/web/actions/default/clusters/cluster/nodes.go b/internal/web/actions/default/clusters/cluster/nodes.go index 9e884f4b..4aa77425 100644 --- a/internal/web/actions/default/clusters/cluster/nodes.go +++ b/internal/web/actions/default/clusters/cluster/nodes.go @@ -129,6 +129,8 @@ func (this *NodesAction) RunGet(params struct { "name": addr.Name, "ip": addr.Ip, "canAccess": addr.CanAccess, + "isUp": addr.IsUp, + "isOn": addr.IsOn, }) } diff --git a/internal/web/actions/default/clusters/index.go b/internal/web/actions/default/clusters/index.go index f639aa21..09842511 100644 --- a/internal/web/actions/default/clusters/index.go +++ b/internal/web/actions/default/clusters/index.go @@ -208,6 +208,8 @@ func (this *IndexAction) searchNodes(keyword string) { "name": addr.Name, "ip": addr.Ip, "canAccess": addr.CanAccess, + "isOn": addr.IsOn, + "isUp": addr.IsUp, }) } diff --git a/internal/web/actions/default/ns/clusters/cluster/index.go b/internal/web/actions/default/ns/clusters/cluster/index.go index 16ab3a06..e4f90f7e 100644 --- a/internal/web/actions/default/ns/clusters/cluster/index.go +++ b/internal/web/actions/default/ns/clusters/cluster/index.go @@ -96,6 +96,8 @@ func (this *IndexAction) RunGet(params struct { "name": addr.Name, "ip": addr.Ip, "canAccess": addr.CanAccess, + "isOn": addr.IsOn, + "isUp": addr.IsUp, }) } diff --git a/internal/web/actions/default/ns/clusters/cluster/node/index.go b/internal/web/actions/default/ns/clusters/cluster/node/index.go index 632a719a..93e72a0a 100644 --- a/internal/web/actions/default/ns/clusters/cluster/node/index.go +++ b/internal/web/actions/default/ns/clusters/cluster/node/index.go @@ -71,6 +71,8 @@ func (this *IndexAction) RunGet(params struct { "name": addr.Name, "ip": addr.Ip, "canAccess": addr.CanAccess, + "isOn": addr.IsOn, + "isUp": addr.IsUp, }) } diff --git a/internal/web/actions/default/ns/clusters/cluster/node/update.go b/internal/web/actions/default/ns/clusters/cluster/node/update.go index 1a3a6a47..e1b3addc 100644 --- a/internal/web/actions/default/ns/clusters/cluster/node/update.go +++ b/internal/web/actions/default/ns/clusters/cluster/node/update.go @@ -61,6 +61,8 @@ func (this *UpdateAction) RunGet(params struct { "name": addr.Name, "ip": addr.Ip, "canAccess": addr.CanAccess, + "isOn": addr.IsOn, + "isUp": addr.IsUp, }) } diff --git a/internal/web/actions/default/ns/clusters/cluster/settings/accessLog/index.go b/internal/web/actions/default/ns/clusters/cluster/settings/accessLog/index.go index b8d96a57..a8651841 100644 --- a/internal/web/actions/default/ns/clusters/cluster/settings/accessLog/index.go +++ b/internal/web/actions/default/ns/clusters/cluster/settings/accessLog/index.go @@ -1,6 +1,6 @@ // Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. -package cluster +package accessLog import ( "encoding/json" diff --git a/internal/web/actions/default/ns/clusters/cluster/settings/accessLog/init.go b/internal/web/actions/default/ns/clusters/cluster/settings/accessLog/init.go index 40468e95..90119ad7 100644 --- a/internal/web/actions/default/ns/clusters/cluster/settings/accessLog/init.go +++ b/internal/web/actions/default/ns/clusters/cluster/settings/accessLog/init.go @@ -1,4 +1,4 @@ -package cluster +package accessLog import ( "github.com/TeaOSLab/EdgeAdmin/internal/configloaders" diff --git a/internal/web/actions/default/ns/clusters/cluster/settings/recursion/index.go b/internal/web/actions/default/ns/clusters/cluster/settings/recursion/index.go new file mode 100644 index 00000000..845d565b --- /dev/null +++ b/internal/web/actions/default/ns/clusters/cluster/settings/recursion/index.go @@ -0,0 +1,68 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package recursion + +import ( + "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/iwind/TeaGo/actions" +) + +type IndexAction struct { + actionutils.ParentAction +} + +func (this *IndexAction) Init() { + this.Nav("", "setting", "") + this.SecondMenu("recursion") +} + +func (this *IndexAction) RunGet(params struct { + ClusterId int64 +}) { + this.Data["clusterId"] = params.ClusterId + + resp, err := this.RPC().NSClusterRPC().FindNSClusterRecursionConfig(this.AdminContext(), &pb.FindNSClusterRecursionConfigRequest{NsClusterId: params.ClusterId}) + if err != nil { + this.ErrorPage(err) + return + } + + var config = &dnsconfigs.RecursionConfig{} + if len(resp.RecursionJSON) > 0 { + err = json.Unmarshal(resp.RecursionJSON, config) + if err != nil { + this.ErrorPage(err) + return + } + } else { + config.UseLocalHosts = true + } + this.Data["config"] = config + + this.Show() +} + +func (this *IndexAction) RunPost(params struct { + ClusterId int64 + RecursionJSON []byte + + Must *actions.Must + CSRF *actionutils.CSRF +}) { + defer this.CreateLogInfo("修改DNS集群 %d 的递归DNS设置", params.ClusterId) + + // TODO 校验域名 + + _, err := this.RPC().NSClusterRPC().UpdateNSClusterRecursionConfig(this.AdminContext(), &pb.UpdateNSClusterRecursionConfigRequest{ + NsClusterId: params.ClusterId, + RecursionJSON: params.RecursionJSON, + }) + if err != nil { + this.ErrorPage(err) + return + } + this.Success() +} diff --git a/internal/web/actions/default/ns/clusters/cluster/settings/recursion/init.go b/internal/web/actions/default/ns/clusters/cluster/settings/recursion/init.go new file mode 100644 index 00000000..854ec62b --- /dev/null +++ b/internal/web/actions/default/ns/clusters/cluster/settings/recursion/init.go @@ -0,0 +1,21 @@ +package recursion + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/configloaders" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/clusterutils" + "github.com/TeaOSLab/EdgeAdmin/internal/web/helpers" + "github.com/iwind/TeaGo" +) + +func init() { + TeaGo.BeforeStart(func(server *TeaGo.Server) { + server. + Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeNS)). + Helper(new(clusterutils.ClusterHelper)). + Data("teaMenu", "ns"). + Data("teaSubMenu", "cluster"). + Prefix("/ns/clusters/cluster/settings/recursion"). + GetPost("", new(IndexAction)). + EndAll() + }) +} diff --git a/internal/web/actions/default/ns/clusters/clusterutils/cluster_helper.go b/internal/web/actions/default/ns/clusters/clusterutils/cluster_helper.go index 87b28537..3ec9ff3f 100644 --- a/internal/web/actions/default/ns/clusters/clusterutils/cluster_helper.go +++ b/internal/web/actions/default/ns/clusters/clusterutils/cluster_helper.go @@ -78,15 +78,21 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext // 设置菜单 func (this *ClusterHelper) createSettingMenu(cluster *pb.NSCluster, selectedItem string) (items []maps.Map) { clusterId := numberutils.FormatInt64(cluster.Id) - items = append(items, maps.Map{ - "name": "基础设置", - "url": "/ns/clusters/cluster/settings?clusterId=" + clusterId, - "isActive": selectedItem == "basic", - }) - items = append(items, maps.Map{ - "name": "访问日志", - "url": "/ns/clusters/cluster/settings/accessLog?clusterId=" + clusterId, - "isActive": selectedItem == "accessLog", - }) - return + return []maps.Map{ + { + "name": "基础设置", + "url": "/ns/clusters/cluster/settings?clusterId=" + clusterId, + "isActive": selectedItem == "basic", + }, + { + "name": "访问日志", + "url": "/ns/clusters/cluster/settings/accessLog?clusterId=" + clusterId, + "isActive": selectedItem == "accessLog", + }, + { + "name": "递归DNS", + "url": "/ns/clusters/cluster/settings/recursion?clusterId=" + clusterId, + "isActive": selectedItem == "recursion", + }, + } } diff --git a/internal/web/import.go b/internal/web/import.go index 6a4797b8..712a7a5c 100644 --- a/internal/web/import.go +++ b/internal/web/import.go @@ -48,6 +48,7 @@ import ( _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster/settings" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster/settings/accessLog" + _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster/settings/recursion" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/logs" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/routes" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/settings/accesslogs" diff --git a/web/public/js/components/ns/ns-access-log-box.js b/web/public/js/components/ns/ns-access-log-box.js index a5474428..bc56f5ac 100644 --- a/web/public/js/components/ns/ns-access-log-box.js +++ b/web/public/js/components/ns/ns-access-log-box.js @@ -32,12 +32,13 @@ Vue.component("ns-access-log-box", { this.$refs.box.parentNode.style.cssText = "" } }, - template: `
| 是否启用 | +
+
+
+
+
+ 启用后,如果找不到某个域名的解析记录,则向上一级DNS查找。 + |
+
| 从节点本机读取 上级DNS主机 |
+
+
+
+
+
+ 选中后,节点会试图从 |
+
| 上级DNS主机地址 * | +
+
+
+
+
+
+ |
+
| 允许的域名 | +支持星号通配符,比如 |
+
| 不允许的域名 | +
+ 支持星号通配符,比如 |
+