From 50401989724ed70f031055463e21caad76589742 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 12 Dec 2020 19:27:18 +0100 Subject: Make it passive-client-friendly --- examples/basalt.rs | 8 ++++---- examples/fullmesh.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/basalt.rs b/examples/basalt.rs index e1ac2e4..4ea4f71 100644 --- a/examples/basalt.rs +++ b/examples/basalt.rs @@ -85,9 +85,7 @@ async fn main() { info!("KYEV SK {}", hex::encode(&privkey)); info!("KYEV PK {}", hex::encode(&privkey.public_key())); - let listen_addr = opt.listen_addr.parse().unwrap(); - let public_addr = opt.public_addr.map(|x| x.parse().unwrap()); - let netapp = NetApp::new(listen_addr, public_addr, netid, privkey); + let netapp = NetApp::new(netid, privkey); let mut bootstrap_peers = vec![]; for peer in opt.bootstrap_peers.iter() { @@ -119,9 +117,11 @@ async fn main() { }, ); + let listen_addr = opt.listen_addr.parse().unwrap(); + let public_addr = opt.public_addr.map(|x| x.parse().unwrap()); tokio::join!( sampling_loop(netapp.clone(), peering.clone()), - netapp.listen(), + netapp.listen(listen_addr, public_addr), peering.run(), ); } diff --git a/examples/fullmesh.rs b/examples/fullmesh.rs index 88784c1..eb954b7 100644 --- a/examples/fullmesh.rs +++ b/examples/fullmesh.rs @@ -65,9 +65,7 @@ async fn main() { info!("Node private key: {}", hex::encode(&privkey)); info!("Node public key: {}", hex::encode(&privkey.public_key())); - let listen_addr = opt.listen_addr.parse().unwrap(); - let public_addr = opt.public_addr.map(|x| x.parse().unwrap()); - let netapp = NetApp::new(listen_addr, public_addr, netid, privkey); + let netapp = NetApp::new(netid, privkey); let mut bootstrap_peers = vec![]; for peer in opt.bootstrap_peers.iter() { @@ -81,5 +79,7 @@ async fn main() { let peering = FullMeshPeeringStrategy::new(netapp.clone(), bootstrap_peers); - tokio::join!(netapp.listen(), peering.run(),); + let listen_addr = opt.listen_addr.parse().unwrap(); + let public_addr = opt.public_addr.map(|x| x.parse().unwrap()); + tokio::join!(netapp.listen(listen_addr, public_addr), peering.run(),); } -- cgit v1.2.3 From 6742638c81f8bda2ba3e3ab72ec520ab22b314e2 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 12 Dec 2020 21:14:15 +0100 Subject: Replace pk,pubkey,PublicKey by id,NodeID,etc --- examples/basalt.rs | 19 +++++++++---------- examples/fullmesh.rs | 3 ++- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/basalt.rs b/examples/basalt.rs index 4ea4f71..4d7887d 100644 --- a/examples/basalt.rs +++ b/examples/basalt.rs @@ -15,6 +15,7 @@ use netapp::message::*; use netapp::peering::basalt::*; use netapp::proto::*; use netapp::NetApp; +use netapp::NodeID; #[derive(StructOpt, Debug)] #[structopt(name = "netapp")] @@ -91,7 +92,7 @@ async fn main() { for peer in opt.bootstrap_peers.iter() { if let Some(delim) = peer.find('@') { let (key, ip) = peer.split_at(delim); - let pubkey = ed25519::PublicKey::from_slice(&hex::decode(&key).unwrap()).unwrap(); + let pubkey = NodeID::from_slice(&hex::decode(&key).unwrap()).unwrap(); let ip = ip[1..].parse::().unwrap(); bootstrap_peers.push((pubkey, ip)); } @@ -106,16 +107,14 @@ async fn main() { }; let peering = Basalt::new(netapp.clone(), bootstrap_peers, basalt_params); - netapp.add_msg_handler::( - |_from: ed25519::PublicKey, msg: ExampleMessage| { - debug!("Got example message: {:?}, sending example response", msg); - async { - ExampleResponse { - example_field: false, - } + netapp.add_msg_handler::(|_from: NodeID, msg: ExampleMessage| { + debug!("Got example message: {:?}, sending example response", msg); + async { + ExampleResponse { + example_field: false, } - }, - ); + } + }); let listen_addr = opt.listen_addr.parse().unwrap(); let public_addr = opt.public_addr.map(|x| x.parse().unwrap()); diff --git a/examples/fullmesh.rs b/examples/fullmesh.rs index eb954b7..acc0a7b 100644 --- a/examples/fullmesh.rs +++ b/examples/fullmesh.rs @@ -10,6 +10,7 @@ use sodiumoxide::crypto::sign::ed25519; use netapp::peering::fullmesh::*; use netapp::NetApp; +use netapp::NodeID; #[derive(StructOpt, Debug)] #[structopt(name = "netapp")] @@ -71,7 +72,7 @@ async fn main() { for peer in opt.bootstrap_peers.iter() { if let Some(delim) = peer.find('@') { let (key, ip) = peer.split_at(delim); - let pubkey = ed25519::PublicKey::from_slice(&hex::decode(&key).unwrap()).unwrap(); + let pubkey = NodeID::from_slice(&hex::decode(&key).unwrap()).unwrap(); let ip = ip[1..].parse::().unwrap(); bootstrap_peers.push((pubkey, ip)); } -- cgit v1.2.3