client: make install step a bit more resilient
change private keys on client earlier to avoid race conditions, and attempt the fetch call multiple times to avoid spurious issues, while also not failing the entire command if fetch doesn't succeed.pull/67/head
parent
733118a463
commit
ee475715c3
|
@ -237,7 +237,16 @@ fn install(invite: &Path, hosts_file: Option<PathBuf>, opts: InstallOpts) -> Res
|
||||||
e
|
e
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
fetch(&iface, false, hosts_file)?;
|
let mut fetch_success = false;
|
||||||
|
for _ in 0..3 {
|
||||||
|
if fetch(&iface, false, hosts_file).is_ok() {
|
||||||
|
fetch_success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !fetch_success {
|
||||||
|
println!("{} Failed to fetch peers from server, you will need to manually run the 'up' command.", "[!]".red());
|
||||||
|
}
|
||||||
|
|
||||||
if opts.delete_invite
|
if opts.delete_invite
|
||||||
|| Confirm::with_theme(&*prompts::THEME)
|
|| Confirm::with_theme(&*prompts::THEME)
|
||||||
|
@ -319,15 +328,15 @@ fn redeem_invite(
|
||||||
"[*]".dimmed(),
|
"[*]".dimmed(),
|
||||||
target_conf.to_string_lossy().yellow()
|
target_conf.to_string_lossy().yellow()
|
||||||
);
|
);
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"{} Waiting for server's WireGuard interface to transition to new key.",
|
"{} Changing keys and waiting for server's WireGuard interface to transition.",
|
||||||
"[*]".dimmed(),
|
"[*]".dimmed(),
|
||||||
);
|
);
|
||||||
thread::sleep(*REDEEM_TRANSITION_WAIT);
|
|
||||||
|
|
||||||
DeviceConfigBuilder::new()
|
DeviceConfigBuilder::new()
|
||||||
.set_private_key(keypair.private)
|
.set_private_key(keypair.private)
|
||||||
.apply(&iface)?;
|
.apply(&iface)?;
|
||||||
|
thread::sleep(*REDEEM_TRANSITION_WAIT);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue