forked from quic-go/quic-go
use stream 0 for the crypto stream when using TLS
This commit is contained in:
@@ -45,7 +45,7 @@ func (vn VersionNumber) String() string {
|
||||
case VersionTLS:
|
||||
return "TLS dev version (WIP)"
|
||||
default:
|
||||
if vn > gquicVersion0 && vn <= maxGquicVersion {
|
||||
if vn.isGQUIC() {
|
||||
return fmt.Sprintf("gQUIC %d", vn.toGQUICVersion())
|
||||
}
|
||||
return fmt.Sprintf("%d", vn)
|
||||
@@ -54,12 +54,24 @@ func (vn VersionNumber) String() string {
|
||||
|
||||
// ToAltSvc returns the representation of the version for the H2 Alt-Svc parameters
|
||||
func (vn VersionNumber) ToAltSvc() string {
|
||||
if vn > gquicVersion0 && vn <= maxGquicVersion {
|
||||
if vn.isGQUIC() {
|
||||
return fmt.Sprintf("%d", vn.toGQUICVersion())
|
||||
}
|
||||
return fmt.Sprintf("%d", vn)
|
||||
}
|
||||
|
||||
// CryptoStreamID gets the Stream ID of the crypto stream
|
||||
func (vn VersionNumber) CryptoStreamID() StreamID {
|
||||
if vn.isGQUIC() {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (vn VersionNumber) isGQUIC() bool {
|
||||
return vn > gquicVersion0 && vn <= maxGquicVersion
|
||||
}
|
||||
|
||||
func (vn VersionNumber) toGQUICVersion() int {
|
||||
return int(10*(vn-gquicVersion0)/0x100) + int(vn%0x10)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,13 @@ var _ = Describe("Version", func() {
|
||||
Expect(VersionNumber(0x51303133).ToAltSvc()).To(Equal("13"))
|
||||
Expect(VersionNumber(0x51303235).ToAltSvc()).To(Equal("25"))
|
||||
Expect(VersionNumber(0x51303438).ToAltSvc()).To(Equal("48"))
|
||||
})
|
||||
|
||||
It("tells the Stream ID of the crypto stream", func() {
|
||||
Expect(Version37.CryptoStreamID()).To(Equal(StreamID(1)))
|
||||
Expect(Version38.CryptoStreamID()).To(Equal(StreamID(1)))
|
||||
Expect(Version39.CryptoStreamID()).To(Equal(StreamID(1)))
|
||||
Expect(VersionTLS.CryptoStreamID()).To(Equal(StreamID(0)))
|
||||
})
|
||||
|
||||
It("recognizes supported versions", func() {
|
||||
|
||||
Reference in New Issue
Block a user