MCPcopy Create free account
hub / github.com/HyBuildNet/quic-relay / reassembleCryptoData

Function reassembleCryptoData

internal/proxy/parser.go:658–690  ·  view source on GitHub ↗

reassembleCryptoData reassembles CRYPTO frames into a contiguous buffer

(frames []CryptoFrame)

Source from the content-addressed store, hash-verified

656
657// reassembleCryptoData reassembles CRYPTO frames into a contiguous buffer
658func reassembleCryptoData(frames []CryptoFrame) []byte {
659 if len(frames) == 0 {
660 return nil
661 }
662
663 // Find the maximum extent of the data
664 var maxEnd uint64
665 for _, f := range frames {
666 end := f.Offset + uint64(len(f.Data))
667 if end > maxEnd {
668 maxEnd = end
669 }
670 }
671
672 // Create buffer and copy data
673 // Limit to reasonable size to prevent memory issues
674 if maxEnd > 16384 {
675 maxEnd = 16384 // Max 16KB for ClientHello
676 }
677
678 buffer := make([]byte, maxEnd)
679 for _, f := range frames {
680 if f.Offset < maxEnd {
681 copyLen := uint64(len(f.Data))
682 if f.Offset+copyLen > maxEnd {
683 copyLen = maxEnd - f.Offset
684 }
685 copy(buffer[f.Offset:], f.Data[:copyLen])
686 }
687 }
688
689 return buffer
690}
691
692// parseTLSClientHello parses TLS 1.3 ClientHello.
693func parseTLSClientHello(data []byte) (*handler.ClientHello, error) {

Callers 1

parseFramesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected