节点设置中增加“通过IP名单”选项

This commit is contained in:
GoEdgeLab
2022-10-26 10:41:53 +08:00
parent 282b3e3945
commit 67da380cba
3 changed files with 20 additions and 13 deletions

View File

@@ -164,6 +164,7 @@ func (this *NodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, clusterI
op.GroupId = groupId
op.RegionId = regionId
op.IsOn = 1
op.EnableIPLists = 1
op.State = NodeStateEnabled
err = this.Save(tx, op)
if err != nil {
@@ -187,7 +188,7 @@ func (this *NodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, clusterI
}
// UpdateNode 修改节点
func (this *NodeDAO) UpdateNode(tx *dbs.Tx, nodeId int64, name string, clusterId int64, secondaryClusterIds []int64, groupId int64, regionId int64, isOn bool, level int, lnAddrs []string) error {
func (this *NodeDAO) UpdateNode(tx *dbs.Tx, nodeId int64, name string, clusterId int64, secondaryClusterIds []int64, groupId int64, regionId int64, isOn bool, level int, lnAddrs []string, enableIPLists bool) error {
if nodeId <= 0 {
return errors.New("invalid nodeId")
}
@@ -247,6 +248,8 @@ func (this *NodeDAO) UpdateNode(tx *dbs.Tx, nodeId int64, name string, clusterId
op.LnAddrs = lnAddrsJSON
}
op.EnableIPLists = enableIPLists
err = this.Save(tx, op)
if err != nil {
return err
@@ -946,17 +949,18 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, cacheMap *utils
}
var config = &nodeconfigs.NodeConfig{
Id: int64(node.Id),
NodeId: node.UniqueId,
Secret: node.Secret,
IsOn: node.IsOn,
Servers: nil,
Version: int64(node.Version),
Name: node.Name,
MaxCPU: types.Int32(node.MaxCPU),
RegionId: int64(node.RegionId),
Level: types.Int32(node.Level),
GroupId: int64(node.GroupId),
Id: int64(node.Id),
NodeId: node.UniqueId,
Secret: node.Secret,
IsOn: node.IsOn,
Servers: nil,
Version: int64(node.Version),
Name: node.Name,
MaxCPU: types.Int32(node.MaxCPU),
RegionId: int64(node.RegionId),
Level: types.Int32(node.Level),
GroupId: int64(node.GroupId),
EnableIPLists: node.EnableIPLists,
}
// API节点IP

View File

@@ -40,6 +40,7 @@ type Node struct {
MaxCacheMemoryCapacity dbs.JSON `field:"maxCacheMemoryCapacity"` // 内存缓存容量
CacheDiskDir string `field:"cacheDiskDir"` // 缓存目录
DnsResolver dbs.JSON `field:"dnsResolver"` // DNS解析器
EnableIPLists bool `field:"enableIPLists"` // 启用IP名单
}
type NodeOperator struct {
@@ -79,6 +80,7 @@ type NodeOperator struct {
MaxCacheMemoryCapacity any // 内存缓存容量
CacheDiskDir any // 缓存目录
DnsResolver any // DNS解析器
EnableIPLists any // 启用IP名单
}
func NewNodeOperator() *NodeOperator {

View File

@@ -476,7 +476,7 @@ func (this *NodeService) UpdateNode(ctx context.Context, req *pb.UpdateNodeReque
var tx = this.NullTx()
err = models.SharedNodeDAO.UpdateNode(tx, req.NodeId, req.Name, req.NodeClusterId, req.SecondaryNodeClusterIds, req.NodeGroupId, req.NodeRegionId, req.IsOn, int(req.Level), req.LnAddrs)
err = models.SharedNodeDAO.UpdateNode(tx, req.NodeId, req.Name, req.NodeClusterId, req.SecondaryNodeClusterIds, req.NodeGroupId, req.NodeRegionId, req.IsOn, int(req.Level), req.LnAddrs, req.EnableIPLists)
if err != nil {
return nil, err
}
@@ -676,6 +676,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
Level: int32(node.Level),
LnAddrs: node.DecodeLnAddrs(),
DnsRoutes: pbRoutes,
EnableIPLists: node.EnableIPLists,
}}, nil
}