mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	WAF策略增加显示页面动作默认设置
This commit is contained in:
		@@ -10,11 +10,21 @@ import (
 | 
				
			|||||||
type PageAction struct {
 | 
					type PageAction struct {
 | 
				
			||||||
	BaseAction
 | 
						BaseAction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Status int    `yaml:"status" json:"status"`
 | 
						UseDefault bool   `yaml:"useDefault" json:"useDefault"`
 | 
				
			||||||
	Body   string `yaml:"body" json:"body"`
 | 
						Status     int    `yaml:"status" json:"status"`
 | 
				
			||||||
 | 
						Body       string `yaml:"body" json:"body"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *PageAction) Init(waf *WAF) error {
 | 
					func (this *PageAction) Init(waf *WAF) error {
 | 
				
			||||||
 | 
						if waf.DefaultPageAction != nil {
 | 
				
			||||||
 | 
							if this.Status <= 0 || this.UseDefault {
 | 
				
			||||||
 | 
								this.Status = waf.DefaultPageAction.Status
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if len(this.Body) == 0 || this.UseDefault {
 | 
				
			||||||
 | 
								this.Body = waf.DefaultPageAction.Body
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.Status <= 0 {
 | 
						if this.Status <= 0 {
 | 
				
			||||||
		this.Status = http.StatusForbidden
 | 
							this.Status = http.StatusForbidden
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,6 +27,7 @@ type WAF struct {
 | 
				
			|||||||
	SYNFlood         *firewallconfigs.SYNFloodConfig `yaml:"synFlood" json:"synFlood"`
 | 
						SYNFlood         *firewallconfigs.SYNFloodConfig `yaml:"synFlood" json:"synFlood"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DefaultBlockAction   *BlockAction
 | 
						DefaultBlockAction   *BlockAction
 | 
				
			||||||
 | 
						DefaultPageAction    *PageAction
 | 
				
			||||||
	DefaultCaptchaAction *CaptchaAction
 | 
						DefaultCaptchaAction *CaptchaAction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hasInboundRules  bool
 | 
						hasInboundRules  bool
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -184,6 +184,14 @@ func (this *WAFManager) ConvertWAF(policy *firewallconfigs.HTTPFirewallPolicy) (
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// page action
 | 
				
			||||||
 | 
						if policy.PageOptions != nil {
 | 
				
			||||||
 | 
							w.DefaultPageAction = &PageAction{
 | 
				
			||||||
 | 
								Status: policy.PageOptions.Status,
 | 
				
			||||||
 | 
								Body:   policy.PageOptions.Body,
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// captcha action
 | 
						// captcha action
 | 
				
			||||||
	if policy.CaptchaOptions != nil {
 | 
						if policy.CaptchaOptions != nil {
 | 
				
			||||||
		w.DefaultCaptchaAction = &CaptchaAction{
 | 
							w.DefaultCaptchaAction = &CaptchaAction{
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user