From 14b16a429c26ae46e35e3c35a7838dcc00bb1e47 Mon Sep 17 00:00:00 2001 From: Lucas Clemente Date: Mon, 9 May 2016 19:50:15 +0200 Subject: [PATCH] add version number to Frame.Write --- frames/ack_frame.go | 2 +- frames/ack_frame_test.go | 26 +++++++++++++------------- frames/blocked_frame.go | 2 +- frames/blocked_frame_test.go | 2 +- frames/connection_close_frame.go | 2 +- frames/connection_close_frame_test.go | 10 +++++----- frames/frame.go | 2 +- frames/ping_frame.go | 2 +- frames/ping_frame_test.go | 2 +- frames/rst_stream_frame.go | 2 +- frames/stop_waiting_frame.go | 2 +- frames/stop_waiting_frame_test.go | 4 ++-- frames/stream_frame.go | 2 +- frames/stream_frame_test.go | 6 +++--- frames/window_update_frame.go | 2 +- packet_packer.go | 6 ++++-- packet_packer_test.go | 8 ++++---- packet_unpacker_test.go | 6 +++--- protocol/version.go | 2 +- protocol/version_test.go | 2 +- session.go | 2 +- 21 files changed, 48 insertions(+), 46 deletions(-) diff --git a/frames/ack_frame.go b/frames/ack_frame.go index 4e718311..1d8d3f6b 100644 --- a/frames/ack_frame.go +++ b/frames/ack_frame.go @@ -21,7 +21,7 @@ type AckFrame struct { } // Write writes an ACK frame. -func (f *AckFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) error { +func (f *AckFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error { typeByte := uint8(0x40 | 0x0C) if f.HasNACK() { diff --git a/frames/ack_frame_test.go b/frames/ack_frame_test.go index 53dc640f..9158e31a 100644 --- a/frames/ack_frame_test.go +++ b/frames/ack_frame_test.go @@ -238,7 +238,7 @@ var _ = Describe("AckFrame", func() { Entropy: 2, LargestObserved: 1, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) Expect(b.Bytes()).To(Equal([]byte{0x4c, 0x02, 0x01, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0})) }) @@ -249,7 +249,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 4, NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 2}}, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) missingPacketBytes := b.Bytes()[b.Len()-8:] Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges @@ -267,7 +267,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 7, NackRanges: []NackRange{nackRange1, nackRange2}, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):] Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges @@ -288,7 +288,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 258, NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 257}}, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) missingPacketBytes := b.Bytes()[b.Len()-(1+7):] Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges @@ -302,7 +302,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 302, NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 301}}, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):] Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges @@ -318,7 +318,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 259, NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 258}}, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):] Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges @@ -334,7 +334,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 603, NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 601}}, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) missingPacketBytes := b.Bytes()[b.Len()-(1+3*7):] Expect(missingPacketBytes[0]).To(Equal(uint8(3))) // numRanges @@ -354,7 +354,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 655, NackRanges: []NackRange{nackRange2, nackRange1}, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) missingPacketBytes := b.Bytes()[b.Len()-(1+4*7):] Expect(missingPacketBytes[0]).To(Equal(uint8(4))) // numRanges @@ -375,7 +375,7 @@ var _ = Describe("AckFrame", func() { Entropy: 2, LargestObserved: 1, } - f.Write(b, 1, protocol.PacketNumberLen6) + f.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(f.MinLength()).To(Equal(b.Len())) }) @@ -385,7 +385,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 4, NackRanges: []NackRange{NackRange{FirstPacketNumber: 2, LastPacketNumber: 2}}, } - err := f.Write(b, 1, protocol.PacketNumberLen6) + err := f.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) Expect(f.MinLength()).To(Equal(b.Len())) }) @@ -403,7 +403,7 @@ var _ = Describe("AckFrame", func() { Entropy: 0xDE, LargestObserved: 6789, } - err := frameOrig.Write(b, 1, protocol.PacketNumberLen6) + err := frameOrig.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) frame, err := ParseAckFrame(bytes.NewReader(b.Bytes())) Expect(err).ToNot(HaveOccurred()) @@ -421,7 +421,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 15, NackRanges: nackRanges, } - err := frameOrig.Write(b, 1, protocol.PacketNumberLen6) + err := frameOrig.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) r := bytes.NewReader(b.Bytes()) frame, err := ParseAckFrame(r) @@ -441,7 +441,7 @@ var _ = Describe("AckFrame", func() { LargestObserved: 1600, NackRanges: nackRanges, } - err := frameOrig.Write(b, 1, protocol.PacketNumberLen6) + err := frameOrig.Write(b, 1, protocol.PacketNumberLen6, 32) Expect(err).ToNot(HaveOccurred()) r := bytes.NewReader(b.Bytes()) frame, err := ParseAckFrame(r) diff --git a/frames/blocked_frame.go b/frames/blocked_frame.go index 14bdb1ee..c3bc906c 100644 --- a/frames/blocked_frame.go +++ b/frames/blocked_frame.go @@ -13,7 +13,7 @@ type BlockedFrame struct { } //Write writes a RST_STREAM frame -func (f *BlockedFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) error { +func (f *BlockedFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error { b.WriteByte(0x05) if f.StreamID == 0 { diff --git a/frames/blocked_frame_test.go b/frames/blocked_frame_test.go index 8d19971e..c1f5db4a 100644 --- a/frames/blocked_frame_test.go +++ b/frames/blocked_frame_test.go @@ -22,7 +22,7 @@ var _ = Describe("BlockedFrame", func() { It("writes a sample frame", func() { b := &bytes.Buffer{} frame := BlockedFrame{StreamID: 0x1337} - frame.Write(b, 10, protocol.PacketNumberLen6) + frame.Write(b, 10, protocol.PacketNumberLen6, 0) Expect(b.Bytes()).To(Equal([]byte{0x05, 0x37, 0x13, 0x0, 0x0})) }) diff --git a/frames/connection_close_frame.go b/frames/connection_close_frame.go index 0590034f..7de367d9 100644 --- a/frames/connection_close_frame.go +++ b/frames/connection_close_frame.go @@ -52,7 +52,7 @@ func (f *ConnectionCloseFrame) MinLength() int { } // Write writes an CONNECTION_CLOSE frame. -func (f *ConnectionCloseFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) error { +func (f *ConnectionCloseFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error { b.WriteByte(0x02) utils.WriteUint32(b, uint32(f.ErrorCode)) diff --git a/frames/connection_close_frame_test.go b/frames/connection_close_frame_test.go index 87a4dddf..68825ec9 100644 --- a/frames/connection_close_frame_test.go +++ b/frames/connection_close_frame_test.go @@ -35,7 +35,7 @@ var _ = Describe("ConnectionCloseFrame", func() { frame := &ConnectionCloseFrame{ ErrorCode: 0xDEADBEEF, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 0) Expect(err).ToNot(HaveOccurred()) Expect(b.Len()).To(Equal(1 + 2 + 4)) Expect(b.Bytes()).To(Equal([]byte{0x02, 0xEF, 0xBE, 0xAD, 0xDE, 0x00, 0x00})) @@ -47,7 +47,7 @@ var _ = Describe("ConnectionCloseFrame", func() { ErrorCode: 0xDEADBEEF, ReasonPhrase: "foobar", } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 0) Expect(err).ToNot(HaveOccurred()) Expect(b.Len()).To(Equal(1 + 2 + 4 + len(frame.ReasonPhrase))) Expect(b.Bytes()[:5]).To(Equal([]byte{0x02, 0xEF, 0xBE, 0xAD, 0xDE})) @@ -67,7 +67,7 @@ var _ = Describe("ConnectionCloseFrame", func() { ErrorCode: 0xDEADBEEF, ReasonPhrase: reasonPhrase, } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 0) Expect(err).To(HaveOccurred()) }) @@ -77,7 +77,7 @@ var _ = Describe("ConnectionCloseFrame", func() { ErrorCode: 0xDEADBEEF, ReasonPhrase: "foobar", } - f.Write(b, 1, protocol.PacketNumberLen6) + f.Write(b, 1, protocol.PacketNumberLen6, 0) Expect(f.MinLength()).To(Equal(b.Len())) }) }) @@ -88,7 +88,7 @@ var _ = Describe("ConnectionCloseFrame", func() { ErrorCode: 0xDEADBEEF, ReasonPhrase: "Lorem ipsum dolor sit amet.", } - err := frame.Write(b, 1, protocol.PacketNumberLen6) + err := frame.Write(b, 1, protocol.PacketNumberLen6, 0) Expect(err).ToNot(HaveOccurred()) readframe, err := ParseConnectionCloseFrame(bytes.NewReader(b.Bytes())) Expect(err).ToNot(HaveOccurred()) diff --git a/frames/frame.go b/frames/frame.go index c5aebd5f..077ec86a 100644 --- a/frames/frame.go +++ b/frames/frame.go @@ -8,6 +8,6 @@ import ( // A Frame in QUIC type Frame interface { - Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) error + Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error MinLength() int } diff --git a/frames/ping_frame.go b/frames/ping_frame.go index 6069f7c4..e860c5b7 100644 --- a/frames/ping_frame.go +++ b/frames/ping_frame.go @@ -21,7 +21,7 @@ func ParsePingFrame(r *bytes.Reader) (*PingFrame, error) { return frame, nil } -func (f *PingFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) error { +func (f *PingFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error { typeByte := uint8(0x07) b.WriteByte(typeByte) return nil diff --git a/frames/ping_frame_test.go b/frames/ping_frame_test.go index 9ded2341..8e706657 100644 --- a/frames/ping_frame_test.go +++ b/frames/ping_frame_test.go @@ -22,7 +22,7 @@ var _ = Describe("PingFrame", func() { It("writes a sample frame", func() { b := &bytes.Buffer{} frame := PingFrame{} - frame.Write(b, 10, protocol.PacketNumberLen6) + frame.Write(b, 10, protocol.PacketNumberLen6, 0) Expect(b.Bytes()).To(Equal([]byte{0x07})) }) diff --git a/frames/rst_stream_frame.go b/frames/rst_stream_frame.go index e93d7a51..5e4cfb5e 100644 --- a/frames/rst_stream_frame.go +++ b/frames/rst_stream_frame.go @@ -15,7 +15,7 @@ type RstStreamFrame struct { } //Write writes a RST_STREAM frame -func (f *RstStreamFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) error { +func (f *RstStreamFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error { panic("RstStreamFrame: Write not yet implemented") } diff --git a/frames/stop_waiting_frame.go b/frames/stop_waiting_frame.go index 24e945a2..a8ea83db 100644 --- a/frames/stop_waiting_frame.go +++ b/frames/stop_waiting_frame.go @@ -14,7 +14,7 @@ type StopWaitingFrame struct { LeastUnacked protocol.PacketNumber } -func (f *StopWaitingFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) error { +func (f *StopWaitingFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error { // packetNumber is the packet number of the packet that this StopWaitingFrame will be sent with typeByte := uint8(0x06) b.WriteByte(typeByte) diff --git a/frames/stop_waiting_frame_test.go b/frames/stop_waiting_frame_test.go index a4ce9592..0adffd79 100644 --- a/frames/stop_waiting_frame_test.go +++ b/frames/stop_waiting_frame_test.go @@ -34,7 +34,7 @@ var _ = Describe("StopWaitingFrame", func() { LeastUnacked: 10, Entropy: 0xE, } - frame.Write(b, packetNumber, protocol.PacketNumberLen6) + frame.Write(b, packetNumber, protocol.PacketNumberLen6, 0) Expect(b.Bytes()[0]).To(Equal(uint8(0x06))) // todo: check more }) @@ -48,7 +48,7 @@ var _ = Describe("StopWaitingFrame", func() { Entropy: 0xE, } b := &bytes.Buffer{} - frame.Write(b, packetNumber, protocol.PacketNumberLen6) + frame.Write(b, packetNumber, protocol.PacketNumberLen6, 0) readframe, err := ParseStopWaitingFrame(bytes.NewReader(b.Bytes()), packetNumber, 6) Expect(err).ToNot(HaveOccurred()) Expect(readframe.Entropy).To(Equal(frame.Entropy)) diff --git a/frames/stream_frame.go b/frames/stream_frame.go index a88efd2c..19c7d33d 100644 --- a/frames/stream_frame.go +++ b/frames/stream_frame.go @@ -70,7 +70,7 @@ func ParseStreamFrame(r *bytes.Reader) (*StreamFrame, error) { } // WriteStreamFrame writes a stream frame. -func (f *StreamFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) error { +func (f *StreamFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error { typeByte := uint8(0x80) if f.FinBit { typeByte ^= 0x40 diff --git a/frames/stream_frame_test.go b/frames/stream_frame_test.go index ee8f79b3..b17fa9da 100644 --- a/frames/stream_frame_test.go +++ b/frames/stream_frame_test.go @@ -37,7 +37,7 @@ var _ = Describe("StreamFrame", func() { (&StreamFrame{ StreamID: 1, Data: []byte("foobar"), - }).Write(b, 1, protocol.PacketNumberLen6) + }).Write(b, 1, protocol.PacketNumberLen6, 0) Expect(b.Bytes()).To(Equal([]byte{0xa3, 0x1, 0, 0, 0, 0x06, 0x00, 'f', 'o', 'o', 'b', 'a', 'r'})) }) @@ -47,7 +47,7 @@ var _ = Describe("StreamFrame", func() { StreamID: 1, Offset: 16, Data: []byte("foobar"), - }).Write(b, 1, protocol.PacketNumberLen6) + }).Write(b, 1, protocol.PacketNumberLen6, 0) Expect(b.Bytes()).To(Equal([]byte{0xbf, 0x1, 0, 0, 0, 0x10, 0, 0, 0, 0, 0, 0, 0, 0x06, 0x00, 'f', 'o', 'o', 'b', 'a', 'r'})) }) @@ -58,7 +58,7 @@ var _ = Describe("StreamFrame", func() { Data: []byte("f"), Offset: 1, } - f.Write(b, 1, protocol.PacketNumberLen6) + f.Write(b, 1, protocol.PacketNumberLen6, 0) Expect(f.MinLength()).To(Equal(b.Len())) }) }) diff --git a/frames/window_update_frame.go b/frames/window_update_frame.go index e9604931..8212fe87 100644 --- a/frames/window_update_frame.go +++ b/frames/window_update_frame.go @@ -14,7 +14,7 @@ type WindowUpdateFrame struct { } //Write writes a RST_STREAM frame -func (f *WindowUpdateFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) error { +func (f *WindowUpdateFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) error { panic("WindowUpdateFrame: Write not yet implemented") } diff --git a/packet_packer.go b/packet_packer.go index 2df07078..a671146b 100644 --- a/packet_packer.go +++ b/packet_packer.go @@ -19,7 +19,9 @@ type packedPacket struct { } type packetPacker struct { - connectionID protocol.ConnectionID + connectionID protocol.ConnectionID + version protocol.VersionNumber + aead crypto.AEAD connectionParametersManager *handshake.ConnectionParametersManager @@ -95,7 +97,7 @@ func (p *packetPacker) getPayload(frames []frames.Frame, currentPacketNumber pro var payload bytes.Buffer payload.WriteByte(0) // The entropy bit is set in sendPayload for _, frame := range frames { - frame.Write(&payload, currentPacketNumber, 6) + frame.Write(&payload, currentPacketNumber, 6, p.version) } return payload.Bytes(), nil } diff --git a/packet_packer_test.go b/packet_packer_test.go index a572f792..9f958b69 100644 --- a/packet_packer_test.go +++ b/packet_packer_test.go @@ -37,7 +37,7 @@ var _ = Describe("Packet packer", func() { Expect(p).ToNot(BeNil()) Expect(err).ToNot(HaveOccurred()) b := &bytes.Buffer{} - f.Write(b, 1, 6) + f.Write(b, 1, 6, 0) Expect(len(p.frames)).To(Equal(1)) Expect(p.raw).To(ContainSubstring(string(b.Bytes()))) }) @@ -80,7 +80,7 @@ var _ = Describe("Packet packer", func() { It("packs many control frames into 1 packets", func() { f := &frames.AckFrame{LargestObserved: 1} b := &bytes.Buffer{} - f.Write(b, 3, 6) + f.Write(b, 3, 6, 32) maxFramesPerPacket := protocol.MaxFrameSize / b.Len() var controlFrames []frames.Frame for i := 0; i < maxFramesPerPacket; i++ { @@ -146,8 +146,8 @@ var _ = Describe("Packet packer", func() { Expect(p).ToNot(BeNil()) Expect(err).ToNot(HaveOccurred()) b := &bytes.Buffer{} - f1.Write(b, 2, 6) - f2.Write(b, 2, 6) + f1.Write(b, 2, 6, 0) + f2.Write(b, 2, 6, 0) Expect(len(p.frames)).To(Equal(2)) Expect(p.raw).To(ContainSubstring(string(b.Bytes()))) }) diff --git a/packet_unpacker_test.go b/packet_unpacker_test.go index 4b2fb4de..8543dd62 100644 --- a/packet_unpacker_test.go +++ b/packet_unpacker_test.go @@ -50,7 +50,7 @@ var _ = Describe("Packet unpacker", func() { StreamID: 1, Data: []byte("foobar"), } - err := f.Write(buf, 3, 6) + err := f.Write(buf, 3, 6, 0) Expect(err).ToNot(HaveOccurred()) setReader(buf.Bytes()) packet, err := unpacker.Unpack(hdrBin, hdr, r) @@ -63,7 +63,7 @@ var _ = Describe("Packet unpacker", func() { LargestObserved: 1, DelayTime: time.Microsecond, } - err := f.Write(buf, 3, 6) + err := f.Write(buf, 3, 6, 32) Expect(err).ToNot(HaveOccurred()) setReader(buf.Bytes()) packet, err := unpacker.Unpack(hdrBin, hdr, r) @@ -99,7 +99,7 @@ var _ = Describe("Packet unpacker", func() { It("unpacks CONNECTION_CLOSE frames", func() { f := &frames.ConnectionCloseFrame{ReasonPhrase: "foo"} - err := f.Write(buf, 6, 6) + err := f.Write(buf, 6, 6, 0) Expect(err).ToNot(HaveOccurred()) setReader(buf.Bytes()) packet, err := unpacker.Unpack(hdrBin, hdr, r) diff --git a/protocol/version.go b/protocol/version.go index 2fcee363..90329ff2 100644 --- a/protocol/version.go +++ b/protocol/version.go @@ -11,7 +11,7 @@ type VersionNumber int // SupportedVersions lists the versions that the server supports var SupportedVersions = []VersionNumber{ - 32, + 31, 32, } // SupportedVersionsAsTags is needed for the SHLO crypto message diff --git a/protocol/version_test.go b/protocol/version_test.go index 52c51a79..9efc14f2 100644 --- a/protocol/version_test.go +++ b/protocol/version_test.go @@ -19,7 +19,7 @@ var _ = Describe("Version", func() { }) It("has proper tag list", func() { - Expect(protocol.SupportedVersionsAsTags).To(Equal([]byte("Q032"))) + Expect(protocol.SupportedVersionsAsTags).To(Equal([]byte("Q031Q032"))) }) It("recognizes supported versions", func() { diff --git a/session.go b/session.go index 83928698..5fc2453d 100644 --- a/session.go +++ b/session.go @@ -95,7 +95,7 @@ func NewSession(conn connection, v protocol.VersionNumber, connectionID protocol } }() - session.packer = &packetPacker{aead: cryptoSetup, connectionParametersManager: session.connectionParametersManager, connectionID: connectionID} + session.packer = &packetPacker{aead: cryptoSetup, connectionParametersManager: session.connectionParametersManager, connectionID: connectionID, version: v} session.unpacker = &packetUnpacker{aead: cryptoSetup} session.congestion = congestion.NewCubicSender(