Skip to content

Commit

Permalink
feat: implement rendezvous server behaviour (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
fbozic authored May 20, 2024
1 parent 9cbc2ca commit 02a2f56
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
53 changes: 52 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [".", "examples/dcutr", "examples/chat"]

[package]
name = "boot-node"
version = "0.3.0"
version = "0.4.0"
authors = ["Calimero Limited <[email protected]>"]
edition = "2021"
repository = "https://github.com/calimero-network/boot-node"
Expand All @@ -21,6 +21,7 @@ libp2p = { version = "0.53.2", features = [
"noise",
"ping",
"quic",
"rendezvous",
"relay",
"tokio",
"tcp",
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,6 +16,7 @@ struct Behaviour {
identify: identify::Behaviour,
kad: kad::Behaviour<kad::store::MemoryStore>,
ping: ping::Behaviour,
rendezvous: rendezvous::server::Behaviour,
relay: relay::Behaviour,
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -141,6 +143,9 @@ async fn handle_swarm_behaviour_event(swarm: &mut Swarm<Behaviour>, event: Behav
BehaviourEvent::Kad(event) => {
info!("Kad event: {event:?}");
}
BehaviourEvent::Rendezvous(event) => {
info!("Rendezvous event: {event:?}");
}
BehaviourEvent::Relay(event) => {
info!("Relay event: {event:?}");
}
Expand Down

0 comments on commit 02a2f56

Please sign in to comment.