fix(installer): de-duplicate common wingtech/tmohs

The Tmobile TMOHS1 is clearly based on the Wingtech CT2MHS01, and thus
the installation process looks very similar between them.
This commit is contained in:
oopsbagel
2025-06-24 16:58:18 -07:00
committed by Cooper Quintin
parent b7636386fc
commit 27bf20fbf4
4 changed files with 30 additions and 121 deletions

View File

@@ -4,6 +4,7 @@ use std::str::FromStr;
use std::time::Duration;
use anyhow::{Context, Result, bail};
use reqwest::Client;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::time::{sleep, timeout};
@@ -105,3 +106,25 @@ pub async fn send_file(admin_ip: &str, local_path: &str, remote_path: &str) -> R
println!("Successfully sent {local_path} to {remote_path}");
Ok(())
}
pub async fn http_ok_every(rayhunter_url: String, interval: Duration, max_failures: u32) -> Result<()> {
let client = Client::new();
let mut failures = 0;
loop {
match client.get(&rayhunter_url).send().await {
Ok(test) => match test.status().is_success() {
true => break,
false => bail!(
"request for url ({rayhunter_url}) failed with status code: {:?}",
test.status()
),
},
Err(e) => match failures > max_failures {
true => return Err(e.into()),
false => failures += 1,
},
}
sleep(interval).await;
}
Ok(())
}