Get rid of the 'verify' which is flakey

This commit is contained in:
Ember
2026-03-23 17:16:23 -07:00
committed by Markus Unterwaditzer
parent f0849340cf
commit bada3846dc
3 changed files with 8 additions and 48 deletions

View File

@@ -13,7 +13,7 @@ use tokio::time::sleep;
use crate::TmobileArgs as Args;
use crate::output::{print, println};
use crate::util::{reboot_and_verify, telnet_send_command, telnet_send_file};
use crate::util::{reboot_device, telnet_send_command, telnet_send_file};
use crate::wingtech::start_telnet;
pub async fn install(
@@ -92,7 +92,7 @@ async fn run_install(admin_ip: String, admin_password: String) -> Result<()> {
)
.await?;
reboot_and_verify(addr, "reboot", &admin_ip).await;
reboot_device(addr, "reboot", &admin_ip).await;
Ok(())
}

View File

@@ -1,11 +1,9 @@
use std::io::IsTerminal;
use std::net::SocketAddr;
use std::str::FromStr;
use std::time::Duration;
use anyhow::{Context, Result, bail};
use nusb::Device;
use reqwest::Client;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::time::{sleep, timeout};
@@ -207,49 +205,11 @@ pub async fn send_file(admin_ip: &str, local_path: &str, remote_path: &str) -> R
Ok(())
}
pub async fn reboot_and_verify(addr: SocketAddr, reboot_command: &str, admin_ip: &str) {
println!("Installation complete. Rebooting device...");
pub async fn reboot_device(addr: SocketAddr, reboot_command: &str, admin_ip: &str) {
println!(
"Done. Rebooting device. After it's started up again, check out the web interface at http://{admin_ip}:8080"
);
let _ = telnet_send_command(addr, reboot_command, "", true).await;
if std::io::stdin().is_terminal() {
println!(
"The device is rebooting. You will need to reconnect to the device's WiFi network."
);
print!("Once you've reconnected, press Enter to verify the installation: ");
let mut input = String::new();
let _ = std::io::stdin().read_line(&mut input);
print!("Verifying rayhunter ... ");
sleep(Duration::from_secs(5)).await;
let client = Client::new();
let url = format!("http://{admin_ip}:8080/index.html");
let mut success = false;
for _ in 0..5 {
if let Ok(resp) = client.get(&url).send().await
&& resp.status().is_success()
{
success = true;
break;
}
sleep(Duration::from_secs(3)).await;
}
if success {
println!("ok");
println!("rayhunter is running at http://{admin_ip}:8080");
} else {
println!("could not reach rayhunter.");
println!(
"The device may still be booting. Check http://{admin_ip}:8080 in a minute or two."
);
}
} else {
println!(
"Device is rebooting. Check http://{}:8080 after it finishes booting.",
admin_ip
);
}
}
/// General function to open a USB device

View File

@@ -1,6 +1,6 @@
use crate::WingtechArgs as Args;
use crate::output::{print, println};
use crate::util::{reboot_and_verify, telnet_send_command, telnet_send_file};
use crate::util::{reboot_device, telnet_send_command, telnet_send_file};
use aes::Aes128;
use aes::cipher::{BlockEncrypt, KeyInit, generic_array::GenericArray};
use anyhow::{Context, Result, bail};
@@ -141,7 +141,7 @@ async fn wingtech_run_install(admin_ip: String, admin_password: String) -> Resul
)
.await?;
reboot_and_verify(addr, "shutdown -r -t 1 now", &admin_ip).await;
reboot_device(addr, "shutdown -r -t 1 now", &admin_ip).await;
Ok(())
}