From 609f0387ca7e04cf1406f10029115f7c09e3a3d9 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 11 Dec 2020 15:53:59 +0100 Subject: Add ability to specify our public addr for people to contact us back --- examples/basalt.rs | 6 +++++- examples/fullmesh.rs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/basalt.rs b/examples/basalt.rs index eaf056b..e1ac2e4 100644 --- a/examples/basalt.rs +++ b/examples/basalt.rs @@ -31,6 +31,9 @@ pub struct Opt { #[structopt(long = "listen-addr", short = "l", default_value = "127.0.0.1:1980")] listen_addr: String, + #[structopt(long = "public-addr", short = "a")] + public_addr: Option, + #[structopt(long = "view-size", short = "v", default_value = "100")] view_size: usize, @@ -83,7 +86,8 @@ async fn main() { info!("KYEV PK {}", hex::encode(&privkey.public_key())); let listen_addr = opt.listen_addr.parse().unwrap(); - let netapp = NetApp::new(listen_addr, netid, privkey); + let public_addr = opt.public_addr.map(|x| x.parse().unwrap()); + let netapp = NetApp::new(listen_addr, public_addr, netid, privkey); let mut bootstrap_peers = vec![]; for peer in opt.bootstrap_peers.iter() { diff --git a/examples/fullmesh.rs b/examples/fullmesh.rs index 5addcea..88784c1 100644 --- a/examples/fullmesh.rs +++ b/examples/fullmesh.rs @@ -25,6 +25,9 @@ pub struct Opt { #[structopt(long = "listen-addr", short = "l", default_value = "127.0.0.1:1980")] listen_addr: String, + + #[structopt(long = "public-addr", short = "a")] + public_addr: Option, } #[tokio::main] @@ -63,7 +66,8 @@ async fn main() { info!("Node public key: {}", hex::encode(&privkey.public_key())); let listen_addr = opt.listen_addr.parse().unwrap(); - let netapp = NetApp::new(listen_addr, netid, privkey); + let public_addr = opt.public_addr.map(|x| x.parse().unwrap()); + let netapp = NetApp::new(listen_addr, public_addr, netid, privkey); let mut bootstrap_peers = vec![]; for peer in opt.bootstrap_peers.iter() { -- cgit v1.2.3