mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
reverse the order of the SupportedVersions slice
For the client, the Versions option in the quic.Config encodes the first entry is the preferred version. If not set, this should default to the highest supported version.
This commit is contained in:
parent
b305cd674f
commit
9db23eceed
4 changed files with 12 additions and 12 deletions
|
@ -274,9 +274,9 @@ func (s *Server) SetQuicHeaders(hdr http.Header) error {
|
|||
}
|
||||
|
||||
if s.supportedVersionsAsString == "" {
|
||||
for i := len(protocol.SupportedVersions) - 1; i >= 0; i-- {
|
||||
s.supportedVersionsAsString += strconv.Itoa(int(protocol.SupportedVersions[i]))
|
||||
if i != 0 {
|
||||
for i, v := range protocol.SupportedVersions {
|
||||
s.supportedVersionsAsString += strconv.Itoa(int(v))
|
||||
if i != len(protocol.SupportedVersions)-1 {
|
||||
s.supportedVersionsAsString += ","
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ const (
|
|||
)
|
||||
|
||||
// SupportedVersions lists the versions that the server supports
|
||||
// must be in sorted order
|
||||
// must be in sorted descending order
|
||||
var SupportedVersions = []VersionNumber{
|
||||
Version35, Version36, Version37,
|
||||
Version37, Version36, Version35,
|
||||
}
|
||||
|
||||
// VersionNumberToTag maps version numbers ('32') to tags ('Q032')
|
||||
|
@ -50,9 +50,9 @@ func HighestSupportedVersion(other []VersionNumber) (bool, VersionNumber) {
|
|||
}
|
||||
}
|
||||
|
||||
for i := len(SupportedVersions) - 1; i >= 0; i-- {
|
||||
for _, v := range SupportedVersions {
|
||||
for _, ver := range otherSupported {
|
||||
if ver == SupportedVersions[i] {
|
||||
if ver == v {
|
||||
return true, ver
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ var _ = Describe("Version", func() {
|
|||
|
||||
It("has supported versions in sorted order", func() {
|
||||
for i := 0; i < len(SupportedVersions)-1; i++ {
|
||||
Expect(SupportedVersions[i]).To(BeNumerically("<", SupportedVersions[i+1]))
|
||||
Expect(SupportedVersions[i]).To(BeNumerically(">", SupportedVersions[i+1]))
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -39,7 +39,7 @@ var _ = Describe("Version", func() {
|
|||
})
|
||||
|
||||
It("finds the supported version", func() {
|
||||
SupportedVersions = []VersionNumber{1, 2, 3}
|
||||
SupportedVersions = []VersionNumber{3, 2, 1}
|
||||
other := []VersionNumber{3, 4, 5, 6}
|
||||
found, ver := HighestSupportedVersion(other)
|
||||
Expect(found).To(BeTrue())
|
||||
|
@ -47,7 +47,7 @@ var _ = Describe("Version", func() {
|
|||
})
|
||||
|
||||
It("picks the highest supported version", func() {
|
||||
SupportedVersions = []VersionNumber{1, 2, 3, 6, 7}
|
||||
SupportedVersions = []VersionNumber{7, 6, 3, 2, 1}
|
||||
other := []VersionNumber{3, 6, 1, 8, 2, 10}
|
||||
found, ver := HighestSupportedVersion(other)
|
||||
Expect(found).To(BeTrue())
|
||||
|
@ -55,7 +55,7 @@ var _ = Describe("Version", func() {
|
|||
})
|
||||
|
||||
It("handles empty inputs", func() {
|
||||
SupportedVersions = []VersionNumber{101, 102}
|
||||
SupportedVersions = []VersionNumber{102, 101}
|
||||
Expect(HighestSupportedVersion([]VersionNumber{})).To(BeFalse())
|
||||
SupportedVersions = []VersionNumber{}
|
||||
Expect(HighestSupportedVersion([]VersionNumber{1, 2})).To(BeFalse())
|
||||
|
|
|
@ -264,7 +264,7 @@ var _ = Describe("Server", func() {
|
|||
Expect(serv.sessions[connID].(*mockSession).packetCount).To(Equal(1))
|
||||
b := &bytes.Buffer{}
|
||||
// add an unsupported version
|
||||
utils.WriteUint32(b, protocol.VersionNumberToTag(protocol.SupportedVersions[0]-2))
|
||||
utils.WriteUint32(b, protocol.VersionNumberToTag(protocol.SupportedVersions[0]+1))
|
||||
data := []byte{0x09, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c}
|
||||
data = append(append(data, b.Bytes()...), 0x01)
|
||||
err = serv.handlePacket(nil, nil, data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue