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

Revamp handshake entrypoints #142

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nox
Copy link
Collaborator

@nox nox commented Aug 3, 2023

I first introduce setup_accept and setup_connect to simplify looping over an interrupted handshake.

This led me to the realisation that removing accept and connect both simplifies the handshake error type and allows us to more easily distinguish between setup failures (caused by the user of the library) and actual errors happening on the stream while performing handshakes.

ghedo and others added 2 commits August 3, 2023 19:52
These two new kinds of methods immediately return a MidHandshakeSslStream
instead of actually initiating a handshake. This greatly simplifies
loops around MidHandshakeSslStream::WouldBlock.
@nox nox force-pushed the revamp-handshake-entrypoints branch 7 times, most recently from 69081d5 to 5a93ea0 Compare August 3, 2023 20:09
@nox nox mentioned this pull request Aug 4, 2023
@nox nox force-pushed the revamp-handshake-entrypoints branch from 5a93ea0 to 756f807 Compare August 4, 2023 11:43
@nox nox requested a review from inikulin August 4, 2023 14:01
nox added 2 commits August 4, 2023 17:26
Those functions were blurring the line between setup failures
(which are caused by the developer misusing the API) and actual
failures encountered on the stream while trying to achieve the
TLS handshake, especially on SslConnector and SslAcceptor.

Removing them allows for the removal of HandshakeError, as
the HandshakeError::SetupFailure variant becomes useless,
and there is no real need to distinguish in that error type
between Failure and WouldBlock when we can just check
the error stored in MidHandshakeSslStream.

This then allow us to simplify tokio_boring's own entry points,
also making them distinguish between setup failures and failures
on the stream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants