Skip to content

Commit b687897

Browse files
ptr1337vnepogodin
andauthored
installer: Add fallback ping checks for the internet check (#119)
* installer: Add fallback ping checks for the internet check Signed-off-by: Peter Jung <admin@ptr1337.dev> * Update src/installer.rs Co-authored-by: Vladislav Nepogodin <nepogodin.vlad@gmail.com> * Update src/installer.rs Co-authored-by: Vladislav Nepogodin <nepogodin.vlad@gmail.com> * Update src/installer.rs Co-authored-by: Vladislav Nepogodin <nepogodin.vlad@gmail.com> * Update src/installer.rs Co-authored-by: Vladislav Nepogodin <nepogodin.vlad@gmail.com> * Update src/installer.rs Co-authored-by: Vladislav Nepogodin <nepogodin.vlad@gmail.com> * Update src/installer.rs Co-authored-by: Vladislav Nepogodin <nepogodin.vlad@gmail.com> * installer: Add IPV6 Signed-off-by: Peter Jung <admin@ptr1337.dev> --------- Signed-off-by: Peter Jung <admin@ptr1337.dev> Co-authored-by: Vladislav Nepogodin <nepogodin.vlad@gmail.com>
1 parent 5bc91da commit b687897

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

src/installer.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,34 @@ fn edition_compat_check(window: &gtk::Window, message: String) -> bool {
9696
}
9797

9898
fn connectivity_check(window: &gtk::Window, message: String) -> bool {
99-
let status = match reqwest::blocking::get("https://cachyos.org") {
99+
// First try HTTP check to cachyos.org
100+
let http_status = match reqwest::blocking::get("https://cachyos.org") {
100101
Ok(resp) => resp.status().is_success() || resp.status().is_server_error(),
101102
_ => false,
102103
};
103104

104-
if !status {
105-
utils::show_simple_dialog(window, gtk::MessageType::Error, &fl!("offline-error"), message);
106-
return false;
105+
if http_status {
106+
return true;
107107
}
108-
true
108+
109+
// If HTTP check fails, try ping fallback to reliable DNS servers
110+
111+
for target in ["2001:4860:4860::8888", "2606:4700:4700::1111", "2620:fe::fe", "8.8.8.8", "1.1.1.1", "9.9.9.9"] {
112+
let ping_result = Exec::cmd("ping")
113+
.args(&["-c", "1", "-W", "3", target])
114+
.join();
115+
116+
if let Ok(status) = ping_result {
117+
if status.success() {
118+
info!("Connectivity confirmed via ping to {target}");
119+
return true;
120+
}
121+
}
122+
}
123+
124+
// All connectivity checks failed
125+
utils::show_simple_dialog(window, gtk::MessageType::Error, &fl!("offline-error"), message);
126+
false
109127
}
110128

111129
pub fn launch_installer(message: String) {

0 commit comments

Comments
 (0)