From 98a1de91a2dae06323558422c239e5a45fc86e7b Mon Sep 17 00:00:00 2001 From: hozan23 Date: Tue, 28 Nov 2023 22:41:33 +0300 Subject: implement TLS for inbound and outbound connections --- p2p/examples/chat.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'p2p/examples/chat.rs') diff --git a/p2p/examples/chat.rs b/p2p/examples/chat.rs index 907ba06..d94bca4 100644 --- a/p2p/examples/chat.rs +++ b/p2p/examples/chat.rs @@ -7,11 +7,12 @@ use async_trait::async_trait; use clap::Parser; use smol::{channel, Executor}; +use karyons_core::key_pair::{KeyPair, KeyPairType}; use karyons_net::{Endpoint, Port}; use karyons_p2p::{ protocol::{ArcProtocol, Protocol, ProtocolEvent, ProtocolID}, - ArcPeer, Backend, Config, P2pError, PeerID, Version, + ArcPeer, Backend, Config, P2pError, Version, }; use shared::run_executor; @@ -102,7 +103,7 @@ fn main() { let cli = Cli::parse(); // Create a PeerID based on the username. - let peer_id = PeerID::new(cli.username.as_bytes()); + let key_pair = KeyPair::generate(&KeyPairType::Ed25519); // Create the configuration for the backend. let config = Config { @@ -117,7 +118,7 @@ fn main() { let ex = Arc::new(Executor::new()); // Create a new Backend - let backend = Backend::new(peer_id, config, ex.clone()); + let backend = Backend::new(&key_pair, config, ex.clone()); let (ctrlc_s, ctrlc_r) = channel::unbounded(); let handle = move || ctrlc_s.try_send(()).unwrap(); -- cgit v1.2.3