refactor how session tickets are sent

Previously, RunHandshake() would send the session tickets. Now, the
session initiates the sending of the session ticket. This simplifies the
setup a bit, and it will make it possible to include the RTT estimate in
the session ticket without accessing the RTTStats concurrently.
This commit is contained in:
Marten Seemann 2020-02-02 13:45:52 +07:00
parent 3e32a693ad
commit 8cde4ab638
9 changed files with 103 additions and 140 deletions

View file

@ -180,46 +180,3 @@ var _ = Describe("Crypto Stream", func() {
})
})
})
var _ = Describe("Post Handshake Crypto Stream", func() {
var (
cs cryptoStream
framer framer
)
BeforeEach(func() {
framer = newFramer(NewMockStreamGetter(mockCtrl), protocol.VersionTLS)
cs = newPostHandshakeCryptoStream(framer)
})
It("queues CRYPTO frames when writing data", func() {
n, err := cs.Write([]byte("foo"))
Expect(err).ToNot(HaveOccurred())
Expect(n).To(Equal(3))
n, err = cs.Write([]byte("bar"))
Expect(err).ToNot(HaveOccurred())
Expect(n).To(Equal(3))
frames, _ := framer.AppendControlFrames(nil, 1000)
Expect(frames).To(HaveLen(2))
fs := []wire.Frame{frames[0].Frame, frames[1].Frame}
Expect(fs).To(ContainElement(&wire.CryptoFrame{Data: []byte("foo")}))
Expect(fs).To(ContainElement(&wire.CryptoFrame{Data: []byte("bar"), Offset: 3}))
})
It("splits large writes into multiple frames", func() {
size := 10 * protocol.MaxPostHandshakeCryptoFrameSize
n, err := cs.Write(make([]byte, size))
Expect(err).ToNot(HaveOccurred())
Expect(n).To(BeEquivalentTo(size))
frames, _ := framer.AppendControlFrames(nil, protocol.MaxByteCount)
Expect(frames).To(HaveLen(11)) // one more for framing overhead
var dataLen int
for _, f := range frames {
Expect(f.Frame.Length(protocol.VersionTLS)).To(BeNumerically("<=", protocol.MaxPostHandshakeCryptoFrameSize))
Expect(f.Frame).To(BeAssignableToTypeOf(&wire.CryptoFrame{}))
dataLen += len(f.Frame.(*wire.CryptoFrame).Data)
}
Expect(dataLen).To(BeEquivalentTo(size))
})
})