only accept 0-RTT it the active_connection_id_limit didn't change

This commit is contained in:
Marten Seemann 2021-03-03 21:52:45 +08:00
parent 2c45f2b11d
commit 35da77afd1
2 changed files with 17 additions and 17 deletions

View file

@ -482,7 +482,7 @@ var _ = Describe("Transport Parameters", func() {
}) })
Context("rejects the parameters if they changed", func() { Context("rejects the parameters if they changed", func() {
var p *TransportParameters var p TransportParameters
params := &TransportParameters{ params := &TransportParameters{
InitialMaxStreamDataBidiLocal: 1, InitialMaxStreamDataBidiLocal: 1,
InitialMaxStreamDataBidiRemote: 2, InitialMaxStreamDataBidiRemote: 2,
@ -490,48 +490,47 @@ var _ = Describe("Transport Parameters", func() {
InitialMaxData: 4, InitialMaxData: 4,
MaxBidiStreamNum: 5, MaxBidiStreamNum: 5,
MaxUniStreamNum: 6, MaxUniStreamNum: 6,
ActiveConnectionIDLimit: 7,
} }
BeforeEach(func() { BeforeEach(func() {
p = &TransportParameters{ p = *params
InitialMaxStreamDataBidiLocal: 1, Expect(params.ValidFor0RTT(&p)).To(BeTrue())
InitialMaxStreamDataBidiRemote: 2,
InitialMaxStreamDataUni: 3,
InitialMaxData: 4,
MaxBidiStreamNum: 5,
MaxUniStreamNum: 6,
}
Expect(params.ValidFor0RTT(p)).To(BeTrue())
}) })
It("rejects the parameters if the InitialMaxStreamDataBidiLocal changed", func() { It("rejects the parameters if the InitialMaxStreamDataBidiLocal changed", func() {
p.InitialMaxStreamDataBidiLocal = 0 p.InitialMaxStreamDataBidiLocal = 0
Expect(params.ValidFor0RTT(p)).To(BeFalse()) Expect(params.ValidFor0RTT(&p)).To(BeFalse())
}) })
It("rejects the parameters if the InitialMaxStreamDataBidiRemote changed", func() { It("rejects the parameters if the InitialMaxStreamDataBidiRemote changed", func() {
p.InitialMaxStreamDataBidiRemote = 0 p.InitialMaxStreamDataBidiRemote = 0
Expect(params.ValidFor0RTT(p)).To(BeFalse()) Expect(params.ValidFor0RTT(&p)).To(BeFalse())
}) })
It("rejects the parameters if the InitialMaxStreamDataUni changed", func() { It("rejects the parameters if the InitialMaxStreamDataUni changed", func() {
p.InitialMaxStreamDataUni = 0 p.InitialMaxStreamDataUni = 0
Expect(params.ValidFor0RTT(p)).To(BeFalse()) Expect(params.ValidFor0RTT(&p)).To(BeFalse())
}) })
It("rejects the parameters if the InitialMaxData changed", func() { It("rejects the parameters if the InitialMaxData changed", func() {
p.InitialMaxData = 0 p.InitialMaxData = 0
Expect(params.ValidFor0RTT(p)).To(BeFalse()) Expect(params.ValidFor0RTT(&p)).To(BeFalse())
}) })
It("rejects the parameters if the MaxBidiStreamNum changed", func() { It("rejects the parameters if the MaxBidiStreamNum changed", func() {
p.MaxBidiStreamNum = 0 p.MaxBidiStreamNum = 0
Expect(params.ValidFor0RTT(p)).To(BeFalse()) Expect(params.ValidFor0RTT(&p)).To(BeFalse())
}) })
It("rejects the parameters if the MaxUniStreamNum changed", func() { It("rejects the parameters if the MaxUniStreamNum changed", func() {
p.MaxUniStreamNum = 0 p.MaxUniStreamNum = 0
Expect(params.ValidFor0RTT(p)).To(BeFalse()) Expect(params.ValidFor0RTT(&p)).To(BeFalse())
})
It("rejects the parameters if the ActiveConnectionIDLimit changed", func() {
p.ActiveConnectionIDLimit = 0
Expect(params.ValidFor0RTT(&p)).To(BeFalse())
}) })
}) })
}) })

View file

@ -446,7 +446,8 @@ func (p *TransportParameters) ValidFor0RTT(tp *TransportParameters) bool {
p.InitialMaxStreamDataUni == tp.InitialMaxStreamDataUni && p.InitialMaxStreamDataUni == tp.InitialMaxStreamDataUni &&
p.InitialMaxData == tp.InitialMaxData && p.InitialMaxData == tp.InitialMaxData &&
p.MaxBidiStreamNum == tp.MaxBidiStreamNum && p.MaxBidiStreamNum == tp.MaxBidiStreamNum &&
p.MaxUniStreamNum == tp.MaxUniStreamNum p.MaxUniStreamNum == tp.MaxUniStreamNum &&
p.ActiveConnectionIDLimit == tp.ActiveConnectionIDLimit
} }
// String returns a string representation, intended for logging. // String returns a string representation, intended for logging.