mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 10:00:24 +08:00
节点设置中增加“通过IP名单”选项
This commit is contained in:
@@ -164,6 +164,7 @@ func (this *NodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, clusterI
|
|||||||
op.GroupId = groupId
|
op.GroupId = groupId
|
||||||
op.RegionId = regionId
|
op.RegionId = regionId
|
||||||
op.IsOn = 1
|
op.IsOn = 1
|
||||||
|
op.EnableIPLists = 1
|
||||||
op.State = NodeStateEnabled
|
op.State = NodeStateEnabled
|
||||||
err = this.Save(tx, op)
|
err = this.Save(tx, op)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -187,7 +188,7 @@ func (this *NodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, clusterI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateNode 修改节点
|
// 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 {
|
if nodeId <= 0 {
|
||||||
return errors.New("invalid nodeId")
|
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.LnAddrs = lnAddrsJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
op.EnableIPLists = enableIPLists
|
||||||
|
|
||||||
err = this.Save(tx, op)
|
err = this.Save(tx, op)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -946,17 +949,18 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, cacheMap *utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
var config = &nodeconfigs.NodeConfig{
|
var config = &nodeconfigs.NodeConfig{
|
||||||
Id: int64(node.Id),
|
Id: int64(node.Id),
|
||||||
NodeId: node.UniqueId,
|
NodeId: node.UniqueId,
|
||||||
Secret: node.Secret,
|
Secret: node.Secret,
|
||||||
IsOn: node.IsOn,
|
IsOn: node.IsOn,
|
||||||
Servers: nil,
|
Servers: nil,
|
||||||
Version: int64(node.Version),
|
Version: int64(node.Version),
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
MaxCPU: types.Int32(node.MaxCPU),
|
MaxCPU: types.Int32(node.MaxCPU),
|
||||||
RegionId: int64(node.RegionId),
|
RegionId: int64(node.RegionId),
|
||||||
Level: types.Int32(node.Level),
|
Level: types.Int32(node.Level),
|
||||||
GroupId: int64(node.GroupId),
|
GroupId: int64(node.GroupId),
|
||||||
|
EnableIPLists: node.EnableIPLists,
|
||||||
}
|
}
|
||||||
|
|
||||||
// API节点IP
|
// API节点IP
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ type Node struct {
|
|||||||
MaxCacheMemoryCapacity dbs.JSON `field:"maxCacheMemoryCapacity"` // 内存缓存容量
|
MaxCacheMemoryCapacity dbs.JSON `field:"maxCacheMemoryCapacity"` // 内存缓存容量
|
||||||
CacheDiskDir string `field:"cacheDiskDir"` // 缓存目录
|
CacheDiskDir string `field:"cacheDiskDir"` // 缓存目录
|
||||||
DnsResolver dbs.JSON `field:"dnsResolver"` // DNS解析器
|
DnsResolver dbs.JSON `field:"dnsResolver"` // DNS解析器
|
||||||
|
EnableIPLists bool `field:"enableIPLists"` // 启用IP名单
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeOperator struct {
|
type NodeOperator struct {
|
||||||
@@ -79,6 +80,7 @@ type NodeOperator struct {
|
|||||||
MaxCacheMemoryCapacity any // 内存缓存容量
|
MaxCacheMemoryCapacity any // 内存缓存容量
|
||||||
CacheDiskDir any // 缓存目录
|
CacheDiskDir any // 缓存目录
|
||||||
DnsResolver any // DNS解析器
|
DnsResolver any // DNS解析器
|
||||||
|
EnableIPLists any // 启用IP名单
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNodeOperator() *NodeOperator {
|
func NewNodeOperator() *NodeOperator {
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ func (this *NodeService) UpdateNode(ctx context.Context, req *pb.UpdateNodeReque
|
|||||||
|
|
||||||
var tx = this.NullTx()
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -676,6 +676,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
|
|||||||
Level: int32(node.Level),
|
Level: int32(node.Level),
|
||||||
LnAddrs: node.DecodeLnAddrs(),
|
LnAddrs: node.DecodeLnAddrs(),
|
||||||
DnsRoutes: pbRoutes,
|
DnsRoutes: pbRoutes,
|
||||||
|
EnableIPLists: node.EnableIPLists,
|
||||||
}}, nil
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user