mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	限制请求域名长度不超过253
This commit is contained in:
		@@ -107,15 +107,23 @@ func (this *HTTPListener) Reload(group *serverconfigs.ServerAddressGroup) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// ServerHTTP 处理HTTP请求
 | 
					// ServerHTTP 处理HTTP请求
 | 
				
			||||||
func (this *HTTPListener) ServeHTTP(rawWriter http.ResponseWriter, rawReq *http.Request) {
 | 
					func (this *HTTPListener) ServeHTTP(rawWriter http.ResponseWriter, rawReq *http.Request) {
 | 
				
			||||||
 | 
						if len(rawReq.Host) > 253 {
 | 
				
			||||||
 | 
							http.Error(rawWriter, "Host too long.", http.StatusBadRequest)
 | 
				
			||||||
 | 
							time.Sleep(1 * time.Second) // make connection slow down
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var globalServerConfig = sharedNodeConfig.GlobalServerConfig
 | 
						var globalServerConfig = sharedNodeConfig.GlobalServerConfig
 | 
				
			||||||
	if globalServerConfig != nil && !globalServerConfig.HTTPAll.SupportsLowVersionHTTP && (rawReq.ProtoMajor < 1 /** 0.x **/ || (rawReq.ProtoMajor == 1 && rawReq.ProtoMinor == 0 /** 1.0 **/)) {
 | 
						if globalServerConfig != nil && !globalServerConfig.HTTPAll.SupportsLowVersionHTTP && (rawReq.ProtoMajor < 1 /** 0.x **/ || (rawReq.ProtoMajor == 1 && rawReq.ProtoMinor == 0 /** 1.0 **/)) {
 | 
				
			||||||
		http.Error(rawWriter, rawReq.Proto+" request is not supported.", http.StatusBadRequest)
 | 
							http.Error(rawWriter, rawReq.Proto+" request is not supported.", http.StatusBadRequest)
 | 
				
			||||||
 | 
							time.Sleep(1 * time.Second) // make connection slow down
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 不支持Connect
 | 
						// 不支持Connect
 | 
				
			||||||
	if rawReq.Method == http.MethodConnect {
 | 
						if rawReq.Method == http.MethodConnect {
 | 
				
			||||||
		http.Error(rawWriter, "Method Not Allowed", http.StatusMethodNotAllowed)
 | 
							http.Error(rawWriter, "Method Not Allowed", http.StatusMethodNotAllowed)
 | 
				
			||||||
 | 
							time.Sleep(1 * time.Second) // make connection slow down
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user