mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 22:42:31 +08:00
Improve network connection handling
This commit is contained in:
parent
e24ee1b837
commit
649e2e465c
31
src/main.cpp
31
src/main.cpp
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
static constexpr int32_t SLEEP_TIMEOUT = 15;
|
static constexpr int32_t CONNECTION_TIMEOUT = 15;
|
||||||
|
|
||||||
void show_iwctl() {
|
void show_iwctl() {
|
||||||
info("\nInstructions to connect to wifi using iwctl:\n");
|
info("\nInstructions to connect to wifi using iwctl:\n");
|
||||||
@ -45,20 +45,39 @@ int main() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
utils::id_system();
|
utils::id_system();
|
||||||
if (!utils::is_connected()) {
|
|
||||||
warning("It seems you are not connected, waiting for 15s before trying again...\n");
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(SLEEP_TIMEOUT));
|
|
||||||
|
|
||||||
if (!utils::is_connected()) {
|
bool connected;
|
||||||
|
|
||||||
|
if (!(connected = utils::is_connected())) {
|
||||||
|
warning("An active network connection could not be detected, waiting 15 seconds ...\n");
|
||||||
|
|
||||||
|
int32_t time_waited = 0;
|
||||||
|
|
||||||
|
while (!(connected = utils::is_connected())) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
|
||||||
|
if (time_waited++ >= CONNECTION_TIMEOUT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!connected) {
|
||||||
char type = '\0';
|
char type = '\0';
|
||||||
|
|
||||||
while (utils::prompt_char("An internet connection could not be detected, do you want to connect to a wifi network? [y/n]", RED, &type)) {
|
while (utils::prompt_char("An active network connection could not be detected, do you want to connect using wifi? [y/n]", RED, &type)) {
|
||||||
if (type != 'n') {
|
if (type != 'n') {
|
||||||
show_iwctl();
|
show_iwctl();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connected = utils::is_connected();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!connected) {
|
||||||
|
error("An active network connection could not be detected, please connect and restart the installer.");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user