Skip to content

Commit d48edfc

Browse files
committed
feat: provide a --local flag for joining network
As with the Launch struct, the `--local` flag is supplied for Join and this flag disables port forwarding for a local node joining a new network. This was added to support the `node join` command in `sn_cli`.
1 parent 16a90fe commit d48edfc

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/lib.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ pub struct Launch {
7373
/// IP used to launch the nodes with.
7474
#[structopt(long = "add")]
7575
add_nodes_to_existing_network: bool,
76-
77-
/// Run the section locally.
78-
#[structopt(long = "local")]
79-
is_local: bool,
8076
}
8177

8278
impl Launch {
@@ -92,14 +88,14 @@ impl Launch {
9288
node_cmd.push_arg(keep_alive_interval_msec.to_string());
9389
}
9490

95-
if self.is_local {
91+
if self.common.is_local {
9692
node_cmd.push_arg("--skip-igd");
9793
}
9894

9995
if let Some(ip) = &self.ip {
10096
node_cmd.push_arg("--local-addr");
10197
node_cmd.push_arg(format!("{}:0", ip));
102-
} else if self.is_local {
98+
} else if self.common.is_local {
10399
node_cmd.push_arg("--local-addr");
104100
node_cmd.push_arg("127.0.0.1:0");
105101
}
@@ -236,9 +232,16 @@ impl Join {
236232
node_cmd.push_arg(max_capacity.to_string());
237233
}
238234

235+
if self.common.is_local {
236+
node_cmd.push_arg("--skip-igd");
237+
}
238+
239239
if let Some(local_addr) = self.local_addr {
240240
node_cmd.push_arg("--local-addr");
241241
node_cmd.push_arg(local_addr.to_string());
242+
} else if self.common.is_local {
243+
node_cmd.push_arg("--local-addr");
244+
node_cmd.push_arg("127.0.0.1:0");
242245
}
243246

244247
if let Some(public_addr) = self.public_addr {
@@ -294,6 +297,10 @@ struct CommonArgs {
294297
/// Output logs in json format for easier processing.
295298
#[structopt(long)]
296299
json_logs: bool,
300+
301+
/// Run the section locally.
302+
#[structopt(long = "local")]
303+
is_local: bool,
297304
}
298305

299306
impl CommonArgs {

0 commit comments

Comments
 (0)