feat(transport): provide generic access to connect info #647
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.
Provides generic access to "connection info" provided by the stream of incoming connections through request extensions.
The
Connected
trait is changed to:TcpStream
andAddrStream
implement this and returnTcpConnectInfo
which hasremote_addr: Option<SocketAddr>
.TlsStream
implements it by returningTlsConnectInfo<T>
whereT
is some other connect info type. That hasget_ref
to access the inner type andpeer_certs
to get the certificates.ServerIo
is then changed to no longer box the IO type but instead be generic such that no type information is erased:Where
IO
andTlsStream<IO>
implementConnected
.In
MakeSvc
we access the connect info from the IO object and set it as a request extension so its accessible later.Should be fairly flexible since we don't have to keep adding methods to the
Connected
trait but can instead add those on the types produced.It is slightly less discoverable but I've updated the uds example to demo it and the
remote_addr
andpeer_certs
methods still exist onRequest
.Fixes #365