From b14ae51f7130e6e367e70340c04ad6372ca6b024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 1 Mar 2023 10:41:09 +0800 Subject: [PATCH] Fix create badhttp2 server --- transport/v2raygrpclite/server_badhttp.go | 18 +++++++----------- transport/v2rayhttp/server_badhttp.go | 18 +++++++----------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/transport/v2raygrpclite/server_badhttp.go b/transport/v2raygrpclite/server_badhttp.go index 326838fe..ff350ffc 100644 --- a/transport/v2raygrpclite/server_badhttp.go +++ b/transport/v2raygrpclite/server_badhttp.go @@ -98,18 +98,14 @@ func (s *Server) fallbackRequest(ctx context.Context, writer http.ResponseWriter } func (s *Server) Serve(listener net.Listener) error { - fixTLSConfig := s.httpServer.TLSConfig == nil - err := http2.ConfigureServer(s.httpServer, s.h2Server) - if err != nil { - return err - } - if fixTLSConfig { - s.httpServer.TLSConfig = nil - } - if s.httpServer.TLSConfig == nil { - return s.httpServer.Serve(listener) - } else { + if s.httpServer.TLSConfig != nil { + err := http2.ConfigureServer(s.httpServer, s.h2Server) + if err != nil { + return err + } return s.httpServer.ServeTLS(listener, "", "") + } else { + return s.httpServer.Serve(listener) } } diff --git a/transport/v2rayhttp/server_badhttp.go b/transport/v2rayhttp/server_badhttp.go index 00cadfa7..3359360f 100644 --- a/transport/v2rayhttp/server_badhttp.go +++ b/transport/v2rayhttp/server_badhttp.go @@ -134,18 +134,14 @@ func (s *Server) fallbackRequest(ctx context.Context, writer http.ResponseWriter } func (s *Server) Serve(listener net.Listener) error { - fixTLSConfig := s.httpServer.TLSConfig == nil - err := http2.ConfigureServer(s.httpServer, s.h2Server) - if err != nil { - return err - } - if fixTLSConfig { - s.httpServer.TLSConfig = nil - } - if s.httpServer.TLSConfig == nil { - return s.httpServer.Serve(listener) - } else { + if s.httpServer.TLSConfig != nil { + err := http2.ConfigureServer(s.httpServer, s.h2Server) + if err != nil { + return err + } return s.httpServer.ServeTLS(listener, "", "") + } else { + return s.httpServer.Serve(listener) } }