forked from quic-go/quic-go
only use the conn ID backwards compatibility mode with draft-29
This commit is contained in:
@@ -22,6 +22,8 @@ type connIDGenerator struct {
|
|||||||
retireConnectionID func(protocol.ConnectionID)
|
retireConnectionID func(protocol.ConnectionID)
|
||||||
replaceWithClosed func(protocol.ConnectionID, packetHandler)
|
replaceWithClosed func(protocol.ConnectionID, packetHandler)
|
||||||
queueControlFrame func(wire.Frame)
|
queueControlFrame func(wire.Frame)
|
||||||
|
|
||||||
|
version protocol.VersionNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConnIDGenerator(
|
func newConnIDGenerator(
|
||||||
@@ -33,6 +35,7 @@ func newConnIDGenerator(
|
|||||||
retireConnectionID func(protocol.ConnectionID),
|
retireConnectionID func(protocol.ConnectionID),
|
||||||
replaceWithClosed func(protocol.ConnectionID, packetHandler),
|
replaceWithClosed func(protocol.ConnectionID, packetHandler),
|
||||||
queueControlFrame func(wire.Frame),
|
queueControlFrame func(wire.Frame),
|
||||||
|
version protocol.VersionNumber,
|
||||||
) *connIDGenerator {
|
) *connIDGenerator {
|
||||||
m := &connIDGenerator{
|
m := &connIDGenerator{
|
||||||
connIDLen: initialConnectionID.Len(),
|
connIDLen: initialConnectionID.Len(),
|
||||||
@@ -43,6 +46,7 @@ func newConnIDGenerator(
|
|||||||
retireConnectionID: retireConnectionID,
|
retireConnectionID: retireConnectionID,
|
||||||
replaceWithClosed: replaceWithClosed,
|
replaceWithClosed: replaceWithClosed,
|
||||||
queueControlFrame: queueControlFrame,
|
queueControlFrame: queueControlFrame,
|
||||||
|
version: version,
|
||||||
}
|
}
|
||||||
m.activeSrcConnIDs[0] = initialConnectionID
|
m.activeSrcConnIDs[0] = initialConnectionID
|
||||||
m.initialClientDestConnID = initialClientDestConnID
|
m.initialClientDestConnID = initialClientDestConnID
|
||||||
@@ -76,7 +80,7 @@ func (m *connIDGenerator) Retire(seq uint64, sentWithDestConnID protocol.Connect
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if connID.Equal(sentWithDestConnID) && !RetireBugBackwardsCompatibilityMode {
|
if connID.Equal(sentWithDestConnID) && !protocol.UseRetireBugBackwardsCompatibilityMode(RetireBugBackwardsCompatibilityMode, m.version) {
|
||||||
return qerr.NewError(qerr.ProtocolViolation, fmt.Sprintf("tried to retire connection ID %d (%s), which was used as the Destination Connection ID on this packet", seq, connID))
|
return qerr.NewError(qerr.ProtocolViolation, fmt.Sprintf("tried to retire connection ID %d (%s), which was used as the Destination Connection ID on this packet", seq, connID))
|
||||||
}
|
}
|
||||||
m.retireConnectionID(connID)
|
m.retireConnectionID(connID)
|
||||||
@@ -89,7 +93,7 @@ func (m *connIDGenerator) Retire(seq uint64, sentWithDestConnID protocol.Connect
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *connIDGenerator) issueNewConnID() error {
|
func (m *connIDGenerator) issueNewConnID() error {
|
||||||
if RetireBugBackwardsCompatibilityMode {
|
if protocol.UseRetireBugBackwardsCompatibilityMode(RetireBugBackwardsCompatibilityMode, m.version) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
connID, err := protocol.GenerateConnectionID(m.connIDLen)
|
connID, err := protocol.GenerateConnectionID(m.connIDLen)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ var _ = Describe("Connection ID Generator", func() {
|
|||||||
func(c protocol.ConnectionID) { retiredConnIDs = append(retiredConnIDs, c) },
|
func(c protocol.ConnectionID) { retiredConnIDs = append(retiredConnIDs, c) },
|
||||||
func(c protocol.ConnectionID, h packetHandler) { replacedWithClosed[string(c)] = h },
|
func(c protocol.ConnectionID, h packetHandler) { replacedWithClosed[string(c)] = h },
|
||||||
func(f wire.Frame) { queuedFrames = append(queuedFrames, f) },
|
func(f wire.Frame) { queuedFrames = append(queuedFrames, f) },
|
||||||
|
protocol.VersionDraft29,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ func (vn VersionNumber) toGQUICVersion() int {
|
|||||||
return int(10*(vn-gquicVersion0)/0x100) + int(vn%0x10)
|
return int(10*(vn-gquicVersion0)/0x100) + int(vn%0x10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UseRetireBugBackwardsCompatibilityMode says if it is necessary to use the backwards compatilibity mode.
|
||||||
|
// This is only the case if it 1. is enabled and 2. draft-29 is used.
|
||||||
|
func UseRetireBugBackwardsCompatibilityMode(enabled bool, v VersionNumber) bool {
|
||||||
|
return enabled && v == VersionDraft29
|
||||||
|
}
|
||||||
|
|
||||||
// IsSupportedVersion returns true if the server supports this version
|
// IsSupportedVersion returns true if the server supports this version
|
||||||
func IsSupportedVersion(supported []VersionNumber, v VersionNumber) bool {
|
func IsSupportedVersion(supported []VersionNumber, v VersionNumber) bool {
|
||||||
for _, t := range supported {
|
for _, t := range supported {
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ var _ = Describe("Version", func() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("says if backwards compatibility mode should be used", func() {
|
||||||
|
Expect(UseRetireBugBackwardsCompatibilityMode(true, VersionDraft29)).To(BeTrue())
|
||||||
|
Expect(UseRetireBugBackwardsCompatibilityMode(true, VersionDraft32)).To(BeFalse())
|
||||||
|
Expect(UseRetireBugBackwardsCompatibilityMode(false, VersionDraft29)).To(BeFalse())
|
||||||
|
Expect(UseRetireBugBackwardsCompatibilityMode(false, VersionDraft32)).To(BeFalse())
|
||||||
|
})
|
||||||
|
|
||||||
Context("highest supported version", func() {
|
Context("highest supported version", func() {
|
||||||
It("finds the supported version", func() {
|
It("finds the supported version", func() {
|
||||||
supportedVersions := []VersionNumber{1, 2, 3}
|
supportedVersions := []VersionNumber{1, 2, 3}
|
||||||
|
|||||||
@@ -268,6 +268,7 @@ var newSession = func(
|
|||||||
runner.Retire,
|
runner.Retire,
|
||||||
runner.ReplaceWithClosed,
|
runner.ReplaceWithClosed,
|
||||||
s.queueControlFrame,
|
s.queueControlFrame,
|
||||||
|
s.version,
|
||||||
)
|
)
|
||||||
s.preSetup()
|
s.preSetup()
|
||||||
s.sentPacketHandler, s.receivedPacketHandler = ackhandler.NewAckHandler(
|
s.sentPacketHandler, s.receivedPacketHandler = ackhandler.NewAckHandler(
|
||||||
@@ -390,6 +391,7 @@ var newClientSession = func(
|
|||||||
runner.Retire,
|
runner.Retire,
|
||||||
runner.ReplaceWithClosed,
|
runner.ReplaceWithClosed,
|
||||||
s.queueControlFrame,
|
s.queueControlFrame,
|
||||||
|
s.version,
|
||||||
)
|
)
|
||||||
s.preSetup()
|
s.preSetup()
|
||||||
s.sentPacketHandler, s.receivedPacketHandler = ackhandler.NewAckHandler(
|
s.sentPacketHandler, s.receivedPacketHandler = ackhandler.NewAckHandler(
|
||||||
|
|||||||
Reference in New Issue
Block a user