Make InboundUpgrade for IK pattern more generic. (#1379)

The current implementation defines the InboundUpgrade only for `R = ()`
so notably a `NoiseConfig` created by `NoiseConfig::ik_dialer` can not
be an `InboundUpgrade`.

Fixes #1378.
This commit is contained in:
Toralf Wittner
2020-01-10 15:09:36 +01:00
committed by GitHub
parent af464e18c5
commit ff780b5bff
2 changed files with 3 additions and 12 deletions

View File

@ -244,9 +244,9 @@ where
// Handshake pattern IK ///////////////////////////////////////////////////// // Handshake pattern IK /////////////////////////////////////////////////////
impl<T, C> InboundUpgrade<T> for NoiseConfig<IK, C> impl<T, C, R> InboundUpgrade<T> for NoiseConfig<IK, C, R>
where where
NoiseConfig<IK, C>: UpgradeInfo, NoiseConfig<IK, C, R>: UpgradeInfo,
T: AsyncRead + AsyncWrite + Unpin + Send + 'static, T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static, C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static,
{ {

View File

@ -83,16 +83,7 @@ impl UpgradeInfo for NoiseConfig<XX, X25519> {
} }
} }
impl UpgradeInfo for NoiseConfig<IK, X25519> { impl<R> UpgradeInfo for NoiseConfig<IK, X25519, R> {
type Info = &'static [u8];
type InfoIter = std::iter::Once<Self::Info>;
fn protocol_info(&self) -> Self::InfoIter {
std::iter::once(b"/noise/ik/25519/chachapoly/sha256/0.1.0")
}
}
impl UpgradeInfo for NoiseConfig<IK, X25519, (PublicKey<X25519>, identity::PublicKey)> {
type Info = &'static [u8]; type Info = &'static [u8];
type InfoIter = std::iter::Once<Self::Info>; type InfoIter = std::iter::Once<Self::Info>;