Struct network::noise::handshake::NoiseUpgrader [−][src]
pub struct NoiseUpgrader {
pub network_context: NetworkContext,
// some fields omitted
}Expand description
The Noise configuration to be used to perform a protocol upgrade on an underlying socket.
Fields
network_context: NetworkContextThe validator’s network context
Implementations
pub fn new(
network_context: NetworkContext,
key: PrivateKey,
auth_mode: HandshakeAuthMode
) -> Self
pub fn new(
network_context: NetworkContext,
key: PrivateKey,
auth_mode: HandshakeAuthMode
) -> Self
Create a new NoiseConfig with the provided keypair and authentication mode.
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,
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.
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],
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.
pub 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.
Auto Trait Implementations
impl RefUnwindSafe for NoiseUpgrader
impl Send for NoiseUpgrader
impl Sync for NoiseUpgrader
impl Unpin for NoiseUpgrader
impl UnwindSafe for NoiseUpgrader
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Output = T
type Output = T
Should always be Self