forked from quic-go/quic-go
1474
connection.go
1474
connection.go
File diff suppressed because it is too large
Load Diff
@@ -50,23 +50,23 @@ func toLoggingAckFrame(f *wire.AckFrame) *logging.AckFrame {
|
|||||||
return ack
|
return ack
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Conn) logLongHeaderPacket(p *longHeaderPacket, ecn protocol.ECN) {
|
func (c *Conn) logLongHeaderPacket(p *longHeaderPacket, ecn protocol.ECN) {
|
||||||
// quic-go logging
|
// quic-go logging
|
||||||
if s.logger.Debug() {
|
if c.logger.Debug() {
|
||||||
p.header.Log(s.logger)
|
p.header.Log(c.logger)
|
||||||
if p.ack != nil {
|
if p.ack != nil {
|
||||||
wire.LogFrame(s.logger, p.ack, true)
|
wire.LogFrame(c.logger, p.ack, true)
|
||||||
}
|
}
|
||||||
for _, frame := range p.frames {
|
for _, frame := range p.frames {
|
||||||
wire.LogFrame(s.logger, frame.Frame, true)
|
wire.LogFrame(c.logger, frame.Frame, true)
|
||||||
}
|
}
|
||||||
for _, frame := range p.streamFrames {
|
for _, frame := range p.streamFrames {
|
||||||
wire.LogFrame(s.logger, frame.Frame, true)
|
wire.LogFrame(c.logger, frame.Frame, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tracing
|
// tracing
|
||||||
if s.tracer != nil && s.tracer.SentLongHeaderPacket != nil {
|
if c.tracer != nil && c.tracer.SentLongHeaderPacket != nil {
|
||||||
frames := make([]logging.Frame, 0, len(p.frames))
|
frames := make([]logging.Frame, 0, len(p.frames))
|
||||||
for _, f := range p.frames {
|
for _, f := range p.frames {
|
||||||
frames = append(frames, toLoggingFrame(f.Frame))
|
frames = append(frames, toLoggingFrame(f.Frame))
|
||||||
@@ -78,11 +78,11 @@ func (s *Conn) logLongHeaderPacket(p *longHeaderPacket, ecn protocol.ECN) {
|
|||||||
if p.ack != nil {
|
if p.ack != nil {
|
||||||
ack = toLoggingAckFrame(p.ack)
|
ack = toLoggingAckFrame(p.ack)
|
||||||
}
|
}
|
||||||
s.tracer.SentLongHeaderPacket(p.header, p.length, ecn, ack, frames)
|
c.tracer.SentLongHeaderPacket(p.header, p.length, ecn, ack, frames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Conn) logShortHeaderPacket(
|
func (c *Conn) logShortHeaderPacket(
|
||||||
destConnID protocol.ConnectionID,
|
destConnID protocol.ConnectionID,
|
||||||
ackFrame *wire.AckFrame,
|
ackFrame *wire.AckFrame,
|
||||||
frames []ackhandler.Frame,
|
frames []ackhandler.Frame,
|
||||||
@@ -94,25 +94,25 @@ func (s *Conn) logShortHeaderPacket(
|
|||||||
size protocol.ByteCount,
|
size protocol.ByteCount,
|
||||||
isCoalesced bool,
|
isCoalesced bool,
|
||||||
) {
|
) {
|
||||||
if s.logger.Debug() && !isCoalesced {
|
if c.logger.Debug() && !isCoalesced {
|
||||||
s.logger.Debugf("-> Sending packet %d (%d bytes) for connection %s, 1-RTT (ECN: %s)", pn, size, s.logID, ecn)
|
c.logger.Debugf("-> Sending packet %d (%d bytes) for connection %s, 1-RTT (ECN: %s)", pn, size, c.logID, ecn)
|
||||||
}
|
}
|
||||||
// quic-go logging
|
// quic-go logging
|
||||||
if s.logger.Debug() {
|
if c.logger.Debug() {
|
||||||
wire.LogShortHeader(s.logger, destConnID, pn, pnLen, kp)
|
wire.LogShortHeader(c.logger, destConnID, pn, pnLen, kp)
|
||||||
if ackFrame != nil {
|
if ackFrame != nil {
|
||||||
wire.LogFrame(s.logger, ackFrame, true)
|
wire.LogFrame(c.logger, ackFrame, true)
|
||||||
}
|
}
|
||||||
for _, f := range frames {
|
for _, f := range frames {
|
||||||
wire.LogFrame(s.logger, f.Frame, true)
|
wire.LogFrame(c.logger, f.Frame, true)
|
||||||
}
|
}
|
||||||
for _, f := range streamFrames {
|
for _, f := range streamFrames {
|
||||||
wire.LogFrame(s.logger, f.Frame, true)
|
wire.LogFrame(c.logger, f.Frame, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tracing
|
// tracing
|
||||||
if s.tracer != nil && s.tracer.SentShortHeaderPacket != nil {
|
if c.tracer != nil && c.tracer.SentShortHeaderPacket != nil {
|
||||||
fs := make([]logging.Frame, 0, len(frames)+len(streamFrames))
|
fs := make([]logging.Frame, 0, len(frames)+len(streamFrames))
|
||||||
for _, f := range frames {
|
for _, f := range frames {
|
||||||
fs = append(fs, toLoggingFrame(f.Frame))
|
fs = append(fs, toLoggingFrame(f.Frame))
|
||||||
@@ -124,7 +124,7 @@ func (s *Conn) logShortHeaderPacket(
|
|||||||
if ackFrame != nil {
|
if ackFrame != nil {
|
||||||
ack = toLoggingAckFrame(ackFrame)
|
ack = toLoggingAckFrame(ackFrame)
|
||||||
}
|
}
|
||||||
s.tracer.SentShortHeaderPacket(
|
c.tracer.SentShortHeaderPacket(
|
||||||
&logging.ShortHeader{DestConnectionID: destConnID, PacketNumber: pn, PacketNumberLen: pnLen, KeyPhase: kp},
|
&logging.ShortHeader{DestConnectionID: destConnID, PacketNumber: pn, PacketNumberLen: pnLen, KeyPhase: kp},
|
||||||
size,
|
size,
|
||||||
ecn,
|
ecn,
|
||||||
@@ -134,12 +134,12 @@ func (s *Conn) logShortHeaderPacket(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Conn) logCoalescedPacket(packet *coalescedPacket, ecn protocol.ECN) {
|
func (c *Conn) logCoalescedPacket(packet *coalescedPacket, ecn protocol.ECN) {
|
||||||
if s.logger.Debug() {
|
if c.logger.Debug() {
|
||||||
// There's a short period between dropping both Initial and Handshake keys and completion of the handshake,
|
// There's a short period between dropping both Initial and Handshake keys and completion of the handshake,
|
||||||
// during which we might call PackCoalescedPacket but just pack a short header packet.
|
// during which we might call PackCoalescedPacket but just pack a short header packet.
|
||||||
if len(packet.longHdrPackets) == 0 && packet.shortHdrPacket != nil {
|
if len(packet.longHdrPackets) == 0 && packet.shortHdrPacket != nil {
|
||||||
s.logShortHeaderPacket(
|
c.logShortHeaderPacket(
|
||||||
packet.shortHdrPacket.DestConnID,
|
packet.shortHdrPacket.DestConnID,
|
||||||
packet.shortHdrPacket.Ack,
|
packet.shortHdrPacket.Ack,
|
||||||
packet.shortHdrPacket.Frames,
|
packet.shortHdrPacket.Frames,
|
||||||
@@ -154,15 +154,15 @@ func (s *Conn) logCoalescedPacket(packet *coalescedPacket, ecn protocol.ECN) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(packet.longHdrPackets) > 1 {
|
if len(packet.longHdrPackets) > 1 {
|
||||||
s.logger.Debugf("-> Sending coalesced packet (%d parts, %d bytes) for connection %s", len(packet.longHdrPackets), packet.buffer.Len(), s.logID)
|
c.logger.Debugf("-> Sending coalesced packet (%d parts, %d bytes) for connection %s", len(packet.longHdrPackets), packet.buffer.Len(), c.logID)
|
||||||
} else {
|
} else {
|
||||||
s.logger.Debugf("-> Sending packet %d (%d bytes) for connection %s, %s", packet.longHdrPackets[0].header.PacketNumber, packet.buffer.Len(), s.logID, packet.longHdrPackets[0].EncryptionLevel())
|
c.logger.Debugf("-> Sending packet %d (%d bytes) for connection %s, %s", packet.longHdrPackets[0].header.PacketNumber, packet.buffer.Len(), c.logID, packet.longHdrPackets[0].EncryptionLevel())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, p := range packet.longHdrPackets {
|
for _, p := range packet.longHdrPackets {
|
||||||
s.logLongHeaderPacket(p, ecn)
|
c.logLongHeaderPacket(p, ecn)
|
||||||
}
|
}
|
||||||
if p := packet.shortHdrPacket; p != nil {
|
if p := packet.shortHdrPacket; p != nil {
|
||||||
s.logShortHeaderPacket(p.DestConnID, p.Ack, p.Frames, p.StreamFrames, p.PacketNumber, p.PacketNumberLen, p.KeyPhase, ecn, p.Length, true)
|
c.logShortHeaderPacket(p.DestConnID, p.Ack, p.Frames, p.StreamFrames, p.PacketNumber, p.PacketNumberLen, p.KeyPhase, ecn, p.Length, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user