-
Notifications
You must be signed in to change notification settings - Fork 810
Improve packet stream & error handling #1856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve packet stream & error handling #1856
Conversation
Instead of ignoring non-critical unknown packets entirely, write an UnparseablePacket object to the packet stream.
Instead of signalling that grammar checking should be delayed for not-yet-authenticated streams on the grammar validator, signal that the stream is not yet authenticated on the stream object.
a629f83
to
730ef27
Compare
*/ | ||
export async function readPackets(input, callback) { | ||
const reader = streamGetReader(input); | ||
export async function readPacket(reader, useStreamType, callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simplify this further and have it return { tag, packet }
instead of taking a callback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because we need to call the callback earlier than returning when streaming. The callback happens when we've parsed the packet header; the function returns when the whole packet has been read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok; I think it should be possible to return the header and some stream/promises for the rest tho. I'd like to look into this for the next major 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that could work 👍
63ff85c
to
6d375a2
Compare
Co-authored-by: larabr <[email protected]>
5641132
to
8f30bb1
Compare
Instead of checking the list of packets for every new packet, check the new packet given the state we've recorded from the previous packets.
8f30bb1
to
d94d9d4
Compare
To make the grammar checker less of a breaking change in v6. This should be reverted in v7.
Some invalid sequences were not detected after refactor
baf3116
to
e584eb7
Compare
e584eb7
to
1aedcbe
Compare
Refactor & simplify the handling of the packet stream and errors in packet parsing & grammar validation.
This PR also makes the following observable changes:
allowUnauthenticatedStream: true
) get delayed until the decrypted data stream is authenticated (i.e. the MDC has been validated)UnparseablePacket
objects on the packet stream instead of being ignored