WAF策略和缓存策略跟随集群

This commit is contained in:
GoEdgeLab
2021-08-01 14:54:06 +08:00
parent 678e7f2c2a
commit e723a64e68
4 changed files with 9 additions and 9 deletions

View File

@@ -12,7 +12,7 @@ import (
// 读取缓存 // 读取缓存
func (this *HTTPRequest) doCacheRead() (shouldStop bool) { func (this *HTTPRequest) doCacheRead() (shouldStop bool) {
cachePolicy := sharedNodeConfig.HTTPCachePolicy cachePolicy := this.Server.HTTPCachePolicy
if cachePolicy == nil || !cachePolicy.IsOn { if cachePolicy == nil || !cachePolicy.IsOn {
return return
} }

View File

@@ -28,8 +28,8 @@ func (this *HTTPRequest) doWAFRequest() (blocked bool) {
} }
// 公用的防火墙设置 // 公用的防火墙设置
if sharedNodeConfig.HTTPFirewallPolicy != nil { if this.Server.HTTPFirewallPolicy != nil && this.Server.HTTPFirewallPolicy.IsOn {
blocked, breakChecking := this.checkWAFRequest(sharedNodeConfig.HTTPFirewallPolicy) blocked, breakChecking := this.checkWAFRequest(this.Server.HTTPFirewallPolicy)
if blocked { if blocked {
return true return true
} }
@@ -201,8 +201,8 @@ func (this *HTTPRequest) doWAFResponse(resp *http.Response) (blocked bool) {
} }
// 公用的防火墙设置 // 公用的防火墙设置
if sharedNodeConfig.HTTPFirewallPolicy != nil { if this.Server.HTTPFirewallPolicy != nil && this.Server.HTTPFirewallPolicy.IsOn {
blocked := this.checkWAFResponse(sharedNodeConfig.HTTPFirewallPolicy, resp) blocked := this.checkWAFResponse(this.Server.HTTPFirewallPolicy, resp)
if blocked { if blocked {
return true return true
} }

View File

@@ -342,7 +342,7 @@ func (this *HTTPWriter) prepareCache(size int64) {
return return
} }
cachePolicy := sharedNodeConfig.HTTPCachePolicy cachePolicy := this.req.Server.HTTPCachePolicy
if cachePolicy == nil || !cachePolicy.IsOn { if cachePolicy == nil || !cachePolicy.IsOn {
return return
} }

View File

@@ -347,12 +347,12 @@ func (this *Node) syncConfig() error {
} else { } else {
remotelogs.Println("NODE", "loading config ...") remotelogs.Println("NODE", "loading config ...")
} }
nodeconfigs.ResetNodeConfig(nodeConfig) nodeconfigs.ResetNodeConfig(nodeConfig)
caches.SharedManager.MaxDiskCapacity = nodeConfig.MaxCacheDiskCapacity caches.SharedManager.MaxDiskCapacity = nodeConfig.MaxCacheDiskCapacity
caches.SharedManager.MaxMemoryCapacity = nodeConfig.MaxCacheMemoryCapacity caches.SharedManager.MaxMemoryCapacity = nodeConfig.MaxCacheMemoryCapacity
if nodeConfig.HTTPCachePolicy != nil { if len(nodeConfig.HTTPCachePolicies) > 0 {
caches.SharedManager.UpdatePolicies([]*serverconfigs.HTTPCachePolicy{nodeConfig.HTTPCachePolicy}) caches.SharedManager.UpdatePolicies(nodeConfig.HTTPCachePolicies)
} else { } else {
caches.SharedManager.UpdatePolicies([]*serverconfigs.HTTPCachePolicy{}) caches.SharedManager.UpdatePolicies([]*serverconfigs.HTTPCachePolicy{})
} }