Source file src/vendor/golang.org/x/net/internal/http3/quic.go

     1  // Copyright 2025 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package http3
     6  
     7  import (
     8  	"crypto/tls"
     9  
    10  	"golang.org/x/net/quic"
    11  )
    12  
    13  func initConfig(config *quic.Config) *quic.Config {
    14  	if config == nil {
    15  		config = &quic.Config{}
    16  	}
    17  
    18  	// maybeCloneTLSConfig clones the user-provided tls.Config (but only once)
    19  	// prior to us modifying it.
    20  	needCloneTLSConfig := true
    21  	maybeCloneTLSConfig := func() *tls.Config {
    22  		if needCloneTLSConfig {
    23  			config.TLSConfig = config.TLSConfig.Clone()
    24  			needCloneTLSConfig = false
    25  		}
    26  		return config.TLSConfig
    27  	}
    28  
    29  	if config.TLSConfig == nil {
    30  		config.TLSConfig = &tls.Config{}
    31  		needCloneTLSConfig = false
    32  	}
    33  	if config.TLSConfig.MinVersion == 0 {
    34  		maybeCloneTLSConfig().MinVersion = tls.VersionTLS13
    35  	}
    36  	if config.TLSConfig.NextProtos == nil {
    37  		maybeCloneTLSConfig().NextProtos = []string{"h3"}
    38  	}
    39  	return config
    40  }
    41  

View as plain text