Skip to content

Commit

Permalink
chore(relay): move server example to examples/
Browse files Browse the repository at this point in the history
Related: #3111.

Pull-Request: #3663.
  • Loading branch information
thomaseizinger committed Mar 23, 2023
1 parent d652c01 commit fd09835
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 deletions.
16 changes: 12 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"examples/ipfs-kad",
"examples/ipfs-private",
"examples/ping-example",
"examples/relay-server",
"examples/rendezvous",
"identity",
"interop-tests",
Expand Down
14 changes: 14 additions & 0 deletions examples/relay-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "relay-server-example"
version = "0.1.0"
edition = "2021"
publish = false
license = "MIT"

[dependencies]
clap = { version = "4.1.11", features = ["derive"] }
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
env_logger = "0.10.0"
futures = "0.3.27"
libp2p = { path = "../../libp2p", features = ["async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay"] }
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@
use clap::Parser;
use futures::executor::block_on;
use futures::stream::StreamExt;
use libp2p_core::multiaddr::Protocol;
use libp2p_core::upgrade;
use libp2p_core::{Multiaddr, Transport};
use libp2p_identify as identify;
use libp2p_identity as identity;
use libp2p_identity::PeerId;
use libp2p_noise as noise;
use libp2p_ping as ping;
use libp2p_relay as relay;
use libp2p_swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent};
use libp2p_tcp as tcp;
use libp2p::{
core::multiaddr::Protocol,
core::upgrade,
core::{Multiaddr, Transport},
identify, identity,
identity::PeerId,
noise, ping, relay,
swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
tcp,
};
use std::error::Error;
use std::net::{Ipv4Addr, Ipv6Addr};

Expand All @@ -55,7 +54,7 @@ fn main() -> Result<(), Box<dyn Error>> {
noise::NoiseAuthenticated::xx(&local_key)
.expect("Signing libp2p-noise static DH keypair failed."),
)
.multiplex(libp2p_yamux::YamuxConfig::default())
.multiplex(libp2p::yamux::YamuxConfig::default())
.boxed();

let behaviour = Behaviour {
Expand Down Expand Up @@ -94,7 +93,6 @@ fn main() -> Result<(), Box<dyn Error>> {
}

#[derive(NetworkBehaviour)]
#[behaviour(prelude = "libp2p_swarm::derive_prelude")]
struct Behaviour {
relay: relay::Behaviour,
ping: ping::Behaviour,
Expand Down
4 changes: 0 additions & 4 deletions protocols/relay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ thiserror = "1.0"
void = "1"

[dev-dependencies]
clap = { version = "4.1.11", features = ["derive"] }
env_logger = "0.10.0"
libp2p-identify = { path = "../../protocols/identify" }
libp2p-noise = { path = "../../transports/noise" }
libp2p-ping = { path = "../../protocols/ping" }
libp2p-plaintext = { path = "../../transports/plaintext" }
libp2p-swarm = { path = "../../swarm", features = ["macros"] }
libp2p-tcp = { path = "../../transports/tcp", features = ["async-io"] }
libp2p-yamux = { path = "../../muxers/yamux" }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }

Expand Down

0 comments on commit fd09835

Please sign in to comment.