Skip to content

Commit

Permalink
create a milestone version for 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Aug 16, 2018
1 parent 00775db commit 893f99a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const (
VersionGQUIC42 = protocol.Version42
// VersionGQUIC43 is gQUIC version 43.
VersionGQUIC43 = protocol.Version43
// VersionMilestone0_9_0 uses TLS
VersionMilestone0_9_0 = protocol.VersionMilestone0_9_0
)

// A Cookie can be used to verify the ownership of the client address.
Expand Down
8 changes: 6 additions & 2 deletions internal/protocol/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const (
VersionTLS VersionNumber = 101
VersionWhatever VersionNumber = 0 // for when the version doesn't matter
VersionUnknown VersionNumber = math.MaxUint32

VersionMilestone0_9_0 VersionNumber = 0x51474f01
)

// SupportedVersions lists the versions that the server supports
Expand All @@ -36,12 +38,12 @@ var SupportedVersions = []VersionNumber{

// IsValidVersion says if the version is known to quic-go
func IsValidVersion(v VersionNumber) bool {
return v == VersionTLS || IsSupportedVersion(SupportedVersions, v)
return v == VersionMilestone0_9_0 || v == VersionTLS || IsSupportedVersion(SupportedVersions, v)
}

// UsesTLS says if this QUIC version uses TLS 1.3 for the handshake
func (vn VersionNumber) UsesTLS() bool {
return vn == VersionTLS
return vn == VersionTLS || vn == VersionMilestone0_9_0
}

func (vn VersionNumber) String() string {
Expand All @@ -52,6 +54,8 @@ func (vn VersionNumber) String() string {
return "unknown"
case VersionTLS:
return "TLS dev version (WIP)"
case VersionMilestone0_9_0:
return "quic-go Milestone 0.9.0"
default:
if vn.isGQUIC() {
return fmt.Sprintf("gQUIC %d", vn.toGQUICVersion())
Expand Down
13 changes: 13 additions & 0 deletions internal/protocol/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var _ = Describe("Version", func() {
Expect(IsValidVersion(Version42)).To(BeTrue())
Expect(IsValidVersion(Version43)).To(BeTrue())
Expect(IsValidVersion(VersionTLS)).To(BeTrue())
Expect(IsValidVersion(VersionMilestone0_9_0)).To(BeTrue())
Expect(IsValidVersion(VersionWhatever)).To(BeFalse())
Expect(IsValidVersion(VersionUnknown)).To(BeFalse())
Expect(IsValidVersion(1234)).To(BeFalse())
Expand All @@ -32,18 +33,21 @@ var _ = Describe("Version", func() {
Expect(Version42.UsesTLS()).To(BeFalse())
Expect(Version43.UsesTLS()).To(BeFalse())
Expect(VersionTLS.UsesTLS()).To(BeTrue())
Expect(VersionMilestone0_9_0.UsesTLS()).To(BeTrue())
})

It("versions don't have reserved version numbers", func() {
Expect(isReservedVersion(Version39)).To(BeFalse())
Expect(isReservedVersion(Version42)).To(BeFalse())
Expect(isReservedVersion(Version43)).To(BeFalse())
Expect(isReservedVersion(VersionTLS)).To(BeFalse())
Expect(isReservedVersion(VersionMilestone0_9_0)).To(BeFalse())
})

It("has the right string representation", func() {
Expect(Version39.String()).To(Equal("gQUIC 39"))
Expect(VersionTLS.String()).To(ContainSubstring("TLS"))
Expect(VersionMilestone0_9_0.String()).To(ContainSubstring("quic-go Milestone 0.9.0"))
Expect(VersionWhatever.String()).To(Equal("whatever"))
Expect(VersionUnknown.String()).To(Equal("unknown"))
// check with unsupported version numbers from the wiki
Expand All @@ -70,34 +74,39 @@ var _ = Describe("Version", func() {
Expect(Version42.CryptoStreamID()).To(Equal(StreamID(1)))
Expect(Version43.CryptoStreamID()).To(Equal(StreamID(1)))
Expect(VersionTLS.CryptoStreamID()).To(Equal(StreamID(0)))
Expect(VersionMilestone0_9_0.CryptoStreamID()).To(Equal(StreamID(0)))
})

It("tells if a version uses the IETF frame types", func() {
Expect(Version39.UsesIETFFrameFormat()).To(BeFalse())
Expect(Version42.UsesIETFFrameFormat()).To(BeFalse())
Expect(Version43.UsesIETFFrameFormat()).To(BeFalse())
Expect(VersionTLS.UsesIETFFrameFormat()).To(BeTrue())
Expect(VersionMilestone0_9_0.UsesIETFFrameFormat()).To(BeTrue())
})

It("tells if a version uses varint packet numbers", func() {
Expect(Version39.UsesVarintPacketNumbers()).To(BeFalse())
Expect(Version42.UsesVarintPacketNumbers()).To(BeFalse())
Expect(Version43.UsesVarintPacketNumbers()).To(BeFalse())
Expect(VersionTLS.UsesVarintPacketNumbers()).To(BeTrue())
Expect(VersionMilestone0_9_0.UsesVarintPacketNumbers()).To(BeTrue())
})

It("tells if a version uses the IETF frame types", func() {
Expect(Version39.UsesIETFFrameFormat()).To(BeFalse())
Expect(Version42.UsesIETFFrameFormat()).To(BeFalse())
Expect(Version43.UsesIETFFrameFormat()).To(BeFalse())
Expect(VersionTLS.UsesIETFFrameFormat()).To(BeTrue())
Expect(VersionMilestone0_9_0.UsesIETFFrameFormat()).To(BeTrue())
})

It("tells if a version uses STOP_WAITING frames", func() {
Expect(Version39.UsesStopWaitingFrames()).To(BeTrue())
Expect(Version42.UsesStopWaitingFrames()).To(BeTrue())
Expect(Version43.UsesStopWaitingFrames()).To(BeTrue())
Expect(VersionTLS.UsesStopWaitingFrames()).To(BeFalse())
Expect(VersionMilestone0_9_0.UsesStopWaitingFrames()).To(BeFalse())
})

It("says if a stream contributes to connection-level flowcontrol, for gQUIC", func() {
Expand All @@ -116,6 +125,10 @@ var _ = Describe("Version", func() {
Expect(VersionTLS.StreamContributesToConnectionFlowControl(1)).To(BeTrue())
Expect(VersionTLS.StreamContributesToConnectionFlowControl(2)).To(BeTrue())
Expect(VersionTLS.StreamContributesToConnectionFlowControl(3)).To(BeTrue())
Expect(VersionMilestone0_9_0.StreamContributesToConnectionFlowControl(0)).To(BeFalse())
Expect(VersionMilestone0_9_0.StreamContributesToConnectionFlowControl(1)).To(BeTrue())
Expect(VersionMilestone0_9_0.StreamContributesToConnectionFlowControl(2)).To(BeTrue())
Expect(VersionMilestone0_9_0.StreamContributesToConnectionFlowControl(3)).To(BeTrue())
})

It("recognizes supported versions", func() {
Expand Down

0 comments on commit 893f99a

Please sign in to comment.