QUIC sniffer: handle multiple initial packets (#3802)

* QUIC sniffer: handle multiple initial packets
Basically copied from Vigilans/v2ray-core@8f33db0

Co-Authored-By: Vigilans <vigilans@foxmail.com>

* Remove unnecessary file

---------

Co-authored-by: Vigilans <vigilans@foxmail.com>
This commit is contained in:
风扇滑翔翼 2024-09-14 01:32:43 +08:00 committed by GitHub
parent 7970f240de
commit 781aaee21f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 217 additions and 178 deletions

View file

@ -41,8 +41,14 @@ func (r *cachedReader) Cache(b *buf.Buffer) {
if !mb.IsEmpty() {
r.cache, _ = buf.MergeMulti(r.cache, mb)
}
b.Clear()
rawBytes := b.Extend(buf.Size)
cacheLen := r.cache.Len()
if cacheLen <= b.Cap() {
b.Clear()
} else {
b.Release()
*b = *buf.NewWithSize(cacheLen)
}
rawBytes := b.Extend(cacheLen)
n := r.cache.Copy(rawBytes)
b.Resize(0, int32(n))
r.Unlock()