fix(gui): verify install over SSH; smaller toolbar icons

- Install verify no longer false-fails on images that serve only SSH. The
  install worker now polls the target's SSH banner after writing (stock
  Antminers ship dropbear 2018/2019; any newer banner on the board we just
  installed to means alkane booted), independent of the HTTP /api/identity
  scan probe. The GUI's HTTP awaiting message is softened to make clear it is
  only about the row auto-refresh, not an install failure. Fixes the "installed
  but did not answer as alkane" seen on the A113D bench image (SSH-only, no
  HTTP API).
- Toolbar icons 22px -> 16px so they fit the control row.

Note: a minimal image without the HTTP API still will not appear in the scan
(the scan probe is HTTP); the proper fix is an A113D image that serves the
flare-ui/API (separate alkane-os/sdk work).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
2026-11-17 14:14:59 -06:00
co-authored by Claude Opus 4.8
parent 8cb6989000
commit 080bebe050
2 changed files with 91 additions and 8 deletions
+82 -5
View File
@@ -10,14 +10,75 @@
//! Results stream back over a channel, drained by the UI timer tick exactly like
//! restore.rs. The UI gates each behind a typed-FLASH confirmation.
use std::io::Read as _;
use std::net::TcpStream;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{channel, Receiver};
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::Arc;
use std::time::{Duration, Instant};
use alkane_artifacts::afw::{verify_afw, VerifyOptions};
use alkane_artifacts::fetch::{self, ReleaseSource};
use alkane_flash::stock::{self, RestoreImages};
/// Read the SSH identification banner (no auth) from `host:22`, e.g.
/// `SSH-2.0-dropbear_2026.93`.
fn ssh_banner(host: &str) -> Option<String> {
let addr: std::net::SocketAddr = format!("{host}:22").parse().ok()?;
let mut s = TcpStream::connect_timeout(&addr, Duration::from_secs(4)).ok()?;
s.set_read_timeout(Some(Duration::from_secs(4))).ok()?;
let mut buf = [0u8; 128];
let n = s.read(&mut buf).ok()?;
if n == 0 {
return None;
}
Some(
String::from_utf8_lossy(&buf[..n])
.lines()
.next()
.unwrap_or("")
.trim()
.to_string(),
)
}
/// Whether a just-installed board's SSH banner looks like alkane. We installed
/// alkane to this specific board, so any SSH banner that is NOT the stock
/// Antminer dropbear (2018/2019) means our image booted. Alkane images ship a
/// current dropbear regardless of whether the image also serves the HTTP API, so
/// this verify works even for minimal images that do not serve `:80` (the
/// HTTP-only scan probe cannot see those).
fn banner_is_alkane(banner: &str) -> bool {
let b = banner.to_ascii_lowercase();
if b.contains("dropbear_2018") || b.contains("dropbear_2019") {
return false;
}
b.contains("dropbear") || b.contains("openssh")
}
/// Poll a just-installed board until it comes up as alkane over SSH (not the
/// stock dropbear) or the deadline passes. Streams a progress line on success.
fn verify_alkane_live(ip: &str, tx: &Sender<StockMsg>, cancel: &AtomicBool) -> bool {
let deadline = Instant::now() + Duration::from_secs(150);
loop {
if cancel.load(Ordering::Relaxed) {
return false;
}
if let Some(b) = ssh_banner(ip) {
if banner_is_alkane(&b) {
let _ = tx.send(StockMsg::Progress(format!(
"{ip}: alkane is live (ssh \"{b}\")"
)));
return true;
}
}
if Instant::now() >= deadline {
return false;
}
std::thread::sleep(Duration::from_secs(5));
}
}
use alkane_flash::stock_firmware;
use crate::scan::fake_scan_enabled;
@@ -248,10 +309,26 @@ pub fn start_install(
let (ok, detail) =
match stock::install_from_stock(&ip, &afw_path, &verified, password.as_deref())
{
Ok(()) => (
true,
"installed alkane-os (verify liveness over the network)".to_string(),
),
Ok(()) => {
// The write succeeded; now confirm the board rebooted
// into alkane. Use the SSH banner (works even for
// images that do not serve the HTTP API) rather than
// only the HTTP scan probe.
let _ = tx.send(StockMsg::Progress(format!(
"{ip}: installed; awaiting reboot into alkane (up to 150s)..."
)));
if verify_alkane_live(&ip, &tx, &tc) {
(true, "installed; alkane is live (SSH-verified)".to_string())
} else {
(
true,
"installed; alkane not confirmed over SSH within the window -- \
check the board (a minimal image without the HTTP API still \
installs and boots; it just will not show in the scan)"
.to_string(),
)
}
}
Err(e) => (false, format!("install failed: {e}")),
};
if tx.send(StockMsg::Result { ip, ok, detail }).is_err() {
+9 -3
View File
@@ -1292,9 +1292,9 @@ pub fn build(frame: Widget) -> App {
(0x33, 0x33, 0x33)
};
let icon_btn = |svg: &str, id: i32, tip: &str| -> Widget {
let b = Widget::svg_button(panel, &svg_recolored(svg, icon_fg), id, 22, 22);
let b = Widget::svg_button(panel, &svg_recolored(svg, icon_fg), id, 16, 16);
b.set_tool_tip(&crate::i18n::t(tip));
ctl.add(b, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 4);
ctl.add(b, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 2);
b
};
let _data_btn = icon_btn(SVG_DATA, ID_DATA, "Data: presets, filter, columns, export");
@@ -4813,8 +4813,14 @@ impl App {
for ip in expired {
awaiting.remove(&ip);
op_status.remove(&ip);
// The install worker already verifies liveness over SSH; this only
// means the HTTP scan probe did not pick the board up, so its row
// will not auto-refresh to the alkane entry. Common for a minimal
// image that serves SSH but not the HTTP API -- not an install
// failure.
crate::logs::log(format!(
"{ip}: installed, but did not answer as alkane within the verify window"
"{ip}: not answering the alkane HTTP API; its row will not auto-update \
(the image may serve only SSH). See the install result above."
));
}
}