mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	WAF规则集中增加是否忽略局域网IP
This commit is contained in:
		@@ -99,6 +99,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
 | 
			
		||||
	config.Description = set.Description
 | 
			
		||||
	config.Code = set.Code
 | 
			
		||||
	config.Connector = set.Connector
 | 
			
		||||
	config.IgnoreLocal = set.IgnoreLocal == 1
 | 
			
		||||
 | 
			
		||||
	if IsNotNull(set.Rules) {
 | 
			
		||||
		ruleRefs := []*firewallconfigs.HTTPFirewallRuleRef{}
 | 
			
		||||
@@ -139,6 +140,7 @@ func (this *HTTPFirewallRuleSetDAO) CreateOrUpdateSetFromConfig(tx *dbs.Tx, setC
 | 
			
		||||
	op.Name = setConfig.Name
 | 
			
		||||
	op.Description = setConfig.Description
 | 
			
		||||
	op.Connector = setConfig.Connector
 | 
			
		||||
	op.IgnoreLocal = setConfig.IgnoreLocal
 | 
			
		||||
 | 
			
		||||
	if len(setConfig.Actions) == 0 {
 | 
			
		||||
		op.Actions = "[]"
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ type HTTPFirewallRuleSet struct {
 | 
			
		||||
	Action        string `field:"action"`        // 执行的动作(过期)
 | 
			
		||||
	ActionOptions string `field:"actionOptions"` // 动作的选项(过期)
 | 
			
		||||
	Actions       string `field:"actions"`       // 一组动作
 | 
			
		||||
	IgnoreLocal   uint8  `field:"ignoreLocal"`   // 忽略局域网请求
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type HTTPFirewallRuleSetOperator struct {
 | 
			
		||||
@@ -33,6 +34,7 @@ type HTTPFirewallRuleSetOperator struct {
 | 
			
		||||
	Action        interface{} // 执行的动作(过期)
 | 
			
		||||
	ActionOptions interface{} // 动作的选项(过期)
 | 
			
		||||
	Actions       interface{} // 一组动作
 | 
			
		||||
	IgnoreLocal   interface{} // 忽略局域网请求
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewHTTPFirewallRuleSetOperator() *HTTPFirewallRuleSetOperator {
 | 
			
		||||
 
 | 
			
		||||
@@ -8,12 +8,12 @@ import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// 规则集相关服务
 | 
			
		||||
// HTTPFirewallRuleSetService 规则集相关服务
 | 
			
		||||
type HTTPFirewallRuleSetService struct {
 | 
			
		||||
	BaseService
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 根据配置创建规则集
 | 
			
		||||
// CreateOrUpdateHTTPFirewallRuleSetFromConfig 根据配置创建规则集
 | 
			
		||||
func (this *HTTPFirewallRuleSetService) CreateOrUpdateHTTPFirewallRuleSetFromConfig(ctx context.Context, req *pb.CreateOrUpdateHTTPFirewallRuleSetFromConfigRequest) (*pb.CreateOrUpdateHTTPFirewallRuleSetFromConfigResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
 | 
			
		||||
@@ -44,7 +44,7 @@ func (this *HTTPFirewallRuleSetService) CreateOrUpdateHTTPFirewallRuleSetFromCon
 | 
			
		||||
	return &pb.CreateOrUpdateHTTPFirewallRuleSetFromConfigResponse{FirewallRuleSetId: setId}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 修改是否开启
 | 
			
		||||
// UpdateHTTPFirewallRuleSetIsOn 修改是否开启
 | 
			
		||||
func (this *HTTPFirewallRuleSetService) UpdateHTTPFirewallRuleSetIsOn(ctx context.Context, req *pb.UpdateHTTPFirewallRuleSetIsOnRequest) (*pb.RPCSuccess, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
 | 
			
		||||
@@ -69,7 +69,7 @@ func (this *HTTPFirewallRuleSetService) UpdateHTTPFirewallRuleSetIsOn(ctx contex
 | 
			
		||||
	return this.Success()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 查找规则集配置
 | 
			
		||||
// FindEnabledHTTPFirewallRuleSetConfig 查找规则集配置
 | 
			
		||||
func (this *HTTPFirewallRuleSetService) FindEnabledHTTPFirewallRuleSetConfig(ctx context.Context, req *pb.FindEnabledHTTPFirewallRuleSetConfigRequest) (*pb.FindEnabledHTTPFirewallRuleSetConfigResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
 | 
			
		||||
@@ -100,7 +100,7 @@ func (this *HTTPFirewallRuleSetService) FindEnabledHTTPFirewallRuleSetConfig(ctx
 | 
			
		||||
	return &pb.FindEnabledHTTPFirewallRuleSetConfigResponse{FirewallRuleSetJSON: configJSON}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 查找规则集
 | 
			
		||||
// FindEnabledHTTPFirewallRuleSet 查找规则集
 | 
			
		||||
func (this *HTTPFirewallRuleSetService) FindEnabledHTTPFirewallRuleSet(ctx context.Context, req *pb.FindEnabledHTTPFirewallRuleSetRequest) (*pb.FindEnabledHTTPFirewallRuleSetResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user