Skip to content
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

Add unprocessedBytes property on NIOSingleStepByteToMessageProcessor #2419

Merged

Conversation

fabianfett
Copy link
Member

Add unprocessedBytes property on NIOSingleStepByteToMessageProcessor

Motivation:

Some protocols require no messages to be in the incoming buffer after a certain message was received. For example if both endpoints agree on an upgrade to TLS no remaining bytes should be in the incoming buffer (as those would have been sent unencrypted or those may have been injected by a man in the middle). We should allow to ask the NIOSingleStepByteToMessageProcessor if there are bytes remaining in its incoming buffer.

Modifications:

  • Add unprocessedBytes property on NIOSingleStepByteToMessageProcessor

Result:

  • Safer network communication

Comment on lines -33 to -44
private final class ForeverDecoder: NIOSingleStepByteToMessageDecoder {
typealias InboundOut = Never

func decode(buffer: inout ByteBuffer) throws -> InboundOut? {
return nil
}

func decodeLast(buffer: inout ByteBuffer, seenEOF: Bool) throws -> InboundOut? {
XCTAssertTrue(seenEOF)
return try self.decode(buffer: &buffer)
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally unused. This is why I removed it.

Copy link
Member

@dnadoba dnadoba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Lukasa Lukasa added the semver/minor Adds new public API. label May 3, 2023
@Lukasa Lukasa merged commit 546eaa2 into apple:main May 3, 2023
@fabianfett fabianfett deleted the ff-add-unprocessedBytes-to-SingleStepProcessor branch May 3, 2023 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants