Struct network::noise::handshake::NoiseUpgrader
source · pub struct NoiseUpgrader {
pub network_context: Arc<NetworkContext>,
/* private fields */
}
Expand description
The Noise configuration to be used to perform a protocol upgrade on an underlying socket.
Fields§
§network_context: Arc<NetworkContext>
The validator’s network context
Implementations§
source§impl NoiseUpgrader
impl NoiseUpgrader
sourcepub fn new(
network_context: Arc<NetworkContext>,
key: PrivateKey,
auth_mode: HandshakeAuthMode
) -> Self
pub fn new( network_context: Arc<NetworkContext>, key: PrivateKey, auth_mode: HandshakeAuthMode ) -> Self
Create a new NoiseConfig with the provided keypair and authentication mode.
sourcepub async fn upgrade_with_noise<TSocket>(
&self,
socket: TSocket,
origin: ConnectionOrigin,
remote_public_key: Option<PublicKey>
) -> Result<(PublicKey, NoiseStream<TSocket>), NoiseHandshakeError>where
TSocket: AsyncRead + AsyncWrite + Debug + Unpin,
pub async fn upgrade_with_noise<TSocket>( &self, socket: TSocket, origin: ConnectionOrigin, remote_public_key: Option<PublicKey> ) -> Result<(PublicKey, NoiseStream<TSocket>), NoiseHandshakeError>where TSocket: AsyncRead + AsyncWrite + Debug + Unpin,
Perform a protocol upgrade on an underlying connection. In addition perform the noise IK handshake to establish a noise stream and exchange static public keys. Upon success, returns the static public key of the remote as well as a NoiseStream.
sourcepub async fn upgrade_outbound<TSocket, F>(
&self,
socket: TSocket,
remote_public_key: PublicKey,
time_provider: F
) -> Result<NoiseStream<TSocket>, NoiseHandshakeError>where
TSocket: AsyncRead + AsyncWrite + Debug + Unpin,
F: Fn() -> [u8; 8],
pub async fn upgrade_outbound<TSocket, F>( &self, socket: TSocket, remote_public_key: PublicKey, time_provider: F ) -> Result<NoiseStream<TSocket>, NoiseHandshakeError>where TSocket: AsyncRead + AsyncWrite + Debug + Unpin, F: Fn() -> [u8; 8],
Perform an outbound protocol upgrade on this connection.
This runs the “client” side of the Noise IK handshake to establish a secure Noise stream and send its static public key to the server. In mutual auth scenarios, we will also include an anti replay attack counter in the Noise handshake payload. Currently this counter is always a millisecond- granularity unix epoch timestamp.
sourcepub async fn upgrade_inbound<TSocket>(
&self,
socket: TSocket
) -> Result<(NoiseStream<TSocket>, PeerId, PeerRole), NoiseHandshakeError>where
TSocket: AsyncRead + AsyncWrite + Debug + Unpin,
pub async fn upgrade_inbound<TSocket>( &self, socket: TSocket ) -> Result<(NoiseStream<TSocket>, PeerId, PeerRole), NoiseHandshakeError>where TSocket: AsyncRead + AsyncWrite + Debug + Unpin,
Perform an inbound protocol upgrade on this connection.
This runs the “server” side of the Noise IK handshake to establish a
secure Noise stream and exchange static public keys. If the configuration
requires mutual authentication, we will only allow connections from peers
that successfully authenticate to a public key in our trusted_peers
set.
In addition, we will expect the client to include an anti replay attack
counter in the Noise handshake payload in mutual auth scenarios.