From df6aad2be4c6c5d11483f20e62d41e71f0ac989e Mon Sep 17 00:00:00 2001 From: hozan23 Date: Wed, 13 Mar 2024 12:33:34 +0100 Subject: net: major cleanup and improvement of the crate api --- p2p/src/connector.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'p2p/src/connector.rs') diff --git a/p2p/src/connector.rs b/p2p/src/connector.rs index e83d8da..41839ab 100644 --- a/p2p/src/connector.rs +++ b/p2p/src/connector.rs @@ -7,7 +7,7 @@ use karyon_core::{ crypto::KeyPair, GlobalExecutor, }; -use karyon_net::{dial, tls, Conn, Endpoint, NetError}; +use karyon_net::{tcp, tls, Conn, Endpoint, NetError}; use crate::{ monitor::{ConnEvent, Monitor}, @@ -142,9 +142,11 @@ impl Connector { async fn dial(&self, endpoint: &Endpoint, peer_id: &Option) -> Result { if self.enable_tls { let tls_config = tls_client_config(&self.key_pair, peer_id.clone())?; - tls::dial(endpoint, tls_config, DNS_NAME).await + tls::dial(endpoint, tls_config, DNS_NAME) + .await + .map(|l| Box::new(l) as Conn) } else { - dial(endpoint).await + tcp::dial(endpoint).await.map(|l| Box::new(l) as Conn) } .map_err(Error::KaryonNet) } -- cgit v1.2.3