Skip to content

Commit 5fb06bf

Browse files
committed
Correctly implement QUIC sniffer when handling multiple initial packets
1 parent 807d4b2 commit 5fb06bf

File tree

2 files changed

+189
-165
lines changed

2 files changed

+189
-165
lines changed

app/dispatcher/default.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ func (r *cachedReader) Cache(b *buf.Buffer) {
3939
if !mb.IsEmpty() {
4040
r.cache, _ = buf.MergeMulti(r.cache, mb)
4141
}
42-
b.Clear()
43-
rawBytes := b.Extend(buf.Size)
42+
cacheLen := r.cache.Len()
43+
if cacheLen <= b.Cap() {
44+
b.Clear()
45+
} else {
46+
b.Release()
47+
*b = *buf.NewWithSize(cacheLen)
48+
}
49+
rawBytes := b.Extend(cacheLen)
4450
n := r.cache.Copy(rawBytes)
4551
b.Resize(0, int32(n))
4652
r.Unlock()

0 commit comments

Comments
 (0)