diff --git a/internal/handshake/crypto_setup_tls.go b/internal/handshake/crypto_setup_tls.go index d8e4245c1..18dab0b37 100644 --- a/internal/handshake/crypto_setup_tls.go +++ b/internal/handshake/crypto_setup_tls.go @@ -120,7 +120,7 @@ func NewCryptoSetupTLSClient( nullAEAD: nullAEAD, keyDerivation: crypto.DeriveAESKeys, aeadChanged: aeadChanged, - nextPacketType: protocol.PacketTypeClientInitial, + nextPacketType: protocol.PacketTypeInitial, }, nil } @@ -211,9 +211,9 @@ func (h *cryptoSetupTLS) determineNextPacketType() error { if h.perspective == protocol.PerspectiveServer { switch state { case "ServerStateStart": // if we're still at ServerStateStart when writing the first packet, that means we've come back to that state by sending a HelloRetryRequest - h.nextPacketType = protocol.PacketTypeServerStatelessRetry + h.nextPacketType = protocol.PacketTypeRetry case "ServerStateWaitFinished": - h.nextPacketType = protocol.PacketTypeServerCleartext + h.nextPacketType = protocol.PacketTypeCleartext default: // TODO: accept 0-RTT data return fmt.Errorf("Unexpected handshake state: %s", state) @@ -222,7 +222,7 @@ func (h *cryptoSetupTLS) determineNextPacketType() error { } // client if state != "ClientStateWaitSH" { - h.nextPacketType = protocol.PacketTypeClientCleartext + h.nextPacketType = protocol.PacketTypeCleartext } return nil } diff --git a/internal/handshake/crypto_setup_tls_test.go b/internal/handshake/crypto_setup_tls_test.go index 84b77d968..148f6a55c 100644 --- a/internal/handshake/crypto_setup_tls_test.go +++ b/internal/handshake/crypto_setup_tls_test.go @@ -99,7 +99,7 @@ var _ = Describe("TLS Crypto Setup", func() { }) It("sends a Client Initial first", func() { - Expect(csClient.GetNextPacketType()).To(Equal(protocol.PacketTypeClientInitial)) + Expect(csClient.GetNextPacketType()).To(Equal(protocol.PacketTypeInitial)) }) It("sends a Client Cleartext after the server sent a Server Hello", func() { @@ -118,14 +118,14 @@ var _ = Describe("TLS Crypto Setup", func() { cs.tls.(*mockhandshake.MockmintTLS).EXPECT().State().Return(mint.ConnectionState{HandshakeState: "ServerStateStart"}) err := cs.determineNextPacketType() Expect(err).ToNot(HaveOccurred()) - Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeServerStatelessRetry)) + Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeRetry)) }) It("sends a Server Cleartext packet", func() { cs.tls.(*mockhandshake.MockmintTLS).EXPECT().State().Return(mint.ConnectionState{HandshakeState: "ServerStateWaitFinished"}) err := cs.determineNextPacketType() Expect(err).ToNot(HaveOccurred()) - Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeServerCleartext)) + Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeCleartext)) }) }) }) diff --git a/internal/protocol/protocol.go b/internal/protocol/protocol.go index 8acceff10..84beb8ee8 100644 --- a/internal/protocol/protocol.go +++ b/internal/protocol/protocol.go @@ -27,16 +27,14 @@ type PacketType uint8 const ( // PacketTypeVersionNegotiation is the packet type of a Version Negotiation packet PacketTypeVersionNegotiation PacketType = 1 - // PacketTypeClientInitial is the packet type of a Client Initial packet - PacketTypeClientInitial PacketType = 2 - // PacketTypeServerStatelessRetry is the packet type of a Server Stateless Retry packet - PacketTypeServerStatelessRetry PacketType = 3 - // PacketTypeServerCleartext is the packet type of a Server Cleartext packet - PacketTypeServerCleartext PacketType = 4 - // PacketTypeClientCleartext is the packet type of a Client Cleartext packet - PacketTypeClientCleartext PacketType = 5 + // PacketTypeInitial is the packet type of a Initial packet + PacketTypeInitial PacketType = 2 + // PacketTypeRetry is the packet type of a Retry packet + PacketTypeRetry PacketType = 3 + // PacketTypeCleartext is the packet type of a Cleartext packet + PacketTypeCleartext PacketType = 4 // PacketType0RTT is the packet type of a 0-RTT packet - PacketType0RTT PacketType = 6 + PacketType0RTT PacketType = 5 ) // A ConnectionID in QUIC diff --git a/server.go b/server.go index 056dca723..22b07575e 100644 --- a/server.go +++ b/server.go @@ -279,7 +279,7 @@ func (s *server) handlePacket(pconn net.PacketConn, remoteAddr net.Addr, packet } } // send an IETF draft style Version Negotiation Packet, if the client sent an unsupported version with an IETF draft style header - if hdr.Type == protocol.PacketTypeClientInitial && !protocol.IsSupportedVersion(s.config.Versions, hdr.Version) { + if hdr.Type == protocol.PacketTypeInitial && !protocol.IsSupportedVersion(s.config.Versions, hdr.Version) { _, err := pconn.WriteTo(wire.ComposeVersionNegotiation(hdr.ConnectionID, hdr.PacketNumber, s.config.Versions), remoteAddr) return err } diff --git a/server_test.go b/server_test.go index 350c83c9b..0688380e8 100644 --- a/server_test.go +++ b/server_test.go @@ -434,7 +434,7 @@ var _ = Describe("Server", func() { config.Versions = []protocol.VersionNumber{99} b := &bytes.Buffer{} hdr := wire.Header{ - Type: protocol.PacketTypeClientInitial, + Type: protocol.PacketTypeInitial, IsLongHeader: true, ConnectionID: 0x1337, PacketNumber: 0x55,