diff options
author | hozan23 <hozan23@proton.me> | 2024-03-13 12:33:34 +0100 |
---|---|---|
committer | hozan23 <hozan23@proton.me> | 2024-03-13 12:33:34 +0100 |
commit | df6aad2be4c6c5d11483f20e62d41e71f0ac989e (patch) | |
tree | bbbc8db330d254eab993f7e3e4bbdbcbb0b3ec6e /p2p/src/connector.rs | |
parent | 76e952830302271e07a4be9df6dfaa1c11e3e675 (diff) |
net: major cleanup and improvement of the crate api
Diffstat (limited to 'p2p/src/connector.rs')
-rw-r--r-- | p2p/src/connector.rs | 8 |
1 files changed, 5 insertions, 3 deletions
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<PeerID>) -> Result<Conn> { 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) } |