From e723a64e68d9b643b19f7ff06b786582741d3797 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 1 Aug 2021 14:54:06 +0800 Subject: [PATCH] =?UTF-8?q?WAF=E7=AD=96=E7=95=A5=E5=92=8C=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E7=AD=96=E7=95=A5=E8=B7=9F=E9=9A=8F=E9=9B=86=E7=BE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_cache.go | 2 +- internal/nodes/http_request_waf.go | 8 ++++---- internal/nodes/http_writer.go | 2 +- internal/nodes/node.go | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/nodes/http_request_cache.go b/internal/nodes/http_request_cache.go index 25694c0..6c6e280 100644 --- a/internal/nodes/http_request_cache.go +++ b/internal/nodes/http_request_cache.go @@ -12,7 +12,7 @@ import ( // 读取缓存 func (this *HTTPRequest) doCacheRead() (shouldStop bool) { - cachePolicy := sharedNodeConfig.HTTPCachePolicy + cachePolicy := this.Server.HTTPCachePolicy if cachePolicy == nil || !cachePolicy.IsOn { return } diff --git a/internal/nodes/http_request_waf.go b/internal/nodes/http_request_waf.go index c6100c5..bab4d2c 100644 --- a/internal/nodes/http_request_waf.go +++ b/internal/nodes/http_request_waf.go @@ -28,8 +28,8 @@ func (this *HTTPRequest) doWAFRequest() (blocked bool) { } // 公用的防火墙设置 - if sharedNodeConfig.HTTPFirewallPolicy != nil { - blocked, breakChecking := this.checkWAFRequest(sharedNodeConfig.HTTPFirewallPolicy) + if this.Server.HTTPFirewallPolicy != nil && this.Server.HTTPFirewallPolicy.IsOn { + blocked, breakChecking := this.checkWAFRequest(this.Server.HTTPFirewallPolicy) if blocked { return true } @@ -201,8 +201,8 @@ func (this *HTTPRequest) doWAFResponse(resp *http.Response) (blocked bool) { } // 公用的防火墙设置 - if sharedNodeConfig.HTTPFirewallPolicy != nil { - blocked := this.checkWAFResponse(sharedNodeConfig.HTTPFirewallPolicy, resp) + if this.Server.HTTPFirewallPolicy != nil && this.Server.HTTPFirewallPolicy.IsOn { + blocked := this.checkWAFResponse(this.Server.HTTPFirewallPolicy, resp) if blocked { return true } diff --git a/internal/nodes/http_writer.go b/internal/nodes/http_writer.go index 352c2fc..d384c14 100644 --- a/internal/nodes/http_writer.go +++ b/internal/nodes/http_writer.go @@ -342,7 +342,7 @@ func (this *HTTPWriter) prepareCache(size int64) { return } - cachePolicy := sharedNodeConfig.HTTPCachePolicy + cachePolicy := this.req.Server.HTTPCachePolicy if cachePolicy == nil || !cachePolicy.IsOn { return } diff --git a/internal/nodes/node.go b/internal/nodes/node.go index a8d90d6..b36b095 100644 --- a/internal/nodes/node.go +++ b/internal/nodes/node.go @@ -347,12 +347,12 @@ func (this *Node) syncConfig() error { } else { remotelogs.Println("NODE", "loading config ...") } - + nodeconfigs.ResetNodeConfig(nodeConfig) caches.SharedManager.MaxDiskCapacity = nodeConfig.MaxCacheDiskCapacity caches.SharedManager.MaxMemoryCapacity = nodeConfig.MaxCacheMemoryCapacity - if nodeConfig.HTTPCachePolicy != nil { - caches.SharedManager.UpdatePolicies([]*serverconfigs.HTTPCachePolicy{nodeConfig.HTTPCachePolicy}) + if len(nodeConfig.HTTPCachePolicies) > 0 { + caches.SharedManager.UpdatePolicies(nodeConfig.HTTPCachePolicies) } else { caches.SharedManager.UpdatePolicies([]*serverconfigs.HTTPCachePolicy{}) }