节点增加DNS解析库类型设置

This commit is contained in:
GoEdgeLab
2022-05-04 16:41:28 +08:00
parent b2f7efe968
commit 4aa841ee5e
8 changed files with 174 additions and 13 deletions

View File

@@ -4,7 +4,6 @@ package nodeutils
import (
"errors"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
@@ -72,15 +71,7 @@ func InitNodeInfo(parentAction *actionutils.ParentAction, nodeId int64) (*pb.Nod
(node.MaxCacheMemoryCapacity != nil && node.MaxCacheMemoryCapacity.Count > 0),
},
}
if teaconst.IsPlus {
menuItems = append(menuItems, []maps.Map{
{
"name": "阈值设置",
"url": prefix + "/settings/thresholds?" + query,
"isActive": menuItem == "threshold",
},
}...)
}
menuItems = filterMenuItems(menuItems, menuItem, prefix, query)
menuItems = append(menuItems, []maps.Map{
{
"name": "SSH设置",

View File

@@ -0,0 +1,13 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
//go:build !plus
// +build !plus
package nodeutils
import (
"github.com/iwind/TeaGo/maps"
)
func filterMenuItems(menuItems []maps.Map, menuItem string, prefix string, query string) []maps.Map {
return menuItems
}

View File

@@ -3,8 +3,10 @@
package system
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
@@ -32,6 +34,22 @@ func (this *IndexAction) RunGet(params struct {
var nodeMap = this.Data["node"].(maps.Map)
nodeMap["maxCPU"] = node.MaxCPU
// DNS
dnsResolverResp, err := this.RPC().NodeRPC().FindNodeDNSResolver(this.AdminContext(), &pb.FindNodeDNSResolverRequest{NodeId: params.NodeId})
if err != nil {
this.ErrorPage(err)
return
}
var dnsResolverConfig = nodeconfigs.DefaultDNSResolverConfig()
if len(dnsResolverResp.DnsResolverJSON) > 0 {
err = json.Unmarshal(dnsResolverResp.DnsResolverJSON, dnsResolverConfig)
if err != nil {
this.ErrorPage(err)
return
}
}
this.Data["dnsResolverConfig"] = dnsResolverConfig
this.Show()
}
@@ -39,6 +57,8 @@ func (this *IndexAction) RunPost(params struct {
NodeId int64
MaxCPU int32
DnsResolverJSON []byte
Must *actions.Must
CSRF *actionutils.CSRF
}) {
@@ -57,5 +77,26 @@ func (this *IndexAction) RunPost(params struct {
return
}
var dnsResolverConfig = nodeconfigs.DefaultDNSResolverConfig()
err = json.Unmarshal(params.DnsResolverJSON, dnsResolverConfig)
if err != nil {
this.ErrorPage(err)
return
}
err = dnsResolverConfig.Init()
if err != nil {
this.Fail("校验DNS解析配置失败" + err.Error())
}
_, err = this.RPC().NodeRPC().UpdateNodeDNSResolver(this.AdminContext(), &pb.UpdateNodeDNSResolverRequest{
NodeId: params.NodeId,
DnsResolverJSON: params.DnsResolverJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}