aboutsummaryrefslogtreecommitdiff
path: root/examples/fullmesh.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/fullmesh.rs')
-rw-r--r--examples/fullmesh.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/examples/fullmesh.rs b/examples/fullmesh.rs
index f5b307b..afc4deb 100644
--- a/examples/fullmesh.rs
+++ b/examples/fullmesh.rs
@@ -1,4 +1,5 @@
use std::io::Write;
+use std::net::SocketAddr;
use log::info;
@@ -65,6 +66,11 @@ async fn main() {
info!("Node private key: {}", hex::encode(&privkey));
info!("Node public key: {}", hex::encode(&privkey.public_key()));
+ let public_addr = opt.public_addr.map(|x| x.parse().unwrap());
+ let listen_addr: SocketAddr = opt.listen_addr.parse().unwrap();
+ info!("Node public address: {:?}", public_addr);
+ info!("Node listen address: {}", listen_addr);
+
let netapp = NetApp::new(netid.clone(), privkey.clone());
let mut bootstrap_peers = vec![];
@@ -72,9 +78,11 @@ async fn main() {
bootstrap_peers.push(parse_peer_addr(peer).expect("Invalid peer address"));
}
- let peering = FullMeshPeeringStrategy::new(netapp.clone(), bootstrap_peers);
-
- let listen_addr = opt.listen_addr.parse().unwrap();
+ let peering = FullMeshPeeringStrategy::new(
+ netapp.clone(),
+ bootstrap_peers,
+ public_addr.map(|a| SocketAddr::new(a, listen_addr.port())),
+ );
info!("Add more peers to this mesh by running: fullmesh -n {} -l 127.0.0.1:$((1000 + $RANDOM)) -b {}@{}",
hex::encode(&netid),
@@ -83,7 +91,6 @@ async fn main() {
let watch_cancel = netapp::util::watch_ctrl_c();
- let public_addr = opt.public_addr.map(|x| x.parse().unwrap());
tokio::join!(
netapp.listen(listen_addr, public_addr, watch_cancel.clone()),
peering.run(watch_cancel),