Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63ada5bb99 |
@@ -240,23 +240,39 @@ fn wm_aes_ecb_enc(pwd_md5: &str, data: &str) -> Option<String> {
|
|||||||
fn probe_whatsminer_access(ip: &str, passwords: &[String]) -> Option<bool> {
|
fn probe_whatsminer_access(ip: &str, passwords: &[String]) -> Option<bool> {
|
||||||
let timeout = Duration::from_secs(6);
|
let timeout = Duration::from_secs(6);
|
||||||
let mut reachable = false;
|
let mut reachable = false;
|
||||||
|
// A transient error on one candidate must not abandon the others (round 18 #12):
|
||||||
|
// skip to the next candidate, but remember it happened so we never report a
|
||||||
|
// confident "locked" when the answer was really indeterminate.
|
||||||
|
let mut errored = false;
|
||||||
for pass in passwords {
|
for pass in passwords {
|
||||||
// 1. get_token (no auth) -> salt / newsalt / time.
|
// 1. get_token (no auth) -> salt / newsalt / time.
|
||||||
let tok_resp = match wm_rpc(ip, "{\"command\":\"get_token\"}", timeout) {
|
let tok_resp = match wm_rpc(ip, "{\"command\":\"get_token\"}", timeout) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(_) => return None,
|
Err(_) => {
|
||||||
|
errored = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let v: serde_json::Value = match serde_json::from_str(&tok_resp) {
|
let v: serde_json::Value = match serde_json::from_str(&tok_resp) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => return None,
|
Err(_) => {
|
||||||
|
errored = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let msg = v.get("Msg")?;
|
let (Some(salt), Some(newsalt), Some(time)) = v
|
||||||
let (Some(salt), Some(newsalt), Some(time)) = (
|
.get("Msg")
|
||||||
msg.get("salt").and_then(|s| s.as_str()),
|
.map(|msg| {
|
||||||
msg.get("newsalt").and_then(|s| s.as_str()),
|
(
|
||||||
msg.get("time").and_then(|s| s.as_str()),
|
msg.get("salt").and_then(|s| s.as_str()),
|
||||||
) else {
|
msg.get("newsalt").and_then(|s| s.as_str()),
|
||||||
return None;
|
msg.get("time").and_then(|s| s.as_str()),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.unwrap_or((None, None, None))
|
||||||
|
else {
|
||||||
|
errored = true;
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
reachable = true;
|
reachable = true;
|
||||||
// 2. Derive the md5crypt password hash + write-token from the password.
|
// 2. Derive the md5crypt password hash + write-token from the password.
|
||||||
@@ -274,15 +290,19 @@ fn probe_whatsminer_access(ip: &str, passwords: &[String]) -> Option<bool> {
|
|||||||
let payload = format!("{{\"enc\":1,\"data\":\"{enc}\"}}");
|
let payload = format!("{{\"enc\":1,\"data\":\"{enc}\"}}");
|
||||||
let resp = match wm_rpc(ip, &payload, timeout) {
|
let resp = match wm_rpc(ip, &payload, timeout) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(_) => return None,
|
Err(_) => {
|
||||||
|
errored = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if resp.contains("\"enc\"") {
|
if resp.contains("\"enc\"") {
|
||||||
return Some(false); // accepted -> unlocked/writable
|
return Some(false); // accepted -> unlocked/writable
|
||||||
}
|
}
|
||||||
// rejected -> try the next candidate password
|
// rejected -> try the next candidate password
|
||||||
}
|
}
|
||||||
// Reached the miner and every candidate password was rejected -> locked.
|
// Only report "locked" when we cleanly reached the miner and every candidate
|
||||||
if reachable { Some(true) } else { None }
|
// was rejected with no transient errors; otherwise the result is indeterminate.
|
||||||
|
if reachable && !errored { Some(true) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -191,7 +191,12 @@ pub fn clear_firmware_credentials() -> std::io::Result<()> {
|
|||||||
/// otherwise the backend falls back to its own default auth. With nothing saved
|
/// otherwise the backend falls back to its own default auth. With nothing saved
|
||||||
/// this is plain `MinerFactory::new()`.
|
/// this is plain `MinerFactory::new()`.
|
||||||
pub fn configured_factory() -> MinerFactory {
|
pub fn configured_factory() -> MinerFactory {
|
||||||
let mut factory = MinerFactory::new();
|
// Apply the operator's configured identification timeout to every factory
|
||||||
|
// (round 18 #12: config actions / refresh / pools / flash previously used
|
||||||
|
// asic-rs's 10s default, so on a slow link they could fail to reach miners a
|
||||||
|
// longer-timeout scan had found). start_scan may still override it explicitly.
|
||||||
|
let mut factory =
|
||||||
|
MinerFactory::new().with_identification_timeout_secs(crate::scan::load_scan_timeout().max(1));
|
||||||
let global = load_credentials();
|
let global = load_credentials();
|
||||||
let per_fw = load_firmware_credentials();
|
let per_fw = load_firmware_credentials();
|
||||||
if global.is_none() && per_fw.is_empty() {
|
if global.is_none() && per_fw.is_empty() {
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ impl Board {
|
|||||||
let control_board = crate::naming::control_board_code(self.make, self.board, &model);
|
let control_board = crate::naming::control_board_code(self.make, self.board, &model);
|
||||||
let cpu = crate::naming::control_board_cpu(self.make, self.board, &model);
|
let cpu = crate::naming::control_board_cpu(self.make, self.board, &model);
|
||||||
let board_code = crate::naming::control_board_board(self.make, self.board, &model);
|
let board_code = crate::naming::control_board_board(self.make, self.board, &model);
|
||||||
|
// Computed before `model` is moved into the struct literal below.
|
||||||
|
let pic_present = crate::scan::infer_pic(&model);
|
||||||
MinerRow {
|
MinerRow {
|
||||||
ip: self.ip.to_string(),
|
ip: self.ip.to_string(),
|
||||||
selected: false,
|
selected: false,
|
||||||
@@ -192,13 +194,9 @@ impl Board {
|
|||||||
// show variety offline). control_board is derived above via naming.
|
// show variety offline). control_board is derived above via naming.
|
||||||
algorithm: "SHA256".to_string(),
|
algorithm: "SHA256".to_string(),
|
||||||
control_board,
|
control_board,
|
||||||
pic_present: if self.model_id.contains("S21") {
|
// Use the same PIC inference the live scan uses (round 18 #12: the demo
|
||||||
Some(false) // noPIC example
|
// previously reimplemented a simplified version that disagreed with it).
|
||||||
} else if self.make.eq_ignore_ascii_case("antminer") {
|
pic_present,
|
||||||
Some(true)
|
|
||||||
} else {
|
|
||||||
None // WhatsMiner: unknown over the network
|
|
||||||
},
|
|
||||||
// Access: idle/view-only units (no worker) shown locked; the rest
|
// Access: idle/view-only units (no worker) shown locked; the rest
|
||||||
// unlocked. (Live rows infer this from control capabilities.)
|
// unlocked. (Live rows infer this from control capabilities.)
|
||||||
write_locked: Some(self.worker.is_empty()),
|
write_locked: Some(self.worker.is_empty()),
|
||||||
|
|||||||
@@ -689,7 +689,13 @@ impl MinerRow {
|
|||||||
if (0..base.len()).any(board_faulted) {
|
if (0..base.len()).any(board_faulted) {
|
||||||
for (i, h) in base.iter_mut().enumerate() {
|
for (i, h) in base.iter_mut().enumerate() {
|
||||||
if board_faulted(i) {
|
if board_faulted(i) {
|
||||||
*h = CompHealth::Down;
|
// A genuinely-undetected board stays grey ("not detected") even
|
||||||
|
// when a fault text names it: a message like "chain N not found"
|
||||||
|
// describes exactly that missing board, and grey-vs-red is the
|
||||||
|
// documented distinction (round 18 #12). Only detected boards go red.
|
||||||
|
if *h != CompHealth::Unreachable {
|
||||||
|
*h = CompHealth::Down;
|
||||||
|
}
|
||||||
} else if *h == CompHealth::Down {
|
} else if *h == CompHealth::Down {
|
||||||
*h = ok; // stall-reddened but not named by the fault codes
|
*h = ok; // stall-reddened but not named by the fault codes
|
||||||
}
|
}
|
||||||
@@ -1896,6 +1902,21 @@ mod tests {
|
|||||||
assert_eq!(rb[0], CompHealth::Ok); // running -> green despite PSU fault
|
assert_eq!(rb[0], CompHealth::Ok); // running -> green despite PSU fault
|
||||||
assert_eq!(rb[1], CompHealth::Ok);
|
assert_eq!(rb[1], CompHealth::Ok);
|
||||||
assert_eq!(rb[2], CompHealth::Unreachable); // only the undetected board is grey
|
assert_eq!(rb[2], CompHealth::Unreachable); // only the undetected board is grey
|
||||||
|
|
||||||
|
// Round 18 #12: a genuinely-undetected board that is ALSO named by a board
|
||||||
|
// fault (e.g. a "chain 2 not found" message attributed to Board(2)) must
|
||||||
|
// stay grey ("not detected"), not turn red -- grey vs red is the
|
||||||
|
// detected/undetected distinction.
|
||||||
|
let missing_named = MinerRow {
|
||||||
|
is_mining: true,
|
||||||
|
board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Missing],
|
||||||
|
faults: vec![fault(FaultComponent::Board(2), "Chain 2 not found, check connection")],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let mb = missing_named.board_healths();
|
||||||
|
assert_eq!(mb[0], CompHealth::Ok);
|
||||||
|
assert_eq!(mb[1], CompHealth::Ok);
|
||||||
|
assert_eq!(mb[2], CompHealth::Unreachable, "undetected board named by a fault stays grey");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -287,8 +287,10 @@ fn is_s17_era(clean_model: &str) -> bool {
|
|||||||
/// S19k Pro, and the S21 Pro; everything else AMLogic is the 120mm C76. asic-rs
|
/// S19k Pro, and the S21 Pro; everything else AMLogic is the 120mm C76. asic-rs
|
||||||
/// cannot tell these apart, so this is a model-family heuristic, not a read.
|
/// cannot tell these apart, so this is a model-family heuristic, not a read.
|
||||||
fn is_aml_140mm(clean_model: &str) -> bool {
|
fn is_aml_140mm(clean_model: &str) -> bool {
|
||||||
|
// Per the doc above: XP-class, the S19k Pro, and the S21 Pro -- NOT every S21
|
||||||
|
// (plain S21 / S21+ / S21e are the 120mm C76 board) (round 18 #12).
|
||||||
let m = clean_model.trim_start();
|
let m = clean_model.trim_start();
|
||||||
m.contains("XP") || m.starts_with("S19k") || m.starts_with("S21")
|
m.contains("XP") || m.starts_with("S19k") || m.contains("S21 Pro")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Nameplate expected hashrate in Sol/s for an Equihash (Zcash) miner model, when
|
/// Nameplate expected hashrate in Sol/s for an Equihash (Zcash) miner model, when
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ mod board_index_tests {
|
|||||||
///
|
///
|
||||||
/// The one genuinely ambiguous model is the plain "S19j Pro" (both PIC and noPIC
|
/// The one genuinely ambiguous model is the plain "S19j Pro" (both PIC and noPIC
|
||||||
/// revisions exist); it is assumed PIC unless the model string says noPIC.
|
/// revisions exist); it is assumed PIC unless the model string says noPIC.
|
||||||
fn infer_pic(model: &str) -> Option<bool> {
|
pub(crate) fn infer_pic(model: &str) -> Option<bool> {
|
||||||
let m = model.to_lowercase();
|
let m = model.to_lowercase();
|
||||||
if m.contains("nopic") {
|
if m.contains("nopic") {
|
||||||
return Some(false);
|
return Some(false);
|
||||||
|
|||||||
@@ -2488,7 +2488,14 @@ impl App {
|
|||||||
PromptKind::Password => format!("New web/API password for {n} miner(s):"),
|
PromptKind::Password => format!("New web/API password for {n} miner(s):"),
|
||||||
};
|
};
|
||||||
root.add(Widget::static_text(dlg, &lbl), 0, sf::BORDER_ALL, 8);
|
root.add(Widget::static_text(dlg, &lbl), 0, sf::BORDER_ALL, 8);
|
||||||
let input = Widget::text_ctrl(dlg, false);
|
// The change-password prompt masks its field so the new fleet password is
|
||||||
|
// never shown in the clear (round 18 #12); the numeric/timezone prompts use
|
||||||
|
// a normal field.
|
||||||
|
let input = if matches!(kind, PromptKind::Password) {
|
||||||
|
Widget::password_ctrl(dlg)
|
||||||
|
} else {
|
||||||
|
Widget::text_ctrl(dlg, false)
|
||||||
|
};
|
||||||
input.set_min_size(200, -1);
|
input.set_min_size(200, -1);
|
||||||
root.add(input, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 8);
|
root.add(input, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 8);
|
||||||
let btns = Widget::box_sizer(false);
|
let btns = Widget::box_sizer(false);
|
||||||
@@ -3177,12 +3184,15 @@ impl App {
|
|||||||
/// overlap rather than block the UI by joining the old scan thread (which
|
/// overlap rather than block the UI by joining the old scan thread (which
|
||||||
/// could freeze it for up to the per-miner scan timeout); the probes target
|
/// could freeze it for up to the per-miner scan timeout); the probes target
|
||||||
/// live miners, so a momentary overlap is harmless.
|
/// live miners, so a momentary overlap is harmless.
|
||||||
fn begin_scan(&mut self, lines: Vec<String>) {
|
/// Returns whether a scan actually started (false if deferred, e.g. mid-flash),
|
||||||
|
/// so callers don't overwrite the real status with a bogus "scanning..."
|
||||||
|
/// (round 18 #12).
|
||||||
|
fn begin_scan(&mut self, lines: Vec<String>) -> bool {
|
||||||
// Never probe the network while a firmware flash is uploading: a stray
|
// Never probe the network while a firmware flash is uploading: a stray
|
||||||
// scan connection to a miner mid-write can interrupt/corrupt the flash.
|
// scan connection to a miner mid-write can interrupt/corrupt the flash.
|
||||||
if self.flashing {
|
if self.flashing {
|
||||||
wx_rs::set_status_text("firmware flash in progress -- scan deferred");
|
wx_rs::set_status_text("firmware flash in progress -- scan deferred");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if let Some(old) = self.scan.take() {
|
if let Some(old) = self.scan.take() {
|
||||||
old.stop();
|
old.stop();
|
||||||
@@ -3190,12 +3200,14 @@ impl App {
|
|||||||
self.scan = Some(scan::start_scan(lines, self.scan_timeout_secs));
|
self.scan = Some(scan::start_scan(lines, self.scan_timeout_secs));
|
||||||
self.scanning = true;
|
self.scanning = true;
|
||||||
self.countdown = 0;
|
self.countdown = 0;
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start a fresh scan of the saved ranges.
|
/// Start a fresh scan of the saved ranges.
|
||||||
fn start_new_scan(&mut self) {
|
fn start_new_scan(&mut self) {
|
||||||
self.begin_scan(scan::load_ranges());
|
if self.begin_scan(scan::load_ranges()) {
|
||||||
wx_rs::set_status_text("scanning...");
|
wx_rs::set_status_text("scanning...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The table's selection changed (ctrl/shift-click). Mirror it into the
|
/// The table's selection changed (ctrl/shift-click). Mirror it into the
|
||||||
|
|||||||
Reference in New Issue
Block a user