From ce01e99ba1e0f4c52cd064e1e847c5429bb61a16 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Wed, 21 Feb 2018 13:52:26 +0800 Subject: [PATCH] log version negotiation packets --- client.go | 2 ++ internal/protocol/version.go | 2 +- internal/protocol/version_test.go | 1 + internal/wire/ietf_header_test.go | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 955c908e..766d03ab 100644 --- a/client.go +++ b/client.go @@ -347,6 +347,8 @@ func (c *client) handleVersionNegotiationPacket(hdr *wire.Header) error { } } + utils.Infof("Received a Version Negotiation Packet. Supported Versions: %s", hdr.SupportedVersions) + newVersion, ok := protocol.ChooseSupportedVersion(c.config.Versions, hdr.SupportedVersions) if !ok { return qerr.InvalidVersion diff --git a/internal/protocol/version.go b/internal/protocol/version.go index 3135ca85..a7475087 100644 --- a/internal/protocol/version.go +++ b/internal/protocol/version.go @@ -46,7 +46,7 @@ func (vn VersionNumber) String() string { if vn.isGQUIC() { return fmt.Sprintf("gQUIC %d", vn.toGQUICVersion()) } - return fmt.Sprintf("%d", vn) + return fmt.Sprintf("%#x", uint32(vn)) } } diff --git a/internal/protocol/version_test.go b/internal/protocol/version_test.go index 33c5cf38..01de14e3 100644 --- a/internal/protocol/version_test.go +++ b/internal/protocol/version_test.go @@ -35,6 +35,7 @@ var _ = Describe("Version", func() { Expect(VersionNumber(0x51303133).String()).To(Equal("gQUIC 13")) Expect(VersionNumber(0x51303235).String()).To(Equal("gQUIC 25")) Expect(VersionNumber(0x51303438).String()).To(Equal("gQUIC 48")) + Expect(VersionNumber(0x01234567).String()).To(Equal("0x1234567")) }) It("has the right representation for the H2 Alt-Svc tag", func() { diff --git a/internal/wire/ietf_header_test.go b/internal/wire/ietf_header_test.go index 4faa5488..72ff2cba 100644 --- a/internal/wire/ietf_header_test.go +++ b/internal/wire/ietf_header_test.go @@ -392,9 +392,9 @@ var _ = Describe("IETF draft Header", func() { Type: protocol.PacketTypeHandshake, PacketNumber: 0x1337, ConnectionID: 0xdeadbeef, - Version: 253, + Version: 0xfeed, }).logHeader() - Expect(string(buf.Bytes())).To(ContainSubstring("Long Header{Type: Handshake, ConnectionID: 0xdeadbeef, PacketNumber: 0x1337, Version: 253}")) + Expect(string(buf.Bytes())).To(ContainSubstring("Long Header{Type: Handshake, ConnectionID: 0xdeadbeef, PacketNumber: 0x1337, Version: 0xfeed}")) }) It("logs Short Headers containing a connection ID", func() {