Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ enum Command {
#[clap(flatten)]
hosts: HostsOpt,

/// The listen port you'd like to set for the interface
#[clap(long)]
listen_port: Option<u16>,

#[clap(flatten)]
install_opts: InstallOpts,

Expand Down Expand Up @@ -276,10 +280,14 @@ fn install(
invite: &Path,
hosts_file: Option<PathBuf>,
install_opts: InstallOpts,
listen_port: Option<u16>,
nat: &NatOpts,
) -> Result<(), Error> {
innernet_shared::ensure_dirs_exist(&[&opts.config_dir])?;
let config = InterfaceConfig::from_file(invite)?;
let config = InterfaceConfig::from_file(invite).map(|mut config| {
config.interface.listen_port = listen_port;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invite files currently don't specify listen ports. We don't expect them to in the future but out of caution I'd feel safer if this overrode the config only when the listen_port argument is Some.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give it an update shortly so it only puts it in if there is actually a value.

config
})?;

let iface = if install_opts.default_name {
config.interface.network_name.clone()
Expand Down Expand Up @@ -420,7 +428,7 @@ fn redeem_invite(
iface,
&config.interface.private_key,
config.interface.address,
None,
config.interface.listen_port,
Some((
&config.server.public_key,
config.server.internal_endpoint.ip(),
Expand Down Expand Up @@ -1289,8 +1297,9 @@ fn run(opts: &Opts) -> Result<(), Error> {
invite,
hosts,
install_opts,
listen_port,
nat,
} => install(opts, &invite, hosts.into(), install_opts, &nat)?,
} => install(opts, &invite, hosts.into(), install_opts, listen_port, &nat)?,
Command::Show {
short,
tree,
Expand Down