Show the crate…

2 unstable releases

0.27.0 Mar 15, 2021
0.0.0 Mar 11, 2021

#48 in #tetcore

MIT license

535KB
9K SLoC

The secio protocol is a middleware that will encrypt and decrypt communications going through a socket (or anything that implements AsyncRead + AsyncWrite).

Usage

The SecioConfig implements InboundUpgrade and OutboundUpgrade and thus serves as a connection upgrade for authentication of a transport. See authenticate.

use futures::prelude::*;
use secio::{SecioConfig, SecioOutput};
use tet_libp2p_core::{PeerId, Multiaddr, identity, upgrade};
use tet_libp2p_core::transport::Transport;
use tet_libp2p_mplex::MplexConfig;
use tet_libp2p_tcp::TcpConfig;

// Create a local peer identity.
let local_keys = identity::Keypair::generate_ed25519();

// Create a `Transport`.
let transport = TcpConfig::new()
    .upgrade(upgrade::Version::V1)
    .authenticate(SecioConfig::new(local_keys.clone()))
    .multiplex(MplexConfig::default());

// The transport can be used with a `Network` from `tet-libp2p-core`, or a
// `Swarm` from from `tet-libp2p-swarm`. See the documentation of these
// crates for mode details.

// let network = Network::new(transport, local_keys.public().into_peer_id());
// let swarm = Swarm::new(transport, behaviour, local_keys.public().into_peer_id());

Dependencies

~11–18MB
~339K SLoC