diff --git a/Cargo.lock b/Cargo.lock index 24cf425..a8793ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -308,6 +308,12 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bimap" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" + [[package]] name = "bitflags" version = "1.3.2" @@ -340,7 +346,7 @@ dependencies = [ [[package]] name = "boot-node" -version = "0.3.0" +version = "0.4.0" dependencies = [ "camino", "clap", @@ -1367,6 +1373,7 @@ dependencies = [ "libp2p-ping", "libp2p-quic", "libp2p-relay", + "libp2p-rendezvous", "libp2p-swarm", "libp2p-tcp", "libp2p-tls", @@ -1705,6 +1712,50 @@ dependencies = [ "web-time", ] +[[package]] +name = "libp2p-rendezvous" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168a444a16f569771bcb48aa081a32724079156e64a730dd900276391ccb6385" +dependencies = [ + "async-trait", + "asynchronous-codec 0.6.2", + "bimap", + "futures", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-request-response", + "libp2p-swarm", + "quick-protobuf", + "quick-protobuf-codec 0.2.0", + "rand", + "thiserror", + "tracing", + "void", +] + +[[package]] +name = "libp2p-request-response" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6946e5456240b3173187cc37a17cb40c3cd1f7138c76e2c773e0d792a42a8de1" +dependencies = [ + "async-trait", + "futures", + "futures-bounded", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "rand", + "smallvec", + "tracing", + "void", +] + [[package]] name = "libp2p-swarm" version = "0.44.2" diff --git a/Cargo.toml b/Cargo.toml index 75c11e1..211b0c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [".", "examples/dcutr", "examples/chat"] [package] name = "boot-node" -version = "0.3.0" +version = "0.4.0" authors = ["Calimero Limited "] edition = "2021" repository = "https://github.com/calimero-network/boot-node" @@ -21,6 +21,7 @@ libp2p = { version = "0.53.2", features = [ "noise", "ping", "quic", + "rendezvous", "relay", "tokio", "tcp", diff --git a/src/main.rs b/src/main.rs index 13b628a..f430010 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use std::net::Ipv4Addr; use clap::Parser; use libp2p::futures::prelude::*; use libp2p::swarm::{NetworkBehaviour, SwarmEvent}; -use libp2p::{identify, identity, kad, ping, relay, Multiaddr, StreamProtocol, Swarm}; +use libp2p::{identify, identity, kad, ping, relay, rendezvous, Multiaddr, StreamProtocol, Swarm}; use tracing::info; use tracing_subscriber::prelude::*; use tracing_subscriber::EnvFilter; @@ -16,6 +16,7 @@ struct Behaviour { identify: identify::Behaviour, kad: kad::Behaviour, ping: ping::Behaviour, + rendezvous: rendezvous::server::Behaviour, relay: relay::Behaviour, } @@ -89,6 +90,7 @@ async fn main() -> eyre::Result<()> { kademlia }, ping: ping::Behaviour::new(ping::Config::new()), + rendezvous: rendezvous::server::Behaviour::new(rendezvous::server::Config::default()), relay: relay::Behaviour::new(keypair.public().to_peer_id(), Default::default()), })? .build(); @@ -141,6 +143,9 @@ async fn handle_swarm_behaviour_event(swarm: &mut Swarm, event: Behav BehaviourEvent::Kad(event) => { info!("Kad event: {event:?}"); } + BehaviourEvent::Rendezvous(event) => { + info!("Rendezvous event: {event:?}"); + } BehaviourEvent::Relay(event) => { info!("Relay event: {event:?}"); }