mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	WAF策略和缓存策略跟随集群
This commit is contained in:
		@@ -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
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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{})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user