mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	waf/ip名单有变更立即发送通知
This commit is contained in:
		@@ -29,7 +29,7 @@ function build() {
 | 
				
			|||||||
	fi
 | 
						fi
 | 
				
			||||||
	cd $ROOT"/../../EdgeNode/build"
 | 
						cd $ROOT"/../../EdgeNode/build"
 | 
				
			||||||
	echo "=============================="
 | 
						echo "=============================="
 | 
				
			||||||
	architects=("amd64" "386" "arm64" "arm64be" "mips64" "mips64le")
 | 
						architects=("amd64" "386" "arm64" "mips64" "mips64le")
 | 
				
			||||||
	for arch in "${architects[@]}"; do
 | 
						for arch in "${architects[@]}"; do
 | 
				
			||||||
		./build.sh linux $arch
 | 
							./build.sh linux $arch
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,9 +46,15 @@ func (this *IPItemDAO) EnableIPItem(id int64) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// 禁用条目
 | 
					// 禁用条目
 | 
				
			||||||
func (this *IPItemDAO) DisableIPItem(id int64) error {
 | 
					func (this *IPItemDAO) DisableIPItem(id int64) error {
 | 
				
			||||||
	_, err := this.Query().
 | 
						version, err := SharedIPListDAO.IncreaseVersion()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = this.Query().
 | 
				
			||||||
		Pk(id).
 | 
							Pk(id).
 | 
				
			||||||
		Set("state", IPItemStateDisabled).
 | 
							Set("state", IPItemStateDisabled).
 | 
				
			||||||
 | 
							Set("version", version).
 | 
				
			||||||
		Update()
 | 
							Update()
 | 
				
			||||||
	return err
 | 
						return err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ type IPList struct {
 | 
				
			|||||||
	State     uint8  `field:"state"`     // 状态
 | 
						State     uint8  `field:"state"`     // 状态
 | 
				
			||||||
	CreatedAt uint64 `field:"createdAt"` // 创建时间
 | 
						CreatedAt uint64 `field:"createdAt"` // 创建时间
 | 
				
			||||||
	Timeout   string `field:"timeout"`   // 默认超时时间
 | 
						Timeout   string `field:"timeout"`   // 默认超时时间
 | 
				
			||||||
 | 
						Actions   string `field:"actions"`   // IP触发的动作
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type IPListOperator struct {
 | 
					type IPListOperator struct {
 | 
				
			||||||
@@ -25,6 +26,7 @@ type IPListOperator struct {
 | 
				
			|||||||
	State     interface{} // 状态
 | 
						State     interface{} // 状态
 | 
				
			||||||
	CreatedAt interface{} // 创建时间
 | 
						CreatedAt interface{} // 创建时间
 | 
				
			||||||
	Timeout   interface{} // 默认超时时间
 | 
						Timeout   interface{} // 默认超时时间
 | 
				
			||||||
 | 
						Actions   interface{} // IP触发的动作
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func NewIPListOperator() *IPListOperator {
 | 
					func NewIPListOperator() *IPListOperator {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,9 @@ func (this *IPItemService) CreateIPItem(ctx context.Context, req *pb.CreateIPIte
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return &pb.CreateIPItemResponse{IpItemId: itemId}, nil
 | 
						return &pb.CreateIPItemResponse{IpItemId: itemId}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -741,6 +741,9 @@ func (this *ServerService) FindAllEnabledServersWithCachePolicyId(ctx context.Co
 | 
				
			|||||||
			Name: server.Name,
 | 
								Name: server.Name,
 | 
				
			||||||
			IsOn: server.IsOn == 1,
 | 
								IsOn: server.IsOn == 1,
 | 
				
			||||||
			Type: server.Type,
 | 
								Type: server.Type,
 | 
				
			||||||
 | 
								Cluster: &pb.NodeCluster{
 | 
				
			||||||
 | 
									Id: int64(server.ClusterId),
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return &pb.FindAllEnabledServersWithCachePolicyIdResponse{Servers: result}, nil
 | 
						return &pb.FindAllEnabledServersWithCachePolicyIdResponse{Servers: result}, nil
 | 
				
			||||||
@@ -770,6 +773,40 @@ func (this *ServerService) CountAllEnabledServersWithHTTPFirewallPolicyId(ctx co
 | 
				
			|||||||
	return &pb.CountAllEnabledServersWithHTTPFirewallPolicyIdResponse{Count: countServers}, nil
 | 
						return &pb.CountAllEnabledServersWithHTTPFirewallPolicyIdResponse{Count: countServers}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 查找使用某个WAF策略的所有服务
 | 
				
			||||||
 | 
					func (this *ServerService) FindAllEnabledServersWithHTTPFirewallPolicyId(ctx context.Context, req *pb.FindAllEnabledServersWithHTTPFirewallPolicyIdRequest) (*pb.FindAllEnabledServersWithHTTPFirewallPolicyIdResponse, error) {
 | 
				
			||||||
 | 
						// 校验请求
 | 
				
			||||||
 | 
						_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						webIds, err := models.SharedHTTPWebDAO.FindAllWebIdsWithHTTPFirewallPolicyId(req.FirewallPolicyId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if len(webIds) == 0 {
 | 
				
			||||||
 | 
							return &pb.FindAllEnabledServersWithHTTPFirewallPolicyIdResponse{Servers: nil}, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						servers, err := models.SharedServerDAO.FindAllEnabledServersWithWebIds(webIds)
 | 
				
			||||||
 | 
						result := []*pb.Server{}
 | 
				
			||||||
 | 
						for _, server := range servers {
 | 
				
			||||||
 | 
							result = append(result, &pb.Server{
 | 
				
			||||||
 | 
								Id:   int64(server.Id),
 | 
				
			||||||
 | 
								Name: server.Name,
 | 
				
			||||||
 | 
								IsOn: server.IsOn == 1,
 | 
				
			||||||
 | 
								Type: server.Type,
 | 
				
			||||||
 | 
								Cluster: &pb.NodeCluster{
 | 
				
			||||||
 | 
									Id: int64(server.ClusterId),
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return &pb.FindAllEnabledServersWithHTTPFirewallPolicyIdResponse{Servers: result}, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 计算运行在某个集群上的所有服务数量
 | 
					// 计算运行在某个集群上的所有服务数量
 | 
				
			||||||
func (this *ServerService) CountAllEnabledServersWithNodeClusterId(ctx context.Context, req *pb.CountAllEnabledServersWithNodeClusterIdRequest) (*pb.CountAllEnabledServersWithNodeClusterIdResponse, error) {
 | 
					func (this *ServerService) CountAllEnabledServersWithNodeClusterId(ctx context.Context, req *pb.CountAllEnabledServersWithNodeClusterIdRequest) (*pb.CountAllEnabledServersWithNodeClusterIdResponse, error) {
 | 
				
			||||||
	// 校验请求
 | 
						// 校验请求
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user