Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51b4eb2556 | ||
|
|
3b18219e4e | ||
|
|
bcc0ba38b6 | ||
|
|
749cdc4eed |
@@ -0,0 +1,20 @@
|
|||||||
|
# cargo-audit configuration (read by `cargo audit` from the project root).
|
||||||
|
#
|
||||||
|
# The two entries below are accepted, documented exceptions -- both live only in
|
||||||
|
# the wx-rs BUILD-dependency tree (reqwest 0.11, used by wx-rs's build.rs to
|
||||||
|
# download the wxWidgets source on Windows/macOS). On Linux download_dist()
|
||||||
|
# returns before ever constructing an HTTP client, and none of this is linked
|
||||||
|
# into the runtime binary, which talks to miners over asic-rs's reqwest 0.13
|
||||||
|
# (hyper 1.x / h2 0.4). The build tree is fully vendored and offline, so these
|
||||||
|
# cannot be upgraded without re-vendoring a newer reqwest.
|
||||||
|
#
|
||||||
|
# Re-review whenever the vendored dependency set is refreshed.
|
||||||
|
|
||||||
|
[advisories]
|
||||||
|
ignore = [
|
||||||
|
# h2 0.3 unbounded empty DATA frames (DoS). Build-time only; our build-time
|
||||||
|
# HTTP client only fetches a fixed HTTPS URL, and only on Windows/macOS.
|
||||||
|
"RUSTSEC-2026-0258",
|
||||||
|
# rustls-pemfile 1.0.4 unmaintained. Same build-only reqwest 0.11 subtree.
|
||||||
|
"RUSTSEC-2025-0134",
|
||||||
|
]
|
||||||
@@ -49,6 +49,13 @@ jobs:
|
|||||||
echo "wx prefix restored from cache"
|
echo "wx prefix restored from cache"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Clippy (our crate, warnings are errors)
|
||||||
|
if: steps.ver.outputs.release == 'true'
|
||||||
|
run: |
|
||||||
|
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
||||||
|
rustup component add clippy >/dev/null 2>&1 || true
|
||||||
|
cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
|
||||||
|
|
||||||
- name: Set crate version to ${{ steps.ver.outputs.version }}
|
- name: Set crate version to ${{ steps.ver.outputs.version }}
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: |
|
run: |
|
||||||
@@ -81,6 +88,43 @@ jobs:
|
|||||||
BIN=target/release/alkane-toolkit
|
BIN=target/release/alkane-toolkit
|
||||||
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN"
|
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN"
|
||||||
|
|
||||||
|
- name: Dependency audit (best-effort)
|
||||||
|
if: steps.ver.outputs.release == 'true'
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
if command -v cargo-audit >/dev/null 2>&1; then
|
||||||
|
cargo audit || echo "cargo audit reported findings (accepted ones in .cargo/audit.toml)"
|
||||||
|
else
|
||||||
|
echo "cargo-audit not installed on this runner; skipping"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Refresh the committed README badges from live metrics and push any change
|
||||||
|
# back to main. Best-effort: a locked-down runner that can't push must not
|
||||||
|
# fail the release. A badges-only push does not bump the version (see
|
||||||
|
# compute-version.sh), so it does not loop back into another release.
|
||||||
|
- name: Refresh badges
|
||||||
|
if: steps.ver.outputs.release == 'true'
|
||||||
|
continue-on-error: true
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
||||||
|
PASS=$(cargo test -p alkane-gui --offline 2>&1 \
|
||||||
|
| grep -hoE '[0-9]+ passed' | grep -oE '[0-9]+' | awk '{s+=$1} END{print s+0}')
|
||||||
|
python3 ci/gen-badges.py --tests "${PASS:-0}" --bench "row-render + scan-parse"
|
||||||
|
if [ -n "$(git status --porcelain badges)" ]; then
|
||||||
|
git config user.name "alkane-ci"
|
||||||
|
git config user.email "ci@bluefla.re"
|
||||||
|
git add badges
|
||||||
|
git commit -m "ci: refresh README badges [skip release]"
|
||||||
|
API="${GITHUB_API_URL:-https://gitea.bluefla.re/api/v1}"
|
||||||
|
HOST="${API%/api/v1}"
|
||||||
|
git push "${HOST}/${GITHUB_REPOSITORY}.git" "HEAD:main" \
|
||||||
|
-c http.extraheader="Authorization: token ${TOKEN}" || echo "badge push skipped"
|
||||||
|
else
|
||||||
|
echo "badges unchanged"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Package artifact
|
- name: Package artifact
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
id: pkg
|
id: pkg
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
name: verify
|
||||||
|
|
||||||
|
# Pre-merge quality gate: clippy + build + tests + microbenchmarks + the headless
|
||||||
|
# UI self-test, plus a best-effort dependency audit. Runs on pull requests and on
|
||||||
|
# pushes to any branch EXCEPT main (main is gated by release.yml, which repeats
|
||||||
|
# these checks before it cuts a release -- so no work is duplicated on main).
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches-ignore: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
verify:
|
||||||
|
runs-on: alkane-ci
|
||||||
|
env:
|
||||||
|
WX_PREFIX: /root/.cache/wx-3.3.3-linux
|
||||||
|
WX_RS_WXCONFIG: /root/.cache/wx-3.3.3-linux/bin/wx-config
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install build dependencies
|
||||||
|
run: |
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y -qq --no-install-recommends \
|
||||||
|
libssl-dev pkg-config ca-certificates >/dev/null
|
||||||
|
|
||||||
|
- name: Cache vendored wxWidgets build
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: /root/.cache/wx-3.3.3-linux
|
||||||
|
key: wx-3.3.3-${{ runner.os }}-${{ hashFiles('thirdparty/wx-rs/VERSION') }}
|
||||||
|
|
||||||
|
- name: Build wxWidgets (once, then cached)
|
||||||
|
run: |
|
||||||
|
if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then
|
||||||
|
bash scripts/build-wx-linux.sh
|
||||||
|
else
|
||||||
|
echo "wx prefix restored from cache"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Clippy (our crate, warnings are errors)
|
||||||
|
run: |
|
||||||
|
rustup component add clippy >/dev/null 2>&1 || true
|
||||||
|
cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cargo build --release -p alkane-gui --offline
|
||||||
|
|
||||||
|
- name: Unit tests
|
||||||
|
run: cargo test -p alkane-gui --offline
|
||||||
|
|
||||||
|
- name: Microbenchmarks
|
||||||
|
run: cargo test -p alkane-gui --release --offline -- --ignored --nocapture bench_
|
||||||
|
|
||||||
|
- name: Headless UI self-test
|
||||||
|
run: |
|
||||||
|
apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
||||||
|
xvfb xauth dbus-x11 fonts-dejavu-core >/dev/null
|
||||||
|
BIN=target/release/alkane-toolkit
|
||||||
|
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN"
|
||||||
|
|
||||||
|
# Advisory audit is best-effort: it needs the RustSec DB over the network,
|
||||||
|
# which the vendored/offline build otherwise never touches, so a locked-down
|
||||||
|
# runner must not fail the gate on it. Accepted advisories live in
|
||||||
|
# .cargo/audit.toml.
|
||||||
|
- name: Dependency audit (best-effort)
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
if command -v cargo-audit >/dev/null 2>&1; then
|
||||||
|
cargo audit || echo "cargo audit reported findings (see .cargo/audit.toml for accepted ones)"
|
||||||
|
else
|
||||||
|
echo "cargo-audit not installed on this runner; skipping"
|
||||||
|
fi
|
||||||
@@ -1,38 +1,116 @@
|
|||||||
# alkane-toolkit
|
# alkane-toolkit
|
||||||
|
|
||||||
Cross-platform desktop toolkit (Rust core, native GUI) to install **stock** or
|
[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
|
||||||
**alkaneOS** firmware on ASIC miner control boards, whatever they currently run
|

|
||||||
(stock, Vnish/AnthillOS, Braiins OS+, LuxOS, ePIC, BixBit, WardenOS).
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
Sibling to [alkane-sdk](https://gitea.bluefla.re/blueflare/alkane-sdk): the SDK
|
A cross-platform desktop toolkit for discovering, monitoring, and re-flashing
|
||||||
owns board knowledge and build outputs; this toolkit is the orchestration
|
ASIC miners. It scans a fleet over the network, shows live health and hashrate
|
||||||
engine and operator UI that executes its install recipes safely.
|
in a sortable table, and installs **stock** or **alkaneOS** firmware onto a
|
||||||
|
control board whatever it currently runs (stock, VNish/AnthillOS, Braiins OS+,
|
||||||
|
LuxOS, ePIC, HiveOn, BixBit, WardenOS).
|
||||||
|
|
||||||
## Status
|
The core and UI are pure Rust; the native window is wxWidgets driven through a
|
||||||
|
vendored, patched [wx-rs](thirdparty/wx-rs) bridge, so there is no Electron,
|
||||||
|
no web view, and a single self-contained binary per platform.
|
||||||
|
|
||||||
M1 primary view ships: discovery (vendored asic-rs 0.8.1) + the UI-SPEC
|
## What it does
|
||||||
table (6 KPIs, sortable/drag-reorderable columns, row checkboxes, scan-range
|
|
||||||
editor, Excel-style filter, columns panel). Pure-Rust GUI on wxWidgets via
|
|
||||||
vendored + patched wx-rs (docs/adr/0002, 0003).
|
|
||||||
|
|
||||||
## Build + run (Debian)
|
- **Discover** a fleet by CIDR or IP range and identify each miner's make,
|
||||||
|
model, control board, and firmware (via a vendored [asic-rs](vendor/asic-rs)).
|
||||||
|
- **Monitor** hashrate vs. expected, per-board health, chip temperatures, fans,
|
||||||
|
PSU state, and pool workers, with an Excel-style filter and drag-reorderable
|
||||||
|
columns.
|
||||||
|
- **Operate** miners from a right-click menu: flash the locate light, pause /
|
||||||
|
resume, restart, set a power or hashrate target, select a firmware profile
|
||||||
|
(LuxOS/VNish presets), configure pools, set the timezone, and change the
|
||||||
|
password -- each action offered only when every selected miner supports it.
|
||||||
|
- **Install firmware**: push stock or aftermarket images, or revert an
|
||||||
|
aftermarket miner to stock, behind a typed confirmation.
|
||||||
|
|
||||||
|
Discovery and telemetry are read-only and safe to run against any fleet; every
|
||||||
|
mutating action is capability-gated and, where destructive, confirmed.
|
||||||
|
|
||||||
|
## Build and run (Debian/Ubuntu)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
scripts/build-wx-linux.sh # once: builds vendored wx 3.3.3 to ~/.cache
|
scripts/build-wx-linux.sh # once: builds the vendored wxWidgets 3.3.3 into ~/.cache
|
||||||
scripts/build-gui-linux.sh # cargo build --release -p alkane-gui
|
scripts/build-gui-linux.sh # cargo build --release -p alkane-gui
|
||||||
~/.cache/alkane-tk-target/release/alkane-toolkit
|
~/.cache/alkane-tk-target/release/alkane-toolkit
|
||||||
```
|
```
|
||||||
|
|
||||||
Windows/macOS: `scripts/build-gui-windows.sh` (needs a Windows/msys2
|
Runtime needs GTK 3: `sudo apt install libgtk-3-0`. To explore the UI with no
|
||||||
toolchain) and `scripts/build-gui-macos.sh` (needs a Mac) - the GUI code is
|
hardware, run the offline demo fleet:
|
||||||
shared; only the C++ bridge + wx differ per platform.
|
|
||||||
|
|
||||||
See `docs/IMPLEMENTATION-PLAN.md` for the roadmap.
|
```sh
|
||||||
|
ALKANE_FAKE_SCAN=1 alkane-toolkit
|
||||||
|
```
|
||||||
|
|
||||||
## Hard rules (from alkane-sdk `docs/install-methods.md`, encoded in code)
|
Windows and macOS share all GUI code; only the C++ bridge and wx build differ
|
||||||
|
(`scripts/build-gui-windows.sh` needs an msys2 toolchain, `-macos.sh` needs a
|
||||||
|
Mac).
|
||||||
|
|
||||||
1. Never write the bootloader/secure region.
|
## Command-line probe
|
||||||
|
|
||||||
|
`miner_probe` is a headless companion for hardware checks that should not go
|
||||||
|
through the window event loop -- discovery, telemetry, and each write action:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
miner_probe scan 10.0.0.0/24 # discover + telemetry (TSV)
|
||||||
|
miner_probe presets 10.0.0.5 # list a firmware's selectable profiles
|
||||||
|
miner_probe setpreset 10.0.0.5 540MHz
|
||||||
|
```
|
||||||
|
|
||||||
|
Run `miner_probe` with no arguments for the full verb list.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export WX_RS_WXCONFIG="$HOME/.cache/wx-3.3.3-linux/bin/wx-config"
|
||||||
|
export CARGO_TARGET_DIR="$HOME/.cache/alkane-tk-target" # keep the target tree off the source share
|
||||||
|
|
||||||
|
cargo test -p alkane-gui # unit tests
|
||||||
|
cargo test -p alkane-gui --release -- --ignored bench_ # microbenchmarks
|
||||||
|
cargo clippy -p alkane-gui --no-deps --bins -- -D warnings # lint gate
|
||||||
|
xvfb-run -a env ALKANE_SELFTEST=1 \
|
||||||
|
"$CARGO_TARGET_DIR/release/alkane-toolkit" # headless UI self-test
|
||||||
|
```
|
||||||
|
|
||||||
|
CI mirrors these: `verify.yml` runs the lint, tests, benchmarks, self-test, and
|
||||||
|
a best-effort dependency audit on every pull request and branch push;
|
||||||
|
`release.yml` repeats them on `main` and cuts an `X.Y.Z` release with the built
|
||||||
|
binary attached when the change warrants it. Dependencies are vendored under
|
||||||
|
`vendor/`, so builds never touch the network.
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
- `crates/alkane-gui` -- the application: scan engine, data model, wxWidgets UI,
|
||||||
|
and the `miner_probe` CLI (the other `crates/alkane-*` are early scaffolding).
|
||||||
|
- `vendor/asic-rs` -- the miner-discovery and control library, vendored and
|
||||||
|
extended through numbered patches under `thirdparty/asic-rs/patches`.
|
||||||
|
- `thirdparty/wx-rs` -- the patched wxWidgets bridge (see `docs/adr/0002`,
|
||||||
|
`0003`).
|
||||||
|
|
||||||
|
See [`docs/IMPLEMENTATION-PLAN.md`](docs/IMPLEMENTATION-PLAN.md) for the roadmap
|
||||||
|
and [`docs/aftermarket-parity-roadmap.md`](docs/aftermarket-parity-roadmap.md)
|
||||||
|
for the firmware config/scan parity work.
|
||||||
|
|
||||||
|
## Firmware safety rules
|
||||||
|
|
||||||
|
Encoded in code, from alkane-sdk `docs/install-methods.md`:
|
||||||
|
|
||||||
|
1. Never write the bootloader or secure region.
|
||||||
2. Verify on a channel the installer does not control.
|
2. Verify on a channel the installer does not control.
|
||||||
3. Reboot is root-only; a dropped SSH connection can be success.
|
3. Reboot is root-only; a dropped SSH connection can still be success.
|
||||||
4. A packer is per board; never reuse across boards.
|
4. A packer is per board; never reuse one across boards.
|
||||||
5. Boot-switch handling is an explicit, verified step.
|
5. Boot-switch handling is an explicit, verified step.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Dual-licensed under either of [Apache-2.0](LICENSE-APACHE) or
|
||||||
|
[MIT](LICENSE-MIT) at your option.
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="206.0" height="20" role="img" aria-label="bench: row-render + scan-parse">
|
||||||
|
<title>bench: row-render + scan-parse</title>
|
||||||
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="r"><rect width="206.0" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
|
<g clip-path="url(#r)">
|
||||||
|
<rect width="44.5" height="20" fill="#555"/>
|
||||||
|
<rect x="44.5" width="161.5" height="20" fill="#007ec6"/>
|
||||||
|
<rect width="206.0" height="20" fill="url(#s)"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
|
<text x="22.2" y="15" fill="#010101" fill-opacity=".3">bench</text>
|
||||||
|
<text x="22.2" y="14">bench</text>
|
||||||
|
<text x="125.2" y="15" fill="#010101" fill-opacity=".3">row-render + scan-parse</text>
|
||||||
|
<text x="125.2" y="14">row-render + scan-parse</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 993 B |
@@ -0,0 +1,19 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="95.5" height="20" role="img" aria-label="coverage: 36%">
|
||||||
|
<title>coverage: 36%</title>
|
||||||
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="r"><rect width="95.5" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
|
<g clip-path="url(#r)">
|
||||||
|
<rect width="64.0" height="20" fill="#555"/>
|
||||||
|
<rect x="64.0" width="31.5" height="20" fill="#fe7d37"/>
|
||||||
|
<rect width="95.5" height="20" fill="url(#s)"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
|
<text x="32.0" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
||||||
|
<text x="32.0" y="14">coverage</text>
|
||||||
|
<text x="79.8" y="15" fill="#010101" fill-opacity=".3">36%</text>
|
||||||
|
<text x="79.8" y="14">36%</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 919 B |
@@ -0,0 +1,19 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="121.5" height="20" role="img" aria-label="dependencies: 349">
|
||||||
|
<title>dependencies: 349</title>
|
||||||
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="r"><rect width="121.5" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
|
<g clip-path="url(#r)">
|
||||||
|
<rect width="90.0" height="20" fill="#555"/>
|
||||||
|
<rect x="90.0" width="31.5" height="20" fill="#007ec6"/>
|
||||||
|
<rect width="121.5" height="20" fill="url(#s)"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
|
<text x="45.0" y="15" fill="#010101" fill-opacity=".3">dependencies</text>
|
||||||
|
<text x="45.0" y="14">dependencies</text>
|
||||||
|
<text x="105.8" y="15" fill="#010101" fill-opacity=".3">349</text>
|
||||||
|
<text x="105.8" y="14">349</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 940 B |
@@ -0,0 +1,19 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="180.0" height="20" role="img" aria-label="license: MIT OR Apache-2.0">
|
||||||
|
<title>license: MIT OR Apache-2.0</title>
|
||||||
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="r"><rect width="180.0" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
|
<g clip-path="url(#r)">
|
||||||
|
<rect width="57.5" height="20" fill="#555"/>
|
||||||
|
<rect x="57.5" width="122.5" height="20" fill="#007ec6"/>
|
||||||
|
<rect width="180.0" height="20" fill="url(#s)"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
|
<text x="28.8" y="15" fill="#010101" fill-opacity=".3">license</text>
|
||||||
|
<text x="28.8" y="14">license</text>
|
||||||
|
<text x="118.8" y="15" fill="#010101" fill-opacity=".3">MIT OR Apache-2.0</text>
|
||||||
|
<text x="118.8" y="14">MIT OR Apache-2.0</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 977 B |
@@ -0,0 +1,19 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="141.0" height="20" role="img" aria-label="lines of code: 12.5k">
|
||||||
|
<title>lines of code: 12.5k</title>
|
||||||
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="r"><rect width="141.0" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
|
<g clip-path="url(#r)">
|
||||||
|
<rect width="96.5" height="20" fill="#555"/>
|
||||||
|
<rect x="96.5" width="44.5" height="20" fill="#007ec6"/>
|
||||||
|
<rect width="141.0" height="20" fill="url(#s)"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
|
<text x="48.2" y="15" fill="#010101" fill-opacity=".3">lines of code</text>
|
||||||
|
<text x="48.2" y="14">lines of code</text>
|
||||||
|
<text x="118.8" y="15" fill="#010101" fill-opacity=".3">12.5k</text>
|
||||||
|
<text x="118.8" y="14">12.5k</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 952 B |
@@ -0,0 +1,19 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="95.5" height="20" role="img" aria-label="clippy: clean">
|
||||||
|
<title>clippy: clean</title>
|
||||||
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="r"><rect width="95.5" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
|
<g clip-path="url(#r)">
|
||||||
|
<rect width="51.0" height="20" fill="#555"/>
|
||||||
|
<rect x="51.0" width="44.5" height="20" fill="#4c1"/>
|
||||||
|
<rect width="95.5" height="20" fill="url(#s)"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
|
<text x="25.5" y="15" fill="#010101" fill-opacity=".3">clippy</text>
|
||||||
|
<text x="25.5" y="14">clippy</text>
|
||||||
|
<text x="73.2" y="15" fill="#010101" fill-opacity=".3">clean</text>
|
||||||
|
<text x="73.2" y="14">clean</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 916 B |
@@ -0,0 +1,19 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="121.5" height="20" role="img" aria-label="tests: 94 passing">
|
||||||
|
<title>tests: 94 passing</title>
|
||||||
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="r"><rect width="121.5" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
|
<g clip-path="url(#r)">
|
||||||
|
<rect width="44.5" height="20" fill="#555"/>
|
||||||
|
<rect x="44.5" width="77.0" height="20" fill="#4c1"/>
|
||||||
|
<rect width="121.5" height="20" fill="url(#s)"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
|
<text x="22.2" y="15" fill="#010101" fill-opacity=".3">tests</text>
|
||||||
|
<text x="22.2" y="14">tests</text>
|
||||||
|
<text x="83.0" y="15" fill="#010101" fill-opacity=".3">94 passing</text>
|
||||||
|
<text x="83.0" y="14">94 passing</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 935 B |
@@ -35,9 +35,11 @@ crates/alkane-gui/src/bin/*)
|
|||||||
ui=true ;;
|
ui=true ;;
|
||||||
crates/alkane-core/*|crates/alkane-discovery/*|crates/alkane-access/*|\
|
crates/alkane-core/*|crates/alkane-discovery/*|crates/alkane-access/*|\
|
||||||
crates/alkane-flash/*|crates/alkane-artifacts/*|crates/alkane-cli/*|\
|
crates/alkane-flash/*|crates/alkane-artifacts/*|crates/alkane-cli/*|\
|
||||||
crates/alkane-gui/src/scan.rs|crates/alkane-gui/src/model.rs|\
|
crates/alkane-gui/src/*|Cargo.toml|Cargo.lock|.gitea/*|ci/*|scripts/*|\
|
||||||
crates/alkane-gui/src/main.rs|Cargo.toml|Cargo.lock|.gitea/*|ci/*|scripts/*|\
|
|
||||||
vendor/*|thirdparty/asic-rs/*)
|
vendor/*|thirdparty/asic-rs/*)
|
||||||
|
# Any other GUI source file (naming, scan, model, pool_prefs, restore,
|
||||||
|
# access_probe, credentials, ...) is backend logic. ui.rs/fixtures.rs/bin
|
||||||
|
# match the UI arm above first, so they still bump Z, not Y.
|
||||||
backend=true ;;
|
backend=true ;;
|
||||||
*) : ;; # docs, HANDOFF, README, thirdparty/wxwidgets tree: no bump
|
*) : ;; # docs, HANDOFF, README, thirdparty/wxwidgets tree: no bump
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -0,0 +1,165 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Generate self-contained shields-style SVG badges into badges/.
|
||||||
|
|
||||||
|
Self-hosted Gitea renders a README's relative image links straight from the
|
||||||
|
repo, so committing the SVGs (rather than depending on an external badge
|
||||||
|
service that would have to reach a possibly-private Gitea) is the robust choice.
|
||||||
|
CI regenerates them from live metrics and commits any changes back.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
gen-badges.py --tests N --coverage PCT --bench "label" [--out badges]
|
||||||
|
|
||||||
|
Metrics not passed on the command line are computed here (LOC from the source
|
||||||
|
tree, dependency count from Cargo.lock, license from Cargo.toml).
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Approximate per-character width at 11px DejaVu Sans, in 1/10 px, matching the
|
||||||
|
# shields "flat" look closely enough for a fixed-width monospace-ish render.
|
||||||
|
CHAR_W = 6.5
|
||||||
|
PAD = 6.0
|
||||||
|
|
||||||
|
COLORS = {
|
||||||
|
"green": "#4c1",
|
||||||
|
"brightgreen": "#4c1",
|
||||||
|
"yellowgreen": "#a4a61d",
|
||||||
|
"yellow": "#dfb317",
|
||||||
|
"orange": "#fe7d37",
|
||||||
|
"red": "#e05d44",
|
||||||
|
"blue": "#007ec6",
|
||||||
|
"lightgrey": "#9f9f9f",
|
||||||
|
"grey": "#555",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def text_width(s: str) -> float:
|
||||||
|
return len(s) * CHAR_W + 2 * PAD
|
||||||
|
|
||||||
|
|
||||||
|
def badge_svg(label: str, message: str, color: str) -> str:
|
||||||
|
color = COLORS.get(color, color)
|
||||||
|
lw = round(text_width(label), 1)
|
||||||
|
mw = round(text_width(message), 1)
|
||||||
|
total = round(lw + mw, 1)
|
||||||
|
lx = round(lw / 2, 1)
|
||||||
|
mx = round(lw + mw / 2, 1)
|
||||||
|
# Text is drawn twice (a dark shadow then the light glyphs) for the shields look.
|
||||||
|
return f'''<svg xmlns="http://www.w3.org/2000/svg" width="{total}" height="20" role="img" aria-label="{label}: {message}">
|
||||||
|
<title>{label}: {message}</title>
|
||||||
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="r"><rect width="{total}" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
|
<g clip-path="url(#r)">
|
||||||
|
<rect width="{lw}" height="20" fill="#555"/>
|
||||||
|
<rect x="{lw}" width="{mw}" height="20" fill="{color}"/>
|
||||||
|
<rect width="{total}" height="20" fill="url(#s)"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
|
<text x="{lx}" y="15" fill="#010101" fill-opacity=".3">{label}</text>
|
||||||
|
<text x="{lx}" y="14">{label}</text>
|
||||||
|
<text x="{mx}" y="15" fill="#010101" fill-opacity=".3">{message}</text>
|
||||||
|
<text x="{mx}" y="14">{message}</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
def count_loc(root: str) -> int:
|
||||||
|
total = 0
|
||||||
|
for base in ("crates",):
|
||||||
|
for dirpath, _dirs, files in os.walk(os.path.join(root, base)):
|
||||||
|
for f in files:
|
||||||
|
if f.endswith(".rs"):
|
||||||
|
try:
|
||||||
|
with open(os.path.join(dirpath, f), encoding="utf-8", errors="ignore") as fh:
|
||||||
|
total += sum(1 for _ in fh)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
return total
|
||||||
|
|
||||||
|
|
||||||
|
def count_deps(root: str) -> int:
|
||||||
|
lock = os.path.join(root, "Cargo.lock")
|
||||||
|
try:
|
||||||
|
with open(lock, encoding="utf-8") as fh:
|
||||||
|
return sum(1 for line in fh if line.startswith("name = "))
|
||||||
|
except OSError:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def read_license(root: str) -> str:
|
||||||
|
try:
|
||||||
|
with open(os.path.join(root, "Cargo.toml"), encoding="utf-8") as fh:
|
||||||
|
for line in fh:
|
||||||
|
m = re.match(r'\s*license\s*=\s*"([^"]+)"', line)
|
||||||
|
if m:
|
||||||
|
return m.group(1)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
def loc_color(n: int) -> str:
|
||||||
|
return "blue"
|
||||||
|
|
||||||
|
|
||||||
|
def cov_color(pct: float) -> str:
|
||||||
|
if pct >= 80:
|
||||||
|
return "brightgreen"
|
||||||
|
if pct >= 60:
|
||||||
|
return "yellowgreen"
|
||||||
|
if pct >= 40:
|
||||||
|
return "yellow"
|
||||||
|
if pct >= 20:
|
||||||
|
return "orange"
|
||||||
|
return "red"
|
||||||
|
|
||||||
|
|
||||||
|
def human(n: int) -> str:
|
||||||
|
if n >= 1000:
|
||||||
|
return f"{n / 1000:.1f}k".replace(".0k", "k")
|
||||||
|
return str(n)
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
ap = argparse.ArgumentParser()
|
||||||
|
ap.add_argument("--out", default="badges")
|
||||||
|
ap.add_argument("--root", default=".")
|
||||||
|
ap.add_argument("--tests", type=int, default=None)
|
||||||
|
ap.add_argument("--coverage", type=float, default=None)
|
||||||
|
ap.add_argument("--bench", default=None)
|
||||||
|
ap.add_argument("--clippy", default="clean")
|
||||||
|
args = ap.parse_args()
|
||||||
|
|
||||||
|
os.makedirs(os.path.join(args.root, args.out), exist_ok=True)
|
||||||
|
|
||||||
|
def write(name, label, message, color):
|
||||||
|
path = os.path.join(args.root, args.out, name + ".svg")
|
||||||
|
with open(path, "w", encoding="utf-8") as fh:
|
||||||
|
fh.write(badge_svg(label, message, color))
|
||||||
|
print(f"wrote {path}: {label}={message}")
|
||||||
|
|
||||||
|
loc = count_loc(args.root)
|
||||||
|
deps = count_deps(args.root)
|
||||||
|
lic = read_license(args.root)
|
||||||
|
|
||||||
|
write("loc", "lines of code", human(loc), loc_color(loc))
|
||||||
|
write("license", "license", lic, "blue")
|
||||||
|
write("dependencies", "dependencies", str(deps), "blue")
|
||||||
|
write("quality", "clippy", args.clippy, "brightgreen" if args.clippy == "clean" else "orange")
|
||||||
|
if args.tests is not None:
|
||||||
|
write("tests", "tests", f"{args.tests} passing", "brightgreen")
|
||||||
|
if args.coverage is not None:
|
||||||
|
write("coverage", "coverage", f"{args.coverage:.0f}%", cov_color(args.coverage))
|
||||||
|
if args.bench is not None:
|
||||||
|
write("bench", "bench", args.bench, "blue")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -64,7 +64,6 @@ pub fn probe_access(ip: &str, make: &str, user: &str, pass: &str) -> Result<Opti
|
|||||||
return Ok(probe_whatsminer_access(ip, &whatsminer_password_candidates()));
|
return Ok(probe_whatsminer_access(ip, &whatsminer_password_candidates()));
|
||||||
}
|
}
|
||||||
let url = format!("http://{ip}{}", endpoint(make));
|
let url = format!("http://{ip}{}", endpoint(make));
|
||||||
let userpass = format!("{user}:{pass}");
|
|
||||||
let mut cmd = Command::new("curl");
|
let mut cmd = Command::new("curl");
|
||||||
cmd.args([
|
cmd.args([
|
||||||
"-s",
|
"-s",
|
||||||
@@ -73,15 +72,18 @@ pub fn probe_access(ip: &str, make: &str, user: &str, pass: &str) -> Result<Opti
|
|||||||
"-w",
|
"-w",
|
||||||
"%{http_code}",
|
"%{http_code}",
|
||||||
"--digest",
|
"--digest",
|
||||||
"-u",
|
|
||||||
&userpass,
|
|
||||||
"--connect-timeout",
|
"--connect-timeout",
|
||||||
"5",
|
"5",
|
||||||
"--max-time",
|
"--max-time",
|
||||||
"9",
|
"9",
|
||||||
|
"-K",
|
||||||
|
"-", // read the rest of the config (the credentials) from stdin
|
||||||
&url,
|
&url,
|
||||||
]);
|
]);
|
||||||
let out = wait_with_timeout(cmd, Duration::from_secs(12))?;
|
// The user:pass goes through a curl config on stdin, never argv, so it can't
|
||||||
|
// be read from the process list (round 18 #12).
|
||||||
|
let config = format!("user = \"{}\"\n", curl_config_quote(&format!("{user}:{pass}")));
|
||||||
|
let out = wait_with_timeout(cmd, Duration::from_secs(12), Some(config.as_bytes()))?;
|
||||||
// curl prints the status code to stdout regardless of exit status (000 on a
|
// curl prints the status code to stdout regardless of exit status (000 on a
|
||||||
// connection failure), so classify the code rather than the exit status.
|
// connection failure), so classify the code rather than the exit status.
|
||||||
let code = String::from_utf8_lossy(&out.stdout);
|
let code = String::from_utf8_lossy(&out.stdout);
|
||||||
@@ -89,11 +91,25 @@ pub fn probe_access(ip: &str, make: &str, user: &str, pass: &str) -> Result<Opti
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Run a command with a wall-clock timeout (curl can hang past --max-time on a
|
/// Run a command with a wall-clock timeout (curl can hang past --max-time on a
|
||||||
/// black-holed host).
|
/// black-holed host). `stdin_data`, when set, is written to the child's stdin and
|
||||||
fn wait_with_timeout(mut cmd: Command, timeout: Duration) -> Result<std::process::Output, String> {
|
/// the pipe closed -- used to feed a curl config (with the credentials) instead
|
||||||
use std::io::Read;
|
/// of putting them on the command line (round 18 #12).
|
||||||
|
fn wait_with_timeout(
|
||||||
|
mut cmd: Command,
|
||||||
|
timeout: Duration,
|
||||||
|
stdin_data: Option<&[u8]>,
|
||||||
|
) -> Result<std::process::Output, String> {
|
||||||
|
use std::io::{Read, Write};
|
||||||
cmd.stdout(std::process::Stdio::piped()).stderr(std::process::Stdio::piped());
|
cmd.stdout(std::process::Stdio::piped()).stderr(std::process::Stdio::piped());
|
||||||
|
if stdin_data.is_some() {
|
||||||
|
cmd.stdin(std::process::Stdio::piped());
|
||||||
|
}
|
||||||
let mut child = cmd.spawn().map_err(|e| format!("spawn curl: {e}"))?;
|
let mut child = cmd.spawn().map_err(|e| format!("spawn curl: {e}"))?;
|
||||||
|
if let Some(data) = stdin_data {
|
||||||
|
if let Some(mut si) = child.stdin.take() {
|
||||||
|
let _ = si.write_all(data);
|
||||||
|
} // dropping `si` closes the pipe so curl stops reading the config
|
||||||
|
}
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
loop {
|
loop {
|
||||||
match child.try_wait().map_err(|e| e.to_string())? {
|
match child.try_wait().map_err(|e| e.to_string())? {
|
||||||
@@ -111,6 +127,7 @@ fn wait_with_timeout(mut cmd: Command, timeout: Duration) -> Result<std::process
|
|||||||
None => {
|
None => {
|
||||||
if start.elapsed() >= timeout {
|
if start.elapsed() >= timeout {
|
||||||
let _ = child.kill();
|
let _ = child.kill();
|
||||||
|
let _ = child.wait(); // reap so we never leave a zombie (round 18 #12)
|
||||||
return Err("curl timed out".into());
|
return Err("curl timed out".into());
|
||||||
}
|
}
|
||||||
std::thread::sleep(Duration::from_millis(100));
|
std::thread::sleep(Duration::from_millis(100));
|
||||||
@@ -119,6 +136,11 @@ fn wait_with_timeout(mut cmd: Command, timeout: Duration) -> Result<std::process
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Escape a value for a curl `--config` file (double-quoted string).
|
||||||
|
fn curl_config_quote(s: &str) -> String {
|
||||||
|
s.replace('\\', "\\\\").replace('"', "\\\"")
|
||||||
|
}
|
||||||
|
|
||||||
/// Passwords to try for a WhatsMiner access check: a user-set per-firmware
|
/// Passwords to try for a WhatsMiner access check: a user-set per-firmware
|
||||||
/// override (round 12 #13) wins; otherwise the two factory defaults ("admin" for
|
/// override (round 12 #13) wins; otherwise the two factory defaults ("admin" for
|
||||||
/// V1/V2, "super" for V3). All attempts are non-mutating, so trying both is safe.
|
/// V1/V2, "super" for V3). All attempts are non-mutating, so trying both is safe.
|
||||||
|
|||||||
@@ -1342,7 +1342,12 @@ impl Column {
|
|||||||
if r.board_temps.is_empty() {
|
if r.board_temps.is_empty() {
|
||||||
if r.chip_temp_c > 0.0 { format!("{:.0}", r.chip_temp_c) } else { String::new() }
|
if r.chip_temp_c > 0.0 { format!("{:.0}", r.chip_temp_c) } else { String::new() }
|
||||||
} else {
|
} else {
|
||||||
r.board_temps.iter().map(|&t| format!("{t:.0}")).collect::<Vec<_>>().join(" / ")
|
// 0.0 == a board with no reading; show "-" so positions align.
|
||||||
|
r.board_temps
|
||||||
|
.iter()
|
||||||
|
.map(|&t| if t > 0.0 { format!("{t:.0}") } else { "-".to_string() })
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(" / ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Column::FluidTemp => num(r.fluid_temp_c, 1, " C"),
|
Column::FluidTemp => num(r.fluid_temp_c, 1, " C"),
|
||||||
@@ -1580,20 +1585,35 @@ impl ViewState {
|
|||||||
/// into `order`, leaving hidden columns in their existing slots, so a
|
/// into `order`, leaving hidden columns in their existing slots, so a
|
||||||
/// reorder while some column is hidden never drops or duplicates a column.
|
/// reorder while some column is hidden never drops or duplicates a column.
|
||||||
pub fn apply_visible_reorder(&mut self, new_visible: &[Column]) {
|
pub fn apply_visible_reorder(&mut self, new_visible: &[Column]) {
|
||||||
let disp = self.display_columns();
|
if new_visible.first() != Some(&Column::Ip) {
|
||||||
if new_visible.len() != disp.len() || new_visible.first() != Some(&Column::Ip) {
|
return; // Ip is fixed first
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let want: HashSet<Column> = disp.iter().copied().collect();
|
let shown: HashSet<Column> = new_visible.iter().copied().collect();
|
||||||
let got: HashSet<Column> = new_visible.iter().copied().collect();
|
if shown.len() != new_visible.len() {
|
||||||
if want != got {
|
return; // duplicates: not a permutation
|
||||||
return; // not a permutation of the visible columns: ignore
|
}
|
||||||
|
// `new_visible` is the set of columns the table actually SHOWS in their new
|
||||||
|
// order. That is `display_columns()` normally, but a SUBSET of it when
|
||||||
|
// auto-hide-empty is on (the widget omits the empty columns). Every shown
|
||||||
|
// column must be a real, currently-visible column; columns not in `shown`
|
||||||
|
// (hidden, or hidden-because-empty) keep their slot. Reordering just the
|
||||||
|
// shown subset is what lets drag-reorder work while a column is hidden
|
||||||
|
// (round 18 #12: the old code compared against display_columns() and so
|
||||||
|
// silently rejected every reorder whenever auto-hide-empty hid a column).
|
||||||
|
let reorderable: HashSet<Column> = self
|
||||||
|
.order
|
||||||
|
.iter()
|
||||||
|
.copied()
|
||||||
|
.filter(|c| *c == Column::Ip || self.visible.contains(c))
|
||||||
|
.collect();
|
||||||
|
if !shown.is_subset(&reorderable) {
|
||||||
|
return; // a non-visible column in the input: ignore
|
||||||
}
|
}
|
||||||
let mut next = new_visible.iter().copied();
|
let mut next = new_visible.iter().copied();
|
||||||
self.order = self
|
self.order = self
|
||||||
.order
|
.order
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&c| if want.contains(&c) { next.next().unwrap_or(c) } else { c })
|
.map(|&c| if shown.contains(&c) { next.next().unwrap_or(c) } else { c })
|
||||||
.collect();
|
.collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2337,6 +2357,31 @@ mod tests {
|
|||||||
assert_eq!(view.order, before, "a same-length non-permutation must be ignored");
|
assert_eq!(view.order, before, "a same-length non-permutation must be ignored");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn apply_visible_reorder_accepts_a_shown_subset() {
|
||||||
|
// Auto-hide-empty shows only a subset of the visible columns; dragging
|
||||||
|
// within that subset must be applied, not silently rejected (round 18 #12).
|
||||||
|
let mut view = ViewState::default();
|
||||||
|
let disp = view.display_columns();
|
||||||
|
assert!(disp.len() >= 4, "default view has several visible columns");
|
||||||
|
// Pretend disp[2] is empty and therefore hidden by the widget.
|
||||||
|
let dropped = disp[2];
|
||||||
|
let mut shown: Vec<Column> = disp.iter().copied().filter(|&c| c != dropped).collect();
|
||||||
|
shown.swap(1, 2); // reorder two columns of the shown subset
|
||||||
|
let before_set: HashSet<Column> = view.order.iter().copied().collect();
|
||||||
|
view.apply_visible_reorder(&shown);
|
||||||
|
assert_ne!(
|
||||||
|
view.display_columns().iter().copied().collect::<Vec<_>>(),
|
||||||
|
disp,
|
||||||
|
"a valid subset reorder must change the display order"
|
||||||
|
);
|
||||||
|
// No column lost or duplicated; Ip still first; the hidden column kept its slot.
|
||||||
|
assert_eq!(view.order.iter().copied().collect::<HashSet<_>>(), before_set);
|
||||||
|
assert_eq!(view.order.len(), before_set.len());
|
||||||
|
assert_eq!(view.display_columns().first(), Some(&Column::Ip));
|
||||||
|
assert_eq!(view.order.iter().filter(|&&c| c == dropped).count(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
/// Microbenchmark: the DEFAULT view (Ip ascending) at 5000 rows. The existing
|
/// Microbenchmark: the DEFAULT view (Ip ascending) at 5000 rows. The existing
|
||||||
/// bench_view_pipeline overrides sort to Hashrate, so it never exercised the
|
/// bench_view_pipeline overrides sort to Hashrate, so it never exercised the
|
||||||
/// default path (previously a lexical string sort).
|
/// default path (previously a lexical string sort).
|
||||||
|
|||||||
@@ -83,9 +83,24 @@ pub fn save_all(field: PoolField, values: &[String]) -> std::io::Result<usize> {
|
|||||||
let _ = std::fs::create_dir_all(dir);
|
let _ = std::fs::create_dir_all(dir);
|
||||||
}
|
}
|
||||||
std::fs::write(&p, out.join("\n"))?;
|
std::fs::write(&p, out.join("\n"))?;
|
||||||
|
// The password list can hold a pool password; keep every saved list owner-only
|
||||||
|
// (round 18 #12).
|
||||||
|
restrict_permissions(&p);
|
||||||
Ok(out.len())
|
Ok(out.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Best-effort tighten a config file to owner-only (0600) on Unix. A no-op
|
||||||
|
/// elsewhere; a failure is ignored (the file still exists, just not restricted).
|
||||||
|
fn restrict_permissions(path: &std::path::Path) {
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
let _ = std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600));
|
||||||
|
}
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
let _ = path;
|
||||||
|
}
|
||||||
|
|
||||||
/// Trim every value, then drop empties, values equal to a built-in preset, and
|
/// Trim every value, then drop empties, values equal to a built-in preset, and
|
||||||
/// later exact duplicates (first occurrence wins). Order is otherwise preserved.
|
/// later exact duplicates (first occurrence wins). Order is otherwise preserved.
|
||||||
fn dedupe_saved(presets: &[&str], values: &[String]) -> Vec<String> {
|
fn dedupe_saved(presets: &[&str], values: &[String]) -> Vec<String> {
|
||||||
|
|||||||
@@ -172,28 +172,30 @@ fn restore_braiins(ip: &str, user: &str, pass: &str) -> (bool, String) {
|
|||||||
return (false, "Braiins restore needs an SSH password (set the SSH login)".into());
|
return (false, "Braiins restore needs an SSH password (set the SSH login)".into());
|
||||||
}
|
}
|
||||||
let target = format!("{user}@{ip}");
|
let target = format!("{user}@{ip}");
|
||||||
// uninstall.sh is on Braiins OS+'s PATH; run it non-interactively.
|
// sshpass reads the password from $SSHPASS (-e) rather than argv (-p), so it
|
||||||
|
// never shows up in the process list (round 18 #12). Host-key checking is
|
||||||
|
// deliberately disabled: these are LAN miners whose SSH host key changes on
|
||||||
|
// every reflash, so pinning it would break the very revert this performs.
|
||||||
|
// BatchMode stops any interactive prompt from hanging out the 60 s cap.
|
||||||
let mut cmd = Command::new("sshpass");
|
let mut cmd = Command::new("sshpass");
|
||||||
cmd.arg("-p").arg(pass).arg("ssh");
|
cmd.env("SSHPASS", pass);
|
||||||
|
cmd.arg("-e").arg("ssh");
|
||||||
cmd.args([
|
cmd.args([
|
||||||
"-o", "StrictHostKeyChecking=no",
|
"-o", "StrictHostKeyChecking=no",
|
||||||
"-o", "UserKnownHostsFile=/dev/null",
|
"-o", "UserKnownHostsFile=/dev/null",
|
||||||
|
"-o", "BatchMode=yes",
|
||||||
"-o", "ConnectTimeout=8",
|
"-o", "ConnectTimeout=8",
|
||||||
&target,
|
&target,
|
||||||
"uninstall.sh || /sbin/uninstall.sh",
|
"uninstall.sh || /sbin/uninstall.sh",
|
||||||
]);
|
]);
|
||||||
match run_with_timeout(cmd, Duration::from_secs(60)) {
|
match run_with_timeout(cmd, Duration::from_secs(60)) {
|
||||||
Ok(out) => {
|
Ok(out) => classify_braiins(
|
||||||
let s = String::from_utf8_lossy(&out).to_lowercase();
|
&String::from_utf8_lossy(&out.stdout),
|
||||||
if s.contains("not found") || s.contains("no such") {
|
&String::from_utf8_lossy(&out.stderr),
|
||||||
(false, "uninstall.sh not found on the miner".into())
|
out.code,
|
||||||
} else {
|
out.timed_out,
|
||||||
(true, "ran uninstall.sh (reverts to stock + reboots)".into())
|
),
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// A reboot mid-command commonly drops the SSH connection; treat a
|
|
||||||
// connection-closed error after the command as likely success.
|
|
||||||
if e.contains("closed") || e.contains("reset") || e.contains("timed out") {
|
if e.contains("closed") || e.contains("reset") || e.contains("timed out") {
|
||||||
(true, "SSH dropped (miner likely rebooting to stock)".into())
|
(true, "SSH dropped (miner likely rebooting to stock)".into())
|
||||||
} else {
|
} else {
|
||||||
@@ -203,6 +205,42 @@ fn restore_braiins(ip: &str, user: &str, pass: &str) -> (bool, String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Decide a Braiins `uninstall.sh` outcome from its captured output. The critical
|
||||||
|
/// rule (round 18 #12): an SSH auth/connection failure -- which writes its
|
||||||
|
/// diagnostic to stderr, leaves stdout empty, and exits non-zero -- must be
|
||||||
|
/// reported as a FAILURE, never a false success. A dropped connection or a
|
||||||
|
/// timeout after the command started is the expected signature of the reboot.
|
||||||
|
fn classify_braiins(stdout: &str, stderr: &str, code: Option<i32>, timed_out: bool) -> (bool, String) {
|
||||||
|
let err = stderr.to_lowercase();
|
||||||
|
// ssh's own connection/auth failures (exit 255) never reach the remote command.
|
||||||
|
let conn_fail = [
|
||||||
|
"permission denied",
|
||||||
|
"connection refused",
|
||||||
|
"could not resolve",
|
||||||
|
"no route to host",
|
||||||
|
"connection timed out",
|
||||||
|
"operation timed out",
|
||||||
|
"host key verification failed",
|
||||||
|
"before authentication",
|
||||||
|
]
|
||||||
|
.iter()
|
||||||
|
.any(|m| err.contains(m));
|
||||||
|
if conn_fail {
|
||||||
|
let why = stderr.lines().map(str::trim).rfind(|l| !l.is_empty());
|
||||||
|
return (false, format!("SSH failed: {}", why.unwrap_or("connection/auth error")));
|
||||||
|
}
|
||||||
|
let out = stdout.to_lowercase();
|
||||||
|
if out.contains("not found") || out.contains("no such") || err.contains("not found") {
|
||||||
|
return (false, "uninstall.sh not found on the miner".into());
|
||||||
|
}
|
||||||
|
match code {
|
||||||
|
Some(0) => (true, "ran uninstall.sh (reverts to stock + reboots)".into()),
|
||||||
|
None => (true, "SSH dropped (miner likely rebooting to stock)".into()),
|
||||||
|
_ if timed_out => (true, "SSH timed out (miner likely rebooting to stock)".into()),
|
||||||
|
Some(c) => (false, format!("uninstall.sh exited {c}: {}", stderr.trim())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// One luxminer :4028 request/response (line-framed, socket closes after reply).
|
/// One luxminer :4028 request/response (line-framed, socket closes after reply).
|
||||||
fn lux_rpc(ip: &str, payload: &str) -> Result<String, String> {
|
fn lux_rpc(ip: &str, payload: &str) -> Result<String, String> {
|
||||||
let addr: SocketAddr = format!("{ip}:4028").parse().map_err(|e| format!("bad addr: {e}"))?;
|
let addr: SocketAddr = format!("{ip}:4028").parse().map_err(|e| format!("bad addr: {e}"))?;
|
||||||
@@ -228,50 +266,101 @@ fn lux_rpc(ip: &str, payload: &str) -> Result<String, String> {
|
|||||||
Ok(String::from_utf8_lossy(&buf).trim_matches('\u{0}').to_string())
|
Ok(String::from_utf8_lossy(&buf).trim_matches('\u{0}').to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// curl with a wall-clock cap (small responses; no pipe-drain thread needed).
|
/// The captured result of a timed subprocess run.
|
||||||
|
struct CmdOutput {
|
||||||
|
/// The process exit code, or `None` if it was killed / dropped / timed out.
|
||||||
|
code: Option<i32>,
|
||||||
|
stdout: Vec<u8>,
|
||||||
|
stderr: Vec<u8>,
|
||||||
|
timed_out: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// curl with a wall-clock cap. Errors only when the run produced no output and
|
||||||
|
/// timed out (a black-holed host); otherwise returns stdout even on a non-zero
|
||||||
|
/// exit (curl prints useful bodies/status on failures).
|
||||||
fn curl(args: &[&str]) -> Result<String, String> {
|
fn curl(args: &[&str]) -> Result<String, String> {
|
||||||
let mut cmd = Command::new("curl");
|
let mut cmd = Command::new("curl");
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
run_with_timeout(cmd, Duration::from_secs(15)).map(|o| String::from_utf8_lossy(&o).into_owned())
|
let out = run_with_timeout(cmd, Duration::from_secs(15))?;
|
||||||
|
if out.timed_out && out.stdout.is_empty() {
|
||||||
|
return Err("timed out".into());
|
||||||
|
}
|
||||||
|
Ok(String::from_utf8_lossy(&out.stdout).into_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run a command, capture stdout, with a hard wall-clock timeout.
|
/// Run a command with a hard wall-clock timeout, capturing stdout, stderr, and
|
||||||
fn run_with_timeout(mut cmd: Command, timeout: Duration) -> Result<Vec<u8>, String> {
|
/// the exit code. Both pipes are drained on their own threads so a child that
|
||||||
|
/// writes a lot to stderr can never deadlock against a full pipe (round 18 #12).
|
||||||
|
fn run_with_timeout(mut cmd: Command, timeout: Duration) -> Result<CmdOutput, String> {
|
||||||
cmd.stdout(std::process::Stdio::piped());
|
cmd.stdout(std::process::Stdio::piped());
|
||||||
cmd.stderr(std::process::Stdio::piped());
|
cmd.stderr(std::process::Stdio::piped());
|
||||||
let mut child = cmd.spawn().map_err(|e| format!("spawn: {e}"))?;
|
let mut child = cmd.spawn().map_err(|e| format!("spawn: {e}"))?;
|
||||||
let mut stdout = child.stdout.take().ok_or("no stdout")?;
|
let mut stdout = child.stdout.take().ok_or("no stdout")?;
|
||||||
let reader = std::thread::spawn(move || {
|
let mut stderr = child.stderr.take().ok_or("no stderr")?;
|
||||||
|
let out_reader = std::thread::spawn(move || {
|
||||||
let mut b = Vec::new();
|
let mut b = Vec::new();
|
||||||
let _ = stdout.read_to_end(&mut b);
|
let _ = stdout.read_to_end(&mut b);
|
||||||
b
|
b
|
||||||
});
|
});
|
||||||
|
let err_reader = std::thread::spawn(move || {
|
||||||
|
let mut b = Vec::new();
|
||||||
|
let _ = stderr.read_to_end(&mut b);
|
||||||
|
b
|
||||||
|
});
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
let mut timed_out = false;
|
let mut timed_out = false;
|
||||||
loop {
|
let status = loop {
|
||||||
match child.try_wait().map_err(|e| e.to_string())? {
|
match child.try_wait().map_err(|e| e.to_string())? {
|
||||||
Some(_) => break,
|
Some(s) => break Some(s),
|
||||||
None => {
|
None => {
|
||||||
if start.elapsed() >= timeout {
|
if start.elapsed() >= timeout {
|
||||||
let _ = child.kill();
|
let _ = child.kill();
|
||||||
|
let _ = child.wait(); // reap so we never leave a zombie
|
||||||
timed_out = true;
|
timed_out = true;
|
||||||
break;
|
break None;
|
||||||
}
|
}
|
||||||
std::thread::sleep(Duration::from_millis(50));
|
std::thread::sleep(Duration::from_millis(50));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
let out = reader.join().unwrap_or_default();
|
Ok(CmdOutput {
|
||||||
if timed_out && out.is_empty() {
|
code: status.and_then(|s| s.code()),
|
||||||
return Err("timed out".into());
|
stdout: out_reader.join().unwrap_or_default(),
|
||||||
}
|
stderr: err_reader.join().unwrap_or_default(),
|
||||||
Ok(out)
|
timed_out,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn braiins_auth_or_connection_failure_is_not_a_false_success() {
|
||||||
|
// The critical regression guard (round 18 #12): a wrong password or an
|
||||||
|
// unreachable miner writes to stderr, leaves stdout empty, and exits
|
||||||
|
// non-zero -- it must report failure, never "restored".
|
||||||
|
let (ok, msg) = classify_braiins("", "Permission denied, please try again.", Some(255), false);
|
||||||
|
assert!(!ok, "wrong password must not report success");
|
||||||
|
assert!(msg.to_lowercase().contains("ssh failed"), "{msg}");
|
||||||
|
|
||||||
|
let (ok, _) = classify_braiins("", "ssh: connect to host 10.0.0.9 port 22: Connection refused", Some(255), false);
|
||||||
|
assert!(!ok, "unreachable miner must not report success");
|
||||||
|
|
||||||
|
let (ok, _) = classify_braiins("", "ssh: Could not resolve hostname miner: Name or service not known", Some(255), false);
|
||||||
|
assert!(!ok, "unresolvable host must not report success");
|
||||||
|
|
||||||
|
// Genuine outcomes.
|
||||||
|
let (ok, _) = classify_braiins("uninstalling...\n", "", Some(0), false);
|
||||||
|
assert!(ok, "clean exit 0 is success");
|
||||||
|
let (ok, _) = classify_braiins("", "Connection to 10.0.0.5 closed by remote host.", None, false);
|
||||||
|
assert!(ok, "connection dropped mid-command (reboot) is success");
|
||||||
|
let (ok, _) = classify_braiins("", "", None, true);
|
||||||
|
assert!(ok, "timeout after the command started (reboot) is success");
|
||||||
|
let (ok, _) = classify_braiins("bash: uninstall.sh: command not found\n", "", Some(127), false);
|
||||||
|
assert!(!ok, "missing uninstall.sh is a failure");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn firmware_selects_the_right_flow() {
|
fn firmware_selects_the_right_flow() {
|
||||||
// The dispatcher only recognises the three revertible aftermarket
|
// The dispatcher only recognises the three revertible aftermarket
|
||||||
|
|||||||
@@ -408,26 +408,36 @@ pub fn start_scan(lines: Vec<String>, timeout_secs: u64) -> ScanHandle {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// scan_stream_with_ip yields one item per probed address, so we
|
// scan_stream_with_ip yields one item per probed address (identification
|
||||||
// get accurate progress plus the responders.
|
// is already concurrent up to SCAN_CONCURRENCY_LIMIT). Each responder's
|
||||||
let mut stream = factory.scan_stream_with_ip();
|
// telemetry (to_row -> get_data + presets: several REST calls) is then
|
||||||
|
// run concurrently via buffer_unordered instead of awaited one at a time
|
||||||
|
// -- otherwise the telemetry serialises and dominates the scan wall-clock
|
||||||
|
// (round 18 #12). buffer_unordered polls the underlying stream on its own,
|
||||||
|
// so identification concurrency is unaffected, and telemetry only ever
|
||||||
|
// targets responders (live miners), so the same cap is safe.
|
||||||
let mut done = 0usize;
|
let mut done = 0usize;
|
||||||
// Emit progress per address for a smoothly-climbing counter; only a
|
// Emit progress per address for a smoothly-climbing counter; only a
|
||||||
// very large scan (> 5000 addresses) is throttled, to bound channel
|
// very large scan (> 5000 addresses) is throttled, to bound channel
|
||||||
// traffic. The UI coalesces these to one gauge update per refresh.
|
// traffic. The UI coalesces these to one gauge update per refresh.
|
||||||
let step = (total / 5000).max(1);
|
let step = (total / 5000).max(1);
|
||||||
while let Some((ip, miner)) = stream.next().await {
|
let mut results = factory
|
||||||
|
.scan_stream_with_ip()
|
||||||
|
.map(|(ip, miner)| async move {
|
||||||
|
match miner {
|
||||||
|
// Only surface a row for an address that actually has a miner
|
||||||
|
// behind it; a non-responding address is never a phantom row.
|
||||||
|
Some(m) => (ip, Some(to_row(&*m).await)),
|
||||||
|
None => (ip, None),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.buffer_unordered(SCAN_CONCURRENCY_LIMIT);
|
||||||
|
while let Some((ip, row)) = results.next().await {
|
||||||
if thread_cancel.load(Ordering::Relaxed) {
|
if thread_cancel.load(Ordering::Relaxed) {
|
||||||
return; // Stop / re-scan requested
|
return; // Stop / re-scan requested
|
||||||
}
|
}
|
||||||
done += 1;
|
done += 1;
|
||||||
// Only surface a row for an address that actually has a miner
|
if let Some(row) = row {
|
||||||
// behind it. A non-responding address is not shown -- we never
|
|
||||||
// fabricate a phantom "offline" row for an empty IP; a miner is
|
|
||||||
// reported as "not hashing" only when it responds and we can see
|
|
||||||
// it is not mining.
|
|
||||||
if let Some(m) = miner {
|
|
||||||
let row = to_row(&*m).await;
|
|
||||||
if tx.send(ScanMsg::Row(row)).is_err() {
|
if tx.send(ScanMsg::Row(row)).is_err() {
|
||||||
return; // UI gone
|
return; // UI gone
|
||||||
}
|
}
|
||||||
@@ -644,17 +654,26 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
// alarmingly high and didn't match the temperature the miner itself reports;
|
// alarmingly high and didn't match the temperature the miner itself reports;
|
||||||
// the board temperature (~60-79C) is the figure the miner's own UI shows
|
// the board temperature (~60-79C) is the figure the miner's own UI shows
|
||||||
// (round 12 #3). Falls back to the chip temp when no board temp is reported.
|
// (round 12 #3). Falls back to the chip temp when no board temp is reported.
|
||||||
let board_temps: Vec<f64> = data
|
// Index-aligned with the hashboards (index i == board i): a board with no
|
||||||
.hashboards
|
// reading is 0.0, NOT dropped, so a missing middle board can't shift the
|
||||||
.iter()
|
// others left in the "77 / - / 74" Chip-temp cell (round 18 #12). Collapsed
|
||||||
.filter_map(|b| {
|
// to empty when NO board reports a temperature, so the cell falls back to the
|
||||||
b.board_temperature
|
// fleet average instead of showing "- / - / -".
|
||||||
.as_ref()
|
let board_temps: Vec<f64> = {
|
||||||
.or(b.outlet_chip_temperature.as_ref())
|
let v: Vec<f64> = data
|
||||||
.map(|t| t.as_celsius())
|
.hashboards
|
||||||
})
|
.iter()
|
||||||
.filter(|&t| t > 0.0)
|
.map(|b| {
|
||||||
.collect();
|
b.board_temperature
|
||||||
|
.as_ref()
|
||||||
|
.or(b.outlet_chip_temperature.as_ref())
|
||||||
|
.map(|t| t.as_celsius())
|
||||||
|
.filter(|&t| t > 0.0)
|
||||||
|
.unwrap_or(0.0)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
if v.iter().all(|&t| t <= 0.0) { Vec::new() } else { v }
|
||||||
|
};
|
||||||
// Per-board hashrate (TH/s), index-aligned with the hashboards, for the
|
// Per-board hashrate (TH/s), index-aligned with the hashboards, for the
|
||||||
// per-board Health tooltip (round 17 R2). Unlike board_temps this is NOT
|
// per-board Health tooltip (round 17 R2). Unlike board_temps this is NOT
|
||||||
// filtered/compacted -- index i must stay board i so the tooltip numbering
|
// filtered/compacted -- index i must stay board i so the tooltip numbering
|
||||||
@@ -732,7 +751,11 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
// "Stock") and carry it into the version instead (round 11 #6).
|
// "Stock") and carry it into the version instead (round 11 #6).
|
||||||
let (mut firmware, mut fw_vendor) = crate::naming::firmware_family(&data.device_info.firmware);
|
let (mut firmware, mut fw_vendor) = crate::naming::firmware_family(&data.device_info.firmware);
|
||||||
// Bixbit/Hiveon masquerade as stock; relabel them from their cgminer signature
|
// Bixbit/Hiveon masquerade as stock; relabel them from their cgminer signature
|
||||||
// so they get their own family + colour instead of "Stock" (round 17).
|
// so they get their own family + colour instead of "Stock" (round 17). This
|
||||||
|
// is one extra TCP probe per stock-labelled Antminer per scan (round 18 #12):
|
||||||
|
// deliberately re-run each scan rather than cached, because a miner's firmware
|
||||||
|
// can change under us between scans (a flash/restore), and the detection must
|
||||||
|
// stay current; it only fires for Antminers that still read as plain "Stock".
|
||||||
if data.device_info.make.eq_ignore_ascii_case("antminer") && firmware.eq_ignore_ascii_case("stock") {
|
if data.device_info.make.eq_ignore_ascii_case("antminer") && firmware.eq_ignore_ascii_case("stock") {
|
||||||
if let Some(fam) = detect_aftermarket_antminer(data.ip).await {
|
if let Some(fam) = detect_aftermarket_antminer(data.ip).await {
|
||||||
firmware = fam.to_string();
|
firmware = fam.to_string();
|
||||||
@@ -1251,16 +1274,24 @@ pub fn start_pools_action(targets: Vec<PoolTarget>) -> ActionHandle {
|
|||||||
|
|
||||||
if fake_scan_enabled() {
|
if fake_scan_enabled() {
|
||||||
let err_tx = tx.clone();
|
let err_tx = tx.clone();
|
||||||
|
let thread_cancel = cancel.clone();
|
||||||
let res = std::thread::Builder::new().name("fake-pools".into()).spawn(move || {
|
let res = std::thread::Builder::new().name("fake-pools".into()).spawn(move || {
|
||||||
|
let mut ok = 0usize;
|
||||||
for t in targets {
|
for t in targets {
|
||||||
|
// Honour cancellation between miners, like every sibling background
|
||||||
|
// action's fake branch (round 18 #12).
|
||||||
|
if thread_cancel.load(Ordering::Relaxed) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
let first = t.pools.first().map(|p| p.username.clone()).unwrap_or_default();
|
let first = t.pools.first().map(|p| p.username.clone()).unwrap_or_default();
|
||||||
let _ = tx.send(ActionMsg::Result {
|
let _ = tx.send(ActionMsg::Result {
|
||||||
ip: t.ip,
|
ip: t.ip,
|
||||||
ok: true,
|
ok: true,
|
||||||
detail: format!("simulated ({} pool(s), {first})", t.pools.len()),
|
detail: format!("simulated ({} pool(s), {first})", t.pools.len()),
|
||||||
});
|
});
|
||||||
|
ok += 1;
|
||||||
}
|
}
|
||||||
let _ = tx.send(ActionMsg::Done { ok: total, total });
|
let _ = tx.send(ActionMsg::Done { ok, total });
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
let _ = err_tx.send(ActionMsg::Done { ok: 0, total });
|
let _ = err_tx.send(ActionMsg::Done { ok: 0, total });
|
||||||
|
|||||||
@@ -291,7 +291,13 @@ fn encode_board_temps_cell(pal: &Palette, temps: &[f64], avg: f64) -> String {
|
|||||||
if i > 0 {
|
if i > 0 {
|
||||||
segs.push((None, " / ".to_string()));
|
segs.push((None, " / ".to_string()));
|
||||||
}
|
}
|
||||||
segs.push((Some(temp_color(pal, t)), format!("{t:.0}")));
|
// A 0.0 slot means "this board reported no temperature"; show a dash in its
|
||||||
|
// position so the remaining boards stay aligned (round 18 #12).
|
||||||
|
if t > 0.0 {
|
||||||
|
segs.push((Some(temp_color(pal, t)), format!("{t:.0}")));
|
||||||
|
} else {
|
||||||
|
segs.push((None, "-".to_string()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
encode_segments(&segs)
|
encode_segments(&segs)
|
||||||
}
|
}
|
||||||
@@ -639,6 +645,12 @@ pub struct App {
|
|||||||
// the first time fill_rows runs with rows present, so the default widths fit
|
// the first time fill_rows runs with rows present, so the default widths fit
|
||||||
// their contents (capped) once and manual resizes afterwards are preserved.
|
// their contents (capped) once and manual resizes afterwards are preserved.
|
||||||
columns_autosized: bool,
|
columns_autosized: bool,
|
||||||
|
// The columns the wxDataViewCtrl was actually built with, in creation order.
|
||||||
|
// fill_rows/header_click/reorder index the widget through table_columns() and
|
||||||
|
// assume it stays in lockstep; with auto-hide-empty on, a scan can change which
|
||||||
|
// columns are non-empty, so fill_rows watches for a mismatch and rebuilds
|
||||||
|
// rather than render against stale columns (round 18 #12).
|
||||||
|
built_columns: Vec<crate::model::Column>,
|
||||||
table_parent: Widget,
|
table_parent: Widget,
|
||||||
root_sizer: Widget,
|
root_sizer: Widget,
|
||||||
pub scan: Option<scan::ScanHandle>,
|
pub scan: Option<scan::ScanHandle>,
|
||||||
@@ -727,6 +739,11 @@ pub struct App {
|
|||||||
fwcreds_rows: Vec<(String, Widget, Widget)>,
|
fwcreds_rows: Vec<(String, Widget, Widget)>,
|
||||||
// Background access (lock-state) probe.
|
// Background access (lock-state) probe.
|
||||||
access_probe: Option<scan::AccessProbeHandle>,
|
access_probe: Option<scan::AccessProbeHandle>,
|
||||||
|
// In-flight background log fetch (round 18 #12): the miner IP plus a channel
|
||||||
|
// the worker thread sends the fetched log (or an error) on, so the API log
|
||||||
|
// fetch never blocks the UI thread. Drained in tick(); builds the viewer when
|
||||||
|
// it lands.
|
||||||
|
logfetch: Option<(String, std::sync::mpsc::Receiver<Result<crate::log_scan::LogScan, String>>)>,
|
||||||
// The API log viewer dialog (round 12 #12).
|
// The API log viewer dialog (round 12 #12).
|
||||||
logview_dialog: Widget,
|
logview_dialog: Widget,
|
||||||
// Settings > Logs page (round 15 #13).
|
// Settings > Logs page (round 15 #13).
|
||||||
@@ -1003,6 +1020,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
progress,
|
progress,
|
||||||
table: None,
|
table: None,
|
||||||
columns_autosized: false,
|
columns_autosized: false,
|
||||||
|
built_columns: Vec::new(),
|
||||||
table_parent,
|
table_parent,
|
||||||
root_sizer: root,
|
root_sizer: root,
|
||||||
scan: Some(scan::start_scan(ranges.clone(), scan::load_scan_timeout())),
|
scan: Some(scan::start_scan(ranges.clone(), scan::load_scan_timeout())),
|
||||||
@@ -1046,6 +1064,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
fwcreds_dialog: frame,
|
fwcreds_dialog: frame,
|
||||||
fwcreds_rows: Vec::new(),
|
fwcreds_rows: Vec::new(),
|
||||||
access_probe: None,
|
access_probe: None,
|
||||||
|
logfetch: None,
|
||||||
logview_dialog: frame,
|
logview_dialog: frame,
|
||||||
logs_dialog: frame,
|
logs_dialog: frame,
|
||||||
logs_text: frame,
|
logs_text: frame,
|
||||||
@@ -1198,6 +1217,10 @@ impl App {
|
|||||||
// Re-apply the table zoom so a non-100% zoom survives this rebuild
|
// Re-apply the table zoom so a non-100% zoom survives this rebuild
|
||||||
// (round 14 #3); the fresh columns come back at their 100% widths.
|
// (round 14 #3); the fresh columns come back at their 100% widths.
|
||||||
wx_rs::table_zoom_reapply();
|
wx_rs::table_zoom_reapply();
|
||||||
|
// Record exactly which columns the widget now holds, so fill_rows can
|
||||||
|
// detect an auto-hide-empty set change and rebuild rather than render
|
||||||
|
// against stale columns (round 18 #12).
|
||||||
|
self.built_columns = self.table_columns();
|
||||||
// Fresh columns come back at their configured default widths; let the
|
// Fresh columns come back at their configured default widths; let the
|
||||||
// next fill_rows shrink them to fit their contents (round 18 #10).
|
// next fill_rows shrink them to fit their contents (round 18 #10).
|
||||||
self.columns_autosized = false;
|
self.columns_autosized = false;
|
||||||
@@ -1206,6 +1229,15 @@ impl App {
|
|||||||
|
|
||||||
pub fn fill_rows(&mut self) {
|
pub fn fill_rows(&mut self) {
|
||||||
let Some(t) = self.table else { return };
|
let Some(t) = self.table else { return };
|
||||||
|
// If the set of shown columns has changed since the widget was built (only
|
||||||
|
// possible with auto-hide-empty on, when a scan makes a column non-empty),
|
||||||
|
// the widget's columns are stale: rendering now would misalign cells and
|
||||||
|
// header clicks. Rebuild instead -- deferred, because rebuild_table
|
||||||
|
// destroys this control (round 18 #12).
|
||||||
|
if self.table_columns() != self.built_columns {
|
||||||
|
wx_rs::call_after(DEFER_TABLE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Hold the scroll position across the full clear+refill so the table
|
// Hold the scroll position across the full clear+refill so the table
|
||||||
// doesn't jump back to the top as new rows stream in during a scan.
|
// doesn't jump back to the top as new rows stream in during a scan.
|
||||||
let top = t.dvlc_get_top_row();
|
let top = t.dvlc_get_top_row();
|
||||||
@@ -1898,13 +1930,17 @@ impl App {
|
|||||||
self.refresh = Some(scan::start_refresh(ips));
|
self.refresh = Some(scan::start_refresh(ips));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch the selected miner's log over its firmware API and show it in a
|
/// Start fetching the selected miner's log over its firmware API on a
|
||||||
/// viewer with a regex summary at the top (round 12 #12). The fetch is a
|
/// background thread (round 18 #12: the fetch is a multi-second network call
|
||||||
/// short blocking network call (a manual, single-miner action). Returns the
|
/// and must never block the wx event loop). The viewer is shown when the
|
||||||
/// dialog to show, or None after reporting why no log could be read.
|
/// result lands, in `drain_logfetch`.
|
||||||
fn build_log_view_dialog(&mut self) -> Option<Widget> {
|
fn start_log_fetch(&mut self) {
|
||||||
|
if self.logfetch.is_some() {
|
||||||
|
wx_rs::set_status_text("a log fetch is already in progress");
|
||||||
|
return;
|
||||||
|
}
|
||||||
let rows = self.selected_rows();
|
let rows = self.selected_rows();
|
||||||
let r = rows.first()?;
|
let Some(r) = rows.first() else { return };
|
||||||
let (ip, brand, firmware) = (r.ip.clone(), r.brand.clone(), r.firmware.clone());
|
let (ip, brand, firmware) = (r.ip.clone(), r.brand.clone(), r.firmware.clone());
|
||||||
// VNish unlock password + Antminer web login: a per-firmware override
|
// VNish unlock password + Antminer web login: a per-firmware override
|
||||||
// (round 12 #13) wins, else the shipped default / saved global creds.
|
// (round 12 #13) wins, else the shipped default / saved global creds.
|
||||||
@@ -1917,7 +1953,40 @@ impl App {
|
|||||||
let (am_user, am_pass) =
|
let (am_user, am_pass) =
|
||||||
credentials::load_credentials().unwrap_or_else(|| ("root".into(), "root".into()));
|
credentials::load_credentials().unwrap_or_else(|| ("root".into(), "root".into()));
|
||||||
wx_rs::set_status_text(&format!("fetching log from {ip}..."));
|
wx_rs::set_status_text(&format!("fetching log from {ip}..."));
|
||||||
let scan = match crate::log_scan::scan_log(&ip, &brand, &firmware, &vnish_pass, &am_user, &am_pass) {
|
let (tx, rx) = std::sync::mpsc::channel();
|
||||||
|
let ip_thread = ip.clone();
|
||||||
|
let spawned = std::thread::Builder::new().name("log-fetch".into()).spawn(move || {
|
||||||
|
let res = crate::log_scan::scan_log(
|
||||||
|
&ip_thread, &brand, &firmware, &vnish_pass, &am_user, &am_pass,
|
||||||
|
);
|
||||||
|
let _ = tx.send(res);
|
||||||
|
});
|
||||||
|
if spawned.is_err() {
|
||||||
|
wx_rs::set_status_text("could not start the log fetch");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.logfetch = Some((ip, rx));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Poll the in-flight log fetch; when it finishes, build the viewer dialog to
|
||||||
|
/// show (or report the error). Returns the dialog for `dispatch` to show
|
||||||
|
/// modally once the App borrow is released (round 18 #12).
|
||||||
|
fn drain_logfetch(&mut self) -> Option<Widget> {
|
||||||
|
let (ip, result) = {
|
||||||
|
let (ip, rx) = self.logfetch.as_ref()?;
|
||||||
|
match rx.try_recv() {
|
||||||
|
Ok(res) => (ip.clone(), res),
|
||||||
|
Err(std::sync::mpsc::TryRecvError::Empty) => return None,
|
||||||
|
Err(std::sync::mpsc::TryRecvError::Disconnected) => {
|
||||||
|
let ip = ip.clone();
|
||||||
|
self.logfetch = None;
|
||||||
|
wx_rs::set_status_text(&format!("log fetch aborted for {ip}"));
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
self.logfetch = None;
|
||||||
|
let scan = match result {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
self.set_error_indicator(&format!("log: {e}"));
|
self.set_error_indicator(&format!("log: {e}"));
|
||||||
@@ -1927,6 +1996,11 @@ impl App {
|
|||||||
};
|
};
|
||||||
self.clear_indicator();
|
self.clear_indicator();
|
||||||
wx_rs::set_status_text(&format!("{} miners", self.rows.len()));
|
wx_rs::set_status_text(&format!("{} miners", self.rows.len()));
|
||||||
|
Some(self.build_log_dialog(&ip, &scan))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build (but do not show) the log viewer for an already-fetched log.
|
||||||
|
fn build_log_dialog(&mut self, ip: &str, scan: &crate::log_scan::LogScan) -> Widget {
|
||||||
let frame = Widget::main_frame();
|
let frame = Widget::main_frame();
|
||||||
let dlg = Widget::dialog(frame, &format!("Miner log (API) -- {ip}"));
|
let dlg = Widget::dialog(frame, &format!("Miner log (API) -- {ip}"));
|
||||||
let root = Widget::box_sizer(true);
|
let root = Widget::box_sizer(true);
|
||||||
@@ -1948,7 +2022,7 @@ impl App {
|
|||||||
dlg.set_min_size(800, 540);
|
dlg.set_min_size(800, 540);
|
||||||
dlg.fit(dlg);
|
dlg.fit(dlg);
|
||||||
self.logview_dialog = dlg;
|
self.logview_dialog = dlg;
|
||||||
Some(dlg)
|
dlg
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Confirmation before restoring aftermarket firmware to stock (round 12 #8a,
|
/// Confirmation before restoring aftermarket firmware to stock (round 12 #8a,
|
||||||
@@ -2005,6 +2079,21 @@ impl App {
|
|||||||
/// keyword). Resolves the per-firmware credentials (VNish password from the
|
/// keyword). Resolves the per-firmware credentials (VNish password from the
|
||||||
/// round 12 #13 defaults; Braiins SSH login from the saved SSH creds).
|
/// round 12 #13 defaults; Braiins SSH login from the saved SSH creds).
|
||||||
fn apply_restore_confirm(&mut self) {
|
fn apply_restore_confirm(&mut self) {
|
||||||
|
// Restore-to-stock is destructive and needs exclusive access to the miners;
|
||||||
|
// refuse if any scan / refresh / action / flash or another restore is
|
||||||
|
// already in flight, so two operations never hit the same unit and a
|
||||||
|
// running restore handle is never orphaned by being overwritten (round 18 #12).
|
||||||
|
if self.flashing
|
||||||
|
|| self.scanning
|
||||||
|
|| self.action.is_some()
|
||||||
|
|| self.refresh.is_some()
|
||||||
|
|| self.restore.is_some()
|
||||||
|
{
|
||||||
|
wx_rs::set_status_text("busy (scan/action/restore in progress) -- try again once it finishes");
|
||||||
|
self.pending_restore.clear();
|
||||||
|
self.restore_dialog.close(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
let targets = std::mem::take(&mut self.pending_restore);
|
let targets = std::mem::take(&mut self.pending_restore);
|
||||||
if targets.is_empty() {
|
if targets.is_empty() {
|
||||||
self.restore_dialog.close(0);
|
self.restore_dialog.close(0);
|
||||||
@@ -2178,7 +2267,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
ID_CTX_REFRESH => self.start_refresh(self.selected_ip_list()),
|
ID_CTX_REFRESH => self.start_refresh(self.selected_ip_list()),
|
||||||
ID_CTX_ACCESS_PROBE => self.start_access_probe(),
|
ID_CTX_ACCESS_PROBE => self.start_access_probe(),
|
||||||
ID_CTX_VIEW_LOG => return self.build_log_view_dialog(),
|
ID_CTX_VIEW_LOG => self.start_log_fetch(),
|
||||||
ID_CTX_RESTORE_STOCK => return self.build_restore_confirm_dialog(),
|
ID_CTX_RESTORE_STOCK => return self.build_restore_confirm_dialog(),
|
||||||
ID_CTX_POOLS => return self.build_pools_dialog(),
|
ID_CTX_POOLS => return self.build_pools_dialog(),
|
||||||
ID_CTX_FLASH => {
|
ID_CTX_FLASH => {
|
||||||
@@ -2633,7 +2722,8 @@ impl App {
|
|||||||
user_input.set_min_size(150, -1);
|
user_input.set_min_size(150, -1);
|
||||||
user_input.set_value(&saved_user);
|
user_input.set_value(&saved_user);
|
||||||
grow.add(user_input, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
grow.add(user_input, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
||||||
let pass_input = Widget::text_ctrl(dlg, false);
|
// Masked so a saved password is never rendered in the clear (round 18 #12).
|
||||||
|
let pass_input = Widget::password_ctrl(dlg);
|
||||||
pass_input.set_min_size(150, -1);
|
pass_input.set_min_size(150, -1);
|
||||||
grow.add(pass_input, 1, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
grow.add(pass_input, 1, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
||||||
root.add_sizer(grow, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 6);
|
root.add_sizer(grow, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 6);
|
||||||
@@ -2667,7 +2757,7 @@ impl App {
|
|||||||
user_ctrl.set_min_size(150, -1);
|
user_ctrl.set_min_size(150, -1);
|
||||||
user_ctrl.set_value(&user);
|
user_ctrl.set_value(&user);
|
||||||
row.add(user_ctrl, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
row.add(user_ctrl, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
||||||
let pass_ctrl = Widget::text_ctrl(dlg, false);
|
let pass_ctrl = Widget::password_ctrl(dlg); // masked (round 18 #12)
|
||||||
pass_ctrl.set_min_size(150, -1);
|
pass_ctrl.set_min_size(150, -1);
|
||||||
pass_ctrl.set_value(&pass);
|
pass_ctrl.set_value(&pass);
|
||||||
row.add(pass_ctrl, 1, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
row.add(pass_ctrl, 1, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
||||||
@@ -2985,24 +3075,28 @@ impl App {
|
|||||||
|
|
||||||
/// Called every second by the scan timer: drain scan messages, then run the
|
/// Called every second by the scan timer: drain scan messages, then run the
|
||||||
/// scan-loop scheduler (countdown to the next automatic rescan, or idle).
|
/// scan-loop scheduler (countdown to the next automatic rescan, or idle).
|
||||||
fn tick(&mut self) {
|
fn tick(&mut self) -> Option<Widget> {
|
||||||
self.drain_scan();
|
self.drain_scan();
|
||||||
self.drain_action();
|
self.drain_action();
|
||||||
self.drain_refresh();
|
self.drain_refresh();
|
||||||
self.drain_access_probe();
|
self.drain_access_probe();
|
||||||
self.drain_restore();
|
self.drain_restore();
|
||||||
|
// A completed background log fetch yields a viewer dialog to show; return
|
||||||
|
// it so `dispatch` presents it modally after the App borrow is released
|
||||||
|
// (round 18 #12).
|
||||||
|
let to_show = self.drain_logfetch();
|
||||||
// The drains above run every fast tick (smooth scan progress); the
|
// The drains above run every fast tick (smooth scan progress); the
|
||||||
// auto-rescan scheduler + idle status only need ~1 Hz, so run them once
|
// auto-rescan scheduler + idle status only need ~1 Hz, so run them once
|
||||||
// per second.
|
// per second.
|
||||||
self.tick_accum = self.tick_accum.wrapping_add(1);
|
self.tick_accum = self.tick_accum.wrapping_add(1);
|
||||||
if !self.tick_accum.is_multiple_of(TICKS_PER_SEC) {
|
if !self.tick_accum.is_multiple_of(TICKS_PER_SEC) {
|
||||||
return;
|
return to_show;
|
||||||
}
|
}
|
||||||
// The bottom-left status is for the scan only (round 15 #8): per-miner
|
// The bottom-left status is for the scan only (round 15 #8): per-miner
|
||||||
// operation progress lives in the Health column, so operations no longer
|
// operation progress lives in the Health column, so operations no longer
|
||||||
// hold or overwrite this line -- only an active scan does.
|
// hold or overwrite this line -- only an active scan does.
|
||||||
if self.scanning {
|
if self.scanning {
|
||||||
return; // status already shows scan progress
|
return to_show; // status already shows scan progress
|
||||||
}
|
}
|
||||||
if self.playing && self.auto_secs > 0 {
|
if self.playing && self.auto_secs > 0 {
|
||||||
if self.countdown > 1 {
|
if self.countdown > 1 {
|
||||||
@@ -3022,11 +3116,16 @@ impl App {
|
|||||||
if self.playing { "auto-rescan off" } else { "paused" }
|
if self.playing { "auto-rescan off" } else { "paused" }
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
to_show
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cancel any in-flight scan, then start a fresh one over `lines`. Signalling
|
/// Cancel any in-flight scan, then start a fresh one over `lines`. The old
|
||||||
/// the old scan to stop before replacing it prevents two scan threads (and
|
/// scan is signalled to stop and winds down cooperatively: it checks the flag
|
||||||
/// two tokio runtimes) probing the network at once.
|
/// per address, so a handful of already-in-flight probes may still complete
|
||||||
|
/// after the new scan starts (round 18 #12). We accept that brief, bounded
|
||||||
|
/// 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
|
||||||
|
/// live miners, so a momentary overlap is harmless.
|
||||||
fn begin_scan(&mut self, lines: Vec<String>) {
|
fn begin_scan(&mut self, lines: Vec<String>) {
|
||||||
// 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.
|
||||||
@@ -4081,7 +4180,7 @@ impl App {
|
|||||||
WxEventKind::SysColour => self.repaint_theme(),
|
WxEventKind::SysColour => self.repaint_theme(),
|
||||||
WxEventKind::Sized => self.on_resize(ev.p1 as i32),
|
WxEventKind::Sized => self.on_resize(ev.p1 as i32),
|
||||||
WxEventKind::Deferred => self.on_deferred(ev.p1 as i32),
|
WxEventKind::Deferred => self.on_deferred(ev.p1 as i32),
|
||||||
WxEventKind::TimerTick if ev.p1 as i32 == TIMER_SCAN => self.tick(),
|
WxEventKind::TimerTick if ev.p1 as i32 == TIMER_SCAN => return self.tick(),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# cargo-deny configuration (https://embarkstudios.github.io/cargo-deny/).
|
||||||
|
#
|
||||||
|
# Run locally with `cargo deny check`. CI's security gate is cargo-audit (lighter,
|
||||||
|
# already wired); this file documents the dependency policy and lets anyone run a
|
||||||
|
# fuller license/advisory/source check. The whole dependency set is vendored under
|
||||||
|
# ./vendor and resolved offline (see .cargo/config.toml).
|
||||||
|
|
||||||
|
[advisories]
|
||||||
|
version = 2
|
||||||
|
# Accepted, documented advisories (build-time-only reqwest 0.11 subtree of the
|
||||||
|
# wx-rs build script -- never linked into the runtime binary). Mirrors
|
||||||
|
# .cargo/audit.toml; re-review when the vendored dependency set is refreshed.
|
||||||
|
ignore = [
|
||||||
|
"RUSTSEC-2026-0258", # h2 0.3 DATA-frame DoS (build-time HTTP client only)
|
||||||
|
"RUSTSEC-2025-0134", # rustls-pemfile 1.0.4 unmaintained (same subtree)
|
||||||
|
]
|
||||||
|
|
||||||
|
[licenses]
|
||||||
|
version = 2
|
||||||
|
# The project is MIT OR Apache-2.0; only permissive licenses are allowed in the
|
||||||
|
# dependency tree.
|
||||||
|
allow = [
|
||||||
|
"MIT",
|
||||||
|
"Apache-2.0",
|
||||||
|
"Apache-2.0 WITH LLVM-exception",
|
||||||
|
"BSD-2-Clause",
|
||||||
|
"BSD-3-Clause",
|
||||||
|
"ISC",
|
||||||
|
"Zlib",
|
||||||
|
"Unicode-3.0",
|
||||||
|
"Unicode-DFS-2016",
|
||||||
|
"MPL-2.0",
|
||||||
|
"CC0-1.0",
|
||||||
|
]
|
||||||
|
confidence-threshold = 0.9
|
||||||
|
|
||||||
|
[bans]
|
||||||
|
multiple-versions = "warn"
|
||||||
|
wildcards = "allow"
|
||||||
|
|
||||||
|
[sources]
|
||||||
|
unknown-registry = "warn"
|
||||||
|
unknown-git = "warn"
|
||||||
@@ -39,6 +39,11 @@ version = "1.0"
|
|||||||
[build-dependencies.embed-resource]
|
[build-dependencies.embed-resource]
|
||||||
version = "1.3"
|
version = "1.3"
|
||||||
|
|
||||||
|
# reqwest is only used by build.rs to download the wxWidgets source on
|
||||||
|
# Windows/macOS; on Linux download_dist() returns before touching it, and it is
|
||||||
|
# never linked into the runtime binary. Kept at the vendored 0.11 (the build tree
|
||||||
|
# is fully vendored / offline); the h2 0.3 advisory it pulls is build-time only
|
||||||
|
# and is documented as accepted in audit.toml (RUSTSEC-2026-0258).
|
||||||
[build-dependencies.reqwest]
|
[build-dependencies.reqwest]
|
||||||
version = "0.11"
|
version = "0.11"
|
||||||
features = ["blocking"]
|
features = ["blocking"]
|
||||||
|
|||||||
@@ -776,6 +776,13 @@ void* wxbr_text_ctrl(void* parent, int multiline) {
|
|||||||
wxDefaultPosition, wxSize(-1, -1), style);
|
wxDefaultPosition, wxSize(-1, -1), style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A single-line text control that masks its content (wxTE_PASSWORD), for secret
|
||||||
|
// entry so a saved password is never rendered in the clear (round 18 #12).
|
||||||
|
void* wxbr_text_ctrl_password(void* parent) {
|
||||||
|
return (void*)new wxTextCtrl((wxWindow*)parent, wxID_ANY, wxT(""),
|
||||||
|
wxDefaultPosition, wxSize(-1, -1), wxTE_PASSWORD);
|
||||||
|
}
|
||||||
|
|
||||||
int wxbr_text_ctrl_get(void* win, char* buf, int cap) {
|
int wxbr_text_ctrl_get(void* win, char* buf, int cap) {
|
||||||
wxTextCtrl* t = (wxTextCtrl*)win;
|
wxTextCtrl* t = (wxTextCtrl*)win;
|
||||||
wxString v = t->GetValue();
|
wxString v = t->GetValue();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ mod notsafe {
|
|||||||
pub fn wxbr_button(parent: *mut c_void, label: *const c_char, id: c_int) -> *mut c_void;
|
pub fn wxbr_button(parent: *mut c_void, label: *const c_char, id: c_int) -> *mut c_void;
|
||||||
pub fn wxbr_bind_click(win: *mut c_void, id: c_int);
|
pub fn wxbr_bind_click(win: *mut c_void, id: c_int);
|
||||||
pub fn wxbr_text_ctrl(parent: *mut c_void, multiline: c_int) -> *mut c_void;
|
pub fn wxbr_text_ctrl(parent: *mut c_void, multiline: c_int) -> *mut c_void;
|
||||||
|
pub fn wxbr_text_ctrl_password(parent: *mut c_void) -> *mut c_void;
|
||||||
pub fn wxbr_text_ctrl_get(win: *mut c_void, buf: *mut c_char, cap: c_int) -> c_int;
|
pub fn wxbr_text_ctrl_get(win: *mut c_void, buf: *mut c_char, cap: c_int) -> c_int;
|
||||||
pub fn wxbr_text_ctrl_set(win: *mut c_void, value: *const c_char);
|
pub fn wxbr_text_ctrl_set(win: *mut c_void, value: *const c_char);
|
||||||
pub fn wxbr_text_ctrl_write(win: *mut c_void, value: *const c_char);
|
pub fn wxbr_text_ctrl_write(win: *mut c_void, value: *const c_char);
|
||||||
@@ -438,6 +439,11 @@ impl Widget {
|
|||||||
Widget(unsafe { notsafe::wxbr_text_ctrl(parent.0, multiline as c_int) })
|
Widget(unsafe { notsafe::wxbr_text_ctrl(parent.0, multiline as c_int) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A single-line text control that masks its content (for password entry).
|
||||||
|
pub fn password_ctrl(parent: Widget) -> Widget {
|
||||||
|
Widget(unsafe { notsafe::wxbr_text_ctrl_password(parent.0) })
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_value(&self) -> String {
|
pub fn get_value(&self) -> String {
|
||||||
let mut buf = vec![0i8; 65536];
|
let mut buf = vec![0i8; 65536];
|
||||||
let n = unsafe { notsafe::wxbr_text_ctrl_get(self.0, buf.as_mut_ptr(), buf.len() as c_int) };
|
let n = unsafe { notsafe::wxbr_text_ctrl_get(self.0, buf.as_mut_ptr(), buf.len() as c_int) };
|
||||||
|
|||||||