diff --git a/go.mod b/go.mod index 164283c..101c6d9 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,3 @@ module github.com/bddjr/hlfhr go 1.21 - -require golang.org/x/net v0.31.0 - -require golang.org/x/text v0.20.0 // indirect diff --git a/go.sum b/go.sum deleted file mode 100644 index 2a7ab58..0000000 --- a/go.sum +++ /dev/null @@ -1,4 +0,0 @@ -golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= -golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= diff --git a/src_server.go b/src_server.go index 34b0dc3..ac1f69d 100644 --- a/src_server.go +++ b/src_server.go @@ -10,8 +10,6 @@ import ( "reflect" "sync/atomic" "unsafe" - - "golang.org/x/net/http2" ) type Server struct { @@ -49,20 +47,16 @@ func NewServer(s *http.Server) *Server { // ServeTLS always returns a non-nil error. After [Server.Shutdown] or [Server.Close], the // returned error is [http.ErrServerClosed]. func (s *Server) ServeTLS(l net.Listener, certFile string, keyFile string) error { - // Setup HTTP/2 before srv.Serve, to initialize srv.TLSConfig - // before we clone it and create the TLS Listener. - err := http2.ConfigureServer(s.Server, nil) - if err != nil { - return err + // Setup HTTP/2 + if s.TLSConfig == nil { + s.TLSConfig = &tls.Config{} + } + if len(s.TLSConfig.NextProtos) == 0 { + s.TLSConfig.NextProtos = []string{"h2", "http/1.1"} } // clone tls config - var config *tls.Config - if s.TLSConfig != nil { - config = s.TLSConfig.Clone() - } else { - config = &tls.Config{} - } + config := s.TLSConfig.Clone() configHasCert := len(config.Certificates) > 0 || config.GetCertificate != nil || config.GetConfigForClient != nil if !configHasCert || certFile != "" || keyFile != "" {