aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-12-11 15:53:59 +0100
committerAlex Auvolat <alex@adnab.me>2020-12-11 15:53:59 +0100
commit609f0387ca7e04cf1406f10029115f7c09e3a3d9 (patch)
tree9c2194a7e39f0606477bb40226119825b876a867 /examples
parentfd8c487b9b9cb6911191e72f4fda8af09d4d0250 (diff)
downloadnetapp-609f0387ca7e04cf1406f10029115f7c09e3a3d9.tar.gz
netapp-609f0387ca7e04cf1406f10029115f7c09e3a3d9.zip
Add ability to specify our public addr for people to contact us back
Diffstat (limited to 'examples')
-rw-r--r--examples/basalt.rs6
-rw-r--r--examples/fullmesh.rs6
2 files changed, 10 insertions, 2 deletions
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<String>,
+
#[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<String>,
}
#[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() {