mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
Merge pull request #1707 from lucas-clemente/remove-raw-header
remove unnecessary Raw byte slice from the header
This commit is contained in:
commit
3fb58da7e6
3 changed files with 3 additions and 7 deletions
|
@ -15,7 +15,6 @@ type ExtendedHeader struct {
|
|||
Header
|
||||
|
||||
typeByte byte
|
||||
Raw []byte
|
||||
|
||||
PacketNumberLen protocol.PacketNumberLen
|
||||
PacketNumber protocol.PacketNumber
|
||||
|
|
|
@ -69,18 +69,16 @@ func (u *packetUnpacker) Unpack(hdr *wire.Header, data []byte) (*unpackedPacket,
|
|||
&data[0],
|
||||
data[hdrLen:hdrLen+4],
|
||||
)
|
||||
|
||||
// 3. parse the header (and learn the actual length of the packet number)
|
||||
extHdr, err := hdr.ParseExtended(r, u.version)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing extended header: %s", err)
|
||||
}
|
||||
extHdr.Raw = data[:hdrLen+int(extHdr.PacketNumberLen)]
|
||||
extHdrLen := hdrLen + int(extHdr.PacketNumberLen)
|
||||
// 4. if the packet number is shorter than 4 bytes, replace the remaining bytes with the copy we saved earlier
|
||||
if extHdr.PacketNumberLen != protocol.PacketNumberLen4 {
|
||||
copy(data[hdrLen+int(extHdr.PacketNumberLen):hdrLen+4], origPNBytes[int(extHdr.PacketNumberLen):])
|
||||
copy(data[extHdrLen:hdrLen+4], origPNBytes[int(extHdr.PacketNumberLen):])
|
||||
}
|
||||
data = data[hdrLen+int(extHdr.PacketNumberLen):]
|
||||
|
||||
pn := protocol.DecodePacketNumber(
|
||||
extHdr.PacketNumberLen,
|
||||
|
@ -88,7 +86,7 @@ func (u *packetUnpacker) Unpack(hdr *wire.Header, data []byte) (*unpackedPacket,
|
|||
extHdr.PacketNumber,
|
||||
)
|
||||
|
||||
decrypted, err := opener.Open(data[:0], data, pn, extHdr.Raw)
|
||||
decrypted, err := opener.Open(data[extHdrLen:extHdrLen], data[extHdrLen:], pn, data[:extHdrLen])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -492,7 +492,6 @@ var _ = Describe("Session", func() {
|
|||
|
||||
It("informs the ReceivedPacketHandler", func() {
|
||||
hdr := &wire.ExtendedHeader{
|
||||
Raw: []byte("raw header"),
|
||||
PacketNumber: 0x37,
|
||||
PacketNumberLen: protocol.PacketNumberLen1,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue