mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 08:31:30 +00:00
Fix tls config for h2 server
This commit is contained in:
parent
bf20ff84b5
commit
ee3cd49aa5
|
@ -53,8 +53,8 @@ func NewServer(ctx context.Context, options option.V2RayGRPCOptions, tlsConfig t
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !common.Contains(stdConfig.NextProtos, "h2") {
|
if len(stdConfig.NextProtos) == 0 {
|
||||||
stdConfig.NextProtos = append(stdConfig.NextProtos, "h2")
|
stdConfig.NextProtos = []string{http2.NextProtoTLS}
|
||||||
}
|
}
|
||||||
server.httpServer.TLSConfig = stdConfig
|
server.httpServer.TLSConfig = stdConfig
|
||||||
}
|
}
|
||||||
|
@ -96,10 +96,14 @@ func (s *Server) badRequest(request *http.Request, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Serve(listener net.Listener) error {
|
func (s *Server) Serve(listener net.Listener) error {
|
||||||
|
fixTLSConfig := s.httpServer.TLSConfig == nil
|
||||||
err := http2.ConfigureServer(s.httpServer, s.h2Server)
|
err := http2.ConfigureServer(s.httpServer, s.h2Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if fixTLSConfig {
|
||||||
|
s.httpServer.TLSConfig = nil
|
||||||
|
}
|
||||||
if s.httpServer.TLSConfig == nil {
|
if s.httpServer.TLSConfig == nil {
|
||||||
return s.httpServer.Serve(listener)
|
return s.httpServer.Serve(listener)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -133,10 +133,14 @@ func (s *Server) badRequest(request *http.Request, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Serve(listener net.Listener) error {
|
func (s *Server) Serve(listener net.Listener) error {
|
||||||
|
fixTLSConfig := s.httpServer.TLSConfig == nil
|
||||||
err := http2.ConfigureServer(s.httpServer, s.h2Server)
|
err := http2.ConfigureServer(s.httpServer, s.h2Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if fixTLSConfig {
|
||||||
|
s.httpServer.TLSConfig = nil
|
||||||
|
}
|
||||||
if s.httpServer.TLSConfig == nil {
|
if s.httpServer.TLSConfig == nil {
|
||||||
return s.httpServer.Serve(listener)
|
return s.httpServer.Serve(listener)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue