mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-07 11:28:48 +03:00
httpserver: Only enable QUIC for sites with TLS & HTTP2 enabled
This commit is contained in:
parent
6e0317a703
commit
ae7e098240
1 changed files with 7 additions and 7 deletions
|
@ -77,14 +77,14 @@ func NewServer(addr string, group []*SiteConfig) (*Server, error) {
|
||||||
}
|
}
|
||||||
s.Server.TLSConfig = tlsConfig
|
s.Server.TLSConfig = tlsConfig
|
||||||
|
|
||||||
// Enable QUIC if desired
|
|
||||||
if QUIC {
|
|
||||||
s.quicServer = &h2quic.Server{Server: s.Server}
|
|
||||||
s.Server.Handler = s.wrapWithSvcHeaders(s.Server.Handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// if TLS is enabled, make sure we prepare the Server accordingly
|
// if TLS is enabled, make sure we prepare the Server accordingly
|
||||||
if s.Server.TLSConfig != nil {
|
if s.Server.TLSConfig != nil {
|
||||||
|
// enable QUIC if desired (requires HTTP/2)
|
||||||
|
if HTTP2 && QUIC {
|
||||||
|
s.quicServer = &h2quic.Server{Server: s.Server}
|
||||||
|
s.Server.Handler = s.wrapWithSvcHeaders(s.Server.Handler)
|
||||||
|
}
|
||||||
|
|
||||||
// wrap the HTTP handler with a handler that does MITM detection
|
// wrap the HTTP handler with a handler that does MITM detection
|
||||||
tlsh := &tlsHandler{next: s.Server.Handler}
|
tlsh := &tlsHandler{next: s.Server.Handler}
|
||||||
s.Server.Handler = tlsh // this needs to be the "outer" handler when Serve() is called, for type assertion
|
s.Server.Handler = tlsh // this needs to be the "outer" handler when Serve() is called, for type assertion
|
||||||
|
@ -302,7 +302,7 @@ func (s *Server) Serve(ln net.Listener) error {
|
||||||
|
|
||||||
// ServePacket serves QUIC requests on pc until it is closed.
|
// ServePacket serves QUIC requests on pc until it is closed.
|
||||||
func (s *Server) ServePacket(pc net.PacketConn) error {
|
func (s *Server) ServePacket(pc net.PacketConn) error {
|
||||||
if QUIC {
|
if s.quicServer != nil {
|
||||||
err := s.quicServer.Serve(pc.(*net.UDPConn))
|
err := s.quicServer.Serve(pc.(*net.UDPConn))
|
||||||
return fmt.Errorf("serving QUIC connections: %v", err)
|
return fmt.Errorf("serving QUIC connections: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue