fix: kcp 协议内部日志细节

This commit is contained in:
2026-03-25 15:09:32 +08:00
parent be013b701b
commit 665a908421
15 changed files with 1117 additions and 42 deletions

View File

@@ -1,7 +1,6 @@
package transport
import (
"encoding/binary"
"net"
"sync"
"time"
@@ -61,7 +60,7 @@ func (c *kcpPacketConnBase) logKCPPacketDebugRecord(record KCPPacketDebugRecord)
_ = c.logger.LogKCPPacketDebugRecord(record)
}
func (c *kcpPacketConnBase) newKCPPacketDebugRecord(event string, remoteAddr net.Addr, packetBytes int, tsUnixNano int64, udpTxID *uint32, kcpConv *uint32) KCPPacketDebugRecord {
func (c *kcpPacketConnBase) newKCPPacketDebugRecord(event string, remoteAddr net.Addr, packetBytes int, tsUnixNano int64, udpTxID *uint32, kcpConv *uint32, segments []KCPPacketDebugSegment) KCPPacketDebugRecord {
record := KCPPacketDebugRecord{
Event: event,
NodeRole: c.nodeRole,
@@ -71,6 +70,7 @@ func (c *kcpPacketConnBase) newKCPPacketDebugRecord(event string, remoteAddr net
PacketBytes: packetBytes,
UDPTXID: udpTxID,
KCPConv: kcpConv,
Segments: append([]KCPPacketDebugSegment(nil), segments...),
TSUnixNano: tsUnixNano,
}
if localAddr := c.conn.LocalAddr(); localAddr != nil {
@@ -81,11 +81,3 @@ func (c *kcpPacketConnBase) newKCPPacketDebugRecord(event string, remoteAddr net
}
return record
}
func parseKCPConversationID(packet []byte) *uint32 {
if len(packet) < 4 {
return nil
}
conv := binary.LittleEndian.Uint32(packet[:4])
return &conv
}