forked from quic-go/quic-go
save last sent CHLO in client CryptoSetup
This commit is contained in:
@@ -26,6 +26,7 @@ type cryptoSetupClient struct {
|
||||
sno []byte
|
||||
nonc []byte
|
||||
diversificationNonce []byte
|
||||
lastSentCHLO []byte
|
||||
certManager *crypto.CertManager
|
||||
}
|
||||
|
||||
@@ -168,6 +169,9 @@ func (h *cryptoSetupClient) sendCHLO() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
h.lastSentCHLO = b.Bytes()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,21 @@ var _ = Describe("Crypto setup", func() {
|
||||
Expect(cs.cryptoStream.(*mockStream).dataWritten.Len()).To(BeNumerically(">", protocol.ClientHelloMinimumSize))
|
||||
})
|
||||
|
||||
It("saves the last sent CHLO", func() {
|
||||
// send first CHLO
|
||||
err := cs.sendCHLO()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(cs.cryptoStream.(*mockStream).dataWritten.Bytes()).To(Equal(cs.lastSentCHLO))
|
||||
cs.cryptoStream.(*mockStream).dataWritten.Reset()
|
||||
firstCHLO := cs.lastSentCHLO
|
||||
// send second CHLO
|
||||
cs.sno = []byte("foobar")
|
||||
err = cs.sendCHLO()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(cs.cryptoStream.(*mockStream).dataWritten.Bytes()).To(Equal(cs.lastSentCHLO))
|
||||
Expect(cs.lastSentCHLO).ToNot(Equal(firstCHLO))
|
||||
})
|
||||
|
||||
It("has the right values for an inchoate CHLO", func() {
|
||||
tags := cs.getTags()
|
||||
Expect(tags).To(HaveKey(TagSNI))
|
||||
|
||||
Reference in New Issue
Block a user