#37, but also report the remote address #38
Closed
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.
This PR incorporates #37 and also changes
TlsListener
to report the remote address, both upon successfully accepting a connection and when TLS negotiation fails or times out.This doesn't quite do what I wanted in #36, which as you said in #36 (comment) is impossible, so reporting the remote address seems like the next best thing.
Unresolved issue: now
Error
has three type parameters. It's pretty messy. I could bring it back down to two by using theAsyncAccept
andAsyncTls
implementations as the type parameters instead (e.g.Error<TcpListener, TlsAcceptor>
), but then theimpl Debug
can't bederive
d because it will get the wrong bounds (see rust-lang/rust#26925). This can be worked around by hand-writingimpl Debug for Error
(yuck) or by using a proc-macro crate like educe, derivative, or impl-tools (which adds a proc-macro dependency, although you already have several). What do you think?This contains breaking changes in addition to those in #37, namely:
Error::ListenerError
is now struct-like instead of tuple-like, and isnon_exhaustive
like the enum itself.Error
now has three type parameters, not two, as mentioned above.TlsListener::accept
and<TlsListener as Stream>::next
yields a tuple of (connection, remote address), not just the connection.AsyncAccept
now has an associated typeAddress
, whichpoll_accept
must now return along with the accepted connection.