aboutsummaryrefslogtreecommitdiff
path: root/p2p/src/connector.rs
diff options
context:
space:
mode:
Diffstat (limited to 'p2p/src/connector.rs')
-rw-r--r--p2p/src/connector.rs8
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)
}