减少一些不必要的访问统计

This commit is contained in:
GoEdgeLab
2023-11-19 09:10:37 +08:00
parent 0b52e3319b
commit 6d76bf3433
4 changed files with 16 additions and 0 deletions

View File

@@ -478,3 +478,10 @@ func (this *HTTPRequest) WAFMaxRequestSize() int64 {
func (this *HTTPRequest) DisableAccessLog() {
this.disableLog = true
}
// DisableStat 停用统计
func (this *HTTPRequest) DisableStat() {
if this.web != nil {
this.web.StatRef = nil
}
}

View File

@@ -46,4 +46,7 @@ type Request interface {
// DisableAccessLog 在当前请求中不使用访问日志
DisableAccessLog()
// DisableStat 在当前请求中停用统计
DisableStat()
}

View File

@@ -85,6 +85,10 @@ func (this *TestRequest) DisableAccessLog() {
}
func (this *TestRequest) DisableStat() {
}
func (this *TestRequest) ProcessResponseHeaders(headers http.Header, status int) {
}

View File

@@ -251,6 +251,7 @@ func (this *WAF) MatchRequest(req requests.Request, writer http.ResponseWriter,
var rawPath = req.WAFRaw().URL.Path
if rawPath == CaptchaPath {
req.DisableAccessLog()
req.DisableStat()
captchaValidator.Run(req, writer, defaultCaptchaType)
return
}
@@ -258,6 +259,7 @@ func (this *WAF) MatchRequest(req requests.Request, writer http.ResponseWriter,
// Get 302验证
if rawPath == Get302Path {
req.DisableAccessLog()
req.DisableStat()
get302Validator.Run(req, writer)
return
}