mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 13:17:36 +03:00
parse IETF headers independent of the sender's perspective
The IETF header format allows parsing of the header without knowing which peer sent the packet.
This commit is contained in:
parent
70f6e3651e
commit
8f2fed1b10
9 changed files with 74 additions and 74 deletions
|
@ -386,6 +386,7 @@ var _ = Describe("Server", func() {
|
|||
})
|
||||
|
||||
It("errors on packets that are smaller than the Payload Length in the packet header", func() {
|
||||
serv.supportsTLS = true
|
||||
b := &bytes.Buffer{}
|
||||
hdr := &wire.Header{
|
||||
IsLongHeader: true,
|
||||
|
@ -401,6 +402,7 @@ var _ = Describe("Server", func() {
|
|||
})
|
||||
|
||||
It("cuts packets at the payload length", func() {
|
||||
serv.supportsTLS = true
|
||||
err := serv.handlePacket(nil, firstPacket)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := &bytes.Buffer{}
|
||||
|
@ -419,6 +421,22 @@ var _ = Describe("Server", func() {
|
|||
Expect(serv.sessions[string(connID)].(*mockSession).handledPackets[1].data).To(HaveLen(123))
|
||||
})
|
||||
|
||||
It("drops packets with invalid packet types", func() {
|
||||
serv.supportsTLS = true
|
||||
b := &bytes.Buffer{}
|
||||
hdr := &wire.Header{
|
||||
IsLongHeader: true,
|
||||
Type: protocol.PacketTypeRetry,
|
||||
PayloadLen: 123,
|
||||
SrcConnectionID: connID,
|
||||
DestConnectionID: connID,
|
||||
Version: versionIETFFrames,
|
||||
}
|
||||
Expect(hdr.Write(b, protocol.PerspectiveClient, versionIETFFrames)).To(Succeed())
|
||||
err := serv.handlePacket(nil, append(b.Bytes(), make([]byte, 456)...))
|
||||
Expect(err).To(MatchError("Received unsupported packet type: Retry"))
|
||||
})
|
||||
|
||||
It("ignores Public Resets", func() {
|
||||
err := serv.handlePacket(nil, firstPacket)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue