Conversation
0f9f0a1 to
1fc8b42
Compare
Signed-off-by: Nathan Perry <nathan@tailscale.com> Change-Id: I7556c1452053f1cc02549e3ad425672c6a6a6964
Simplify the handshake to read the header and then the body in two successive steps. Drop most of the message types, as they rewrap the body, which is handled on its own by `codec`. Export more of the internals -- this is an internals crate anyway, might as well open the definitions if other people might want to use it. Improve docs as part of that. Signed-off-by: Nathan Perry <nathan@tailscale.com> Change-Id: I5a037e0ac35dd969812d7ab68cf6ca3c6a6a6964
Signed-off-by: Nathan Perry <nathan@tailscale.com> Change-Id: Ia83e08aff37ad6303ba57c31dea773c86a6a6964
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Saw #139, had a feeling we still had bugs here -- rewrote
control_noiseto usetokio-codecas had been a rough plan. This eliminates the manualAsyncRead/AsyncWriteimplementations at the cost of potential minimal increases to allocation. I think this is well worth having code that's much easier to reason about. I added tests here, including some proptests, which should cover the error from #139 if I'm reading it right.Also cut down the
messagesmodule — we read the header and the body in two steps, so I don't think we need the dedicated*Messagetypes containing both.Also documented and made most of the crate
pub, since I think that gives a more complete representation of the pieces of ts2021.FramedIoI did a dumb copy-paste out of tokio because the adapters from
Stream<impl AsRef<[u8]>>andSink<impl AsRef<[u8]>>toAsyncRead/AsyncWriteare mutually exclusive, and our codec type is duplex (we would need both wrapping it, and we can't nest them to get both trait impls).With existing tools we would've needed to use something like
StreamExt::splitto separateBiCodecinto stream and sink parts, which introduces a mutex that we know a priori is unnecessary, wrap each part inSinkWriterandStreamReader, thenjointhem back together.