set the H3 ALPN on tls.Configs returned by GetConfigForClient

This commit is contained in:
Marten Seemann
2019-08-24 11:08:06 +07:00
parent fd30146de5
commit 328dd2c848
2 changed files with 35 additions and 0 deletions

View File

@@ -99,6 +99,17 @@ func (s *Server) serveImpl(tlsConf *tls.Config, conn net.PacketConn) error {
}
// Replace existing ALPNs by H3
tlsConf.NextProtos = []string{nextProtoH3}
if tlsConf.GetConfigForClient != nil {
getConfigForClient := tlsConf.GetConfigForClient
tlsConf.GetConfigForClient = func(ch *tls.ClientHelloInfo) (*tls.Config, error) {
conf, err := getConfigForClient(ch)
if err != nil || conf == nil {
return conf, err
}
conf.NextProtos = []string{nextProtoH3}
return conf, nil
}
}
var ln quic.Listener
var err error