forked from quic-go/quic-go
set the correct HTTP/3 ALPN for QUIC v2
This commit is contained in:
@@ -44,7 +44,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func versionToALPN(v protocol.VersionNumber) string {
|
func versionToALPN(v protocol.VersionNumber) string {
|
||||||
if v == protocol.Version1 {
|
if v == protocol.Version1 || v == protocol.Version2 {
|
||||||
return nextProtoH3
|
return nextProtoH3
|
||||||
}
|
}
|
||||||
if v == protocol.VersionTLS || v == protocol.VersionDraft29 {
|
if v == protocol.VersionTLS || v == protocol.VersionDraft29 {
|
||||||
@@ -63,11 +63,9 @@ func ConfigureTLSConfig(tlsConf *tls.Config) *tls.Config {
|
|||||||
return &tls.Config{
|
return &tls.Config{
|
||||||
GetConfigForClient: func(ch *tls.ClientHelloInfo) (*tls.Config, error) {
|
GetConfigForClient: func(ch *tls.ClientHelloInfo) (*tls.Config, error) {
|
||||||
// determine the ALPN from the QUIC version used
|
// determine the ALPN from the QUIC version used
|
||||||
proto := nextProtoH3Draft29
|
proto := nextProtoH3
|
||||||
if qconn, ok := ch.Conn.(handshake.ConnWithVersion); ok {
|
if qconn, ok := ch.Conn.(handshake.ConnWithVersion); ok {
|
||||||
if qconn.GetQUICVersion() == protocol.Version1 {
|
proto = versionToALPN(qconn.GetQUICVersion())
|
||||||
proto = nextProtoH3
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
config := tlsConf
|
config := tlsConf
|
||||||
if tlsConf.GetConfigForClient != nil {
|
if tlsConf.GetConfigForClient != nil {
|
||||||
|
|||||||
@@ -819,24 +819,24 @@ var _ = Describe("Server", func() {
|
|||||||
ch = &tls.ClientHelloInfo{}
|
ch = &tls.ClientHelloInfo{}
|
||||||
})
|
})
|
||||||
|
|
||||||
It("advertises draft by default", func() {
|
It("advertises v1 by default", func() {
|
||||||
tlsConf = ConfigureTLSConfig(tlsConf)
|
tlsConf = ConfigureTLSConfig(tlsConf)
|
||||||
Expect(tlsConf.GetConfigForClient).NotTo(BeNil())
|
Expect(tlsConf.GetConfigForClient).NotTo(BeNil())
|
||||||
|
|
||||||
config, err := tlsConf.GetConfigForClient(ch)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
Expect(config.NextProtos).To(Equal([]string{nextProtoH3Draft29}))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("advertises h3 for quic version 1", func() {
|
|
||||||
tlsConf = ConfigureTLSConfig(tlsConf)
|
|
||||||
Expect(tlsConf.GetConfigForClient).NotTo(BeNil())
|
|
||||||
|
|
||||||
ch.Conn = newMockConn(protocol.Version1)
|
|
||||||
config, err := tlsConf.GetConfigForClient(ch)
|
config, err := tlsConf.GetConfigForClient(ch)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(config.NextProtos).To(Equal([]string{nextProtoH3}))
|
Expect(config.NextProtos).To(Equal([]string{nextProtoH3}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("advertises h3-29 for draft-29", func() {
|
||||||
|
tlsConf = ConfigureTLSConfig(tlsConf)
|
||||||
|
Expect(tlsConf.GetConfigForClient).NotTo(BeNil())
|
||||||
|
|
||||||
|
ch.Conn = newMockConn(protocol.VersionDraft29)
|
||||||
|
config, err := tlsConf.GetConfigForClient(ch)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(config.NextProtos).To(Equal([]string{nextProtoH3Draft29}))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("Serve", func() {
|
Context("Serve", func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user