mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 13:10:24 +08:00 
			
		
		
		
	5秒盾增加匹配条件
This commit is contained in:
		@@ -2,7 +2,9 @@
 | 
			
		||||
 | 
			
		||||
package serverconfigs
 | 
			
		||||
 | 
			
		||||
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// UAMConfig UAM配置
 | 
			
		||||
type UAMConfig struct {
 | 
			
		||||
@@ -13,6 +15,7 @@ type UAMConfig struct {
 | 
			
		||||
	OnlyURLPatterns   []*shared.URLPattern           `yaml:"onlyURLPatterns" json:"onlyURLPatterns"`     // 仅限的URL
 | 
			
		||||
	ExceptURLPatterns []*shared.URLPattern           `yaml:"exceptURLPatterns" json:"exceptURLPatterns"` // 排除的URL
 | 
			
		||||
	MinQPSPerIP       int                            `yaml:"minQPSPerIP" json:"minQPSPerIP"`             // 启用要求的单IP最低平均QPS
 | 
			
		||||
	Conds             *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"`                         // 匹配条件
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewUAMConfig() *UAMConfig {
 | 
			
		||||
@@ -38,6 +41,14 @@ func (this *UAMConfig) Init() error {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// conds
 | 
			
		||||
	if this.Conds != nil {
 | 
			
		||||
		err := this.Conds.Init()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -62,3 +73,10 @@ func (this *UAMConfig) MatchURL(url string) bool {
 | 
			
		||||
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *UAMConfig) MatchRequest(formatter func(s string) string) bool {
 | 
			
		||||
	if this.Conds == nil {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	return this.Conds.MatchRequest(formatter)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user