mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
qlog the key phase bit
This commit is contained in:
parent
c75da7965b
commit
93e3873141
3 changed files with 27 additions and 0 deletions
|
@ -22,6 +22,8 @@ type (
|
||||||
EncryptionLevel = protocol.EncryptionLevel
|
EncryptionLevel = protocol.EncryptionLevel
|
||||||
// The KeyPhase is the key phase of the 1-RTT keys.
|
// The KeyPhase is the key phase of the 1-RTT keys.
|
||||||
KeyPhase = protocol.KeyPhase
|
KeyPhase = protocol.KeyPhase
|
||||||
|
// The KeyPhaseBit is the value of the key phase bit of the 1-RTT packets.
|
||||||
|
KeyPhaseBit = protocol.KeyPhaseBit
|
||||||
// The PacketNumber is the packet number of a packet.
|
// The PacketNumber is the packet number of a packet.
|
||||||
PacketNumber = protocol.PacketNumber
|
PacketNumber = protocol.PacketNumber
|
||||||
// The Perspective is the role of a QUIC endpoint (client or server).
|
// The Perspective is the role of a QUIC endpoint (client or server).
|
||||||
|
@ -53,6 +55,13 @@ type (
|
||||||
RTTStats = utils.RTTStats
|
RTTStats = utils.RTTStats
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// KeyPhaseZero is key phase bit 0
|
||||||
|
KeyPhaseZero KeyPhaseBit = protocol.KeyPhaseZero
|
||||||
|
// KeyPhaseOne is key phase bit 1
|
||||||
|
KeyPhaseOne KeyPhaseBit = protocol.KeyPhaseOne
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// PerspectiveServer is used for a QUIC server
|
// PerspectiveServer is used for a QUIC server
|
||||||
PerspectiveServer Perspective = protocol.PerspectiveServer
|
PerspectiveServer Perspective = protocol.PerspectiveServer
|
||||||
|
|
|
@ -37,6 +37,9 @@ type packetHeader struct {
|
||||||
Version logging.VersionNumber
|
Version logging.VersionNumber
|
||||||
SrcConnectionID logging.ConnectionID
|
SrcConnectionID logging.ConnectionID
|
||||||
DestConnectionID logging.ConnectionID
|
DestConnectionID logging.ConnectionID
|
||||||
|
|
||||||
|
hasKeyPhase bool
|
||||||
|
KeyPhaseBit logging.KeyPhaseBit
|
||||||
}
|
}
|
||||||
|
|
||||||
func transformHeader(hdr *wire.Header) *packetHeader {
|
func transformHeader(hdr *wire.Header) *packetHeader {
|
||||||
|
@ -52,6 +55,10 @@ func transformHeader(hdr *wire.Header) *packetHeader {
|
||||||
func transformExtendedHeader(hdr *wire.ExtendedHeader) *packetHeader {
|
func transformExtendedHeader(hdr *wire.ExtendedHeader) *packetHeader {
|
||||||
h := transformHeader(&hdr.Header)
|
h := transformHeader(&hdr.Header)
|
||||||
h.PacketNumber = hdr.PacketNumber
|
h.PacketNumber = hdr.PacketNumber
|
||||||
|
if !hdr.IsLongHeader {
|
||||||
|
h.hasKeyPhase = true
|
||||||
|
h.KeyPhaseBit = hdr.KeyPhase
|
||||||
|
}
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,4 +81,12 @@ func (h packetHeader) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
if h.DestConnectionID.Len() > 0 {
|
if h.DestConnectionID.Len() > 0 {
|
||||||
enc.StringKey("dcid", connectionID(h.DestConnectionID).String())
|
enc.StringKey("dcid", connectionID(h.DestConnectionID).String())
|
||||||
}
|
}
|
||||||
|
if h.hasKeyPhase {
|
||||||
|
switch h.KeyPhaseBit {
|
||||||
|
case logging.KeyPhaseZero:
|
||||||
|
enc.StringKey("key_phase_bit", "0")
|
||||||
|
case logging.KeyPhaseOne:
|
||||||
|
enc.StringKey("key_phase_bit", "1")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ var _ = Describe("Packet Header", func() {
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"packet_number": 42,
|
"packet_number": 42,
|
||||||
"dcil": 0,
|
"dcil": 0,
|
||||||
|
"key_phase_bit": "0",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -108,11 +109,13 @@ var _ = Describe("Packet Header", func() {
|
||||||
&wire.ExtendedHeader{
|
&wire.ExtendedHeader{
|
||||||
PacketNumber: 42,
|
PacketNumber: 42,
|
||||||
Header: wire.Header{DestConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}},
|
Header: wire.Header{DestConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}},
|
||||||
|
KeyPhase: protocol.KeyPhaseOne,
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"packet_number": 42,
|
"packet_number": 42,
|
||||||
"dcil": 4,
|
"dcil": 4,
|
||||||
"dcid": "deadbeef",
|
"dcid": "deadbeef",
|
||||||
|
"key_phase_bit": "1",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue