diff --git a/internal/nodes/listener_http.go b/internal/nodes/listener_http.go index 3a8f366..92a6f59 100644 --- a/internal/nodes/listener_http.go +++ b/internal/nodes/listener_http.go @@ -107,15 +107,23 @@ func (this *HTTPListener) Reload(group *serverconfigs.ServerAddressGroup) { // ServerHTTP 处理HTTP请求 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 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) + time.Sleep(1 * time.Second) // make connection slow down return } // 不支持Connect if rawReq.Method == http.MethodConnect { http.Error(rawWriter, "Method Not Allowed", http.StatusMethodNotAllowed) + time.Sleep(1 * time.Second) // make connection slow down return }