Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4154a50ed0 | ||
|
|
0ab822940e | ||
|
|
c1aa6db834 | ||
|
|
7feab6117b | ||
|
|
808fd4de1d | ||
|
|
63ada5bb99 | ||
|
|
52b7c3f2a1 | ||
|
|
571c2305aa | ||
|
|
79ecc100d3 | ||
|
|
51b4eb2556 | ||
|
|
3b18219e4e |
@@ -11,6 +11,9 @@ jobs:
|
|||||||
runs-on: alkane-ci
|
runs-on: alkane-ci
|
||||||
env:
|
env:
|
||||||
WX_PREFIX: /root/.cache/wx-3.3.3-linux
|
WX_PREFIX: /root/.cache/wx-3.3.3-linux
|
||||||
|
# Set once for the whole job so build/clippy/test/bench steps don't each
|
||||||
|
# re-export it (round 18 #12).
|
||||||
|
WX_RS_WXCONFIG: /root/.cache/wx-3.3.3-linux/bin/wx-config
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout (full history for tags)
|
- name: Checkout (full history for tags)
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -52,7 +55,6 @@ jobs:
|
|||||||
- name: Clippy (our crate, warnings are errors)
|
- name: Clippy (our crate, warnings are errors)
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
rustup component add clippy >/dev/null 2>&1 || true
|
rustup component add clippy >/dev/null 2>&1 || true
|
||||||
cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
|
cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
|
||||||
|
|
||||||
@@ -65,19 +67,16 @@ jobs:
|
|||||||
- name: Build release
|
- name: Build release
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
cargo build --release -p alkane-gui --offline
|
cargo build --release -p alkane-gui --offline
|
||||||
|
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
cargo test -p alkane-gui --offline
|
cargo test -p alkane-gui --offline
|
||||||
|
|
||||||
- name: Microbenchmarks
|
- name: Microbenchmarks
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
cargo test -p alkane-gui --release --offline -- --ignored --nocapture bench_
|
cargo test -p alkane-gui --release --offline -- --ignored --nocapture bench_
|
||||||
|
|
||||||
- name: Headless UI self-test
|
- name: Headless UI self-test
|
||||||
@@ -98,6 +97,40 @@ jobs:
|
|||||||
echo "cargo-audit not installed on this runner; skipping"
|
echo "cargo-audit not installed on this runner; skipping"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Merge coverage from the unit tests AND the headless self-test (ci/coverage.sh)
|
||||||
|
# so the committed badge reflects real coverage, not the tests-only number a
|
||||||
|
# plain `cargo llvm-cov` reports. Best-effort: cargo-llvm-cov is fetched as a
|
||||||
|
# prebuilt binary because the vendored .cargo/config blocks `cargo install`,
|
||||||
|
# and the instrumented rebuild is slow, so a failure here never blocks a
|
||||||
|
# release. Feeds steps.cov.outputs.pct to the badge refresh below. xvfb is
|
||||||
|
# already installed by the self-test step above.
|
||||||
|
- name: Coverage (best-effort)
|
||||||
|
id: cov
|
||||||
|
if: steps.ver.outputs.release == 'true'
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
rustup component add llvm-tools-preview >/dev/null 2>&1 || true
|
||||||
|
if ! command -v cargo-llvm-cov >/dev/null 2>&1; then
|
||||||
|
V=0.8.7
|
||||||
|
URL="https://github.com/taiki-e/cargo-llvm-cov/releases/download/v${V}/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz"
|
||||||
|
DEST="${CARGO_HOME:-$HOME/.cargo}/bin"
|
||||||
|
mkdir -p "$DEST"
|
||||||
|
curl -fsSL "$URL" | tar -xz -C "$DEST" && export PATH="$DEST:$PATH" \
|
||||||
|
|| echo "cargo-llvm-cov download failed"
|
||||||
|
fi
|
||||||
|
if command -v cargo-llvm-cov >/dev/null 2>&1; then
|
||||||
|
PCT=$(bash ci/coverage.sh --summary-only 2>/dev/null \
|
||||||
|
| awk '/^TOTAL/{gsub(/%/,"",$10); print $10}')
|
||||||
|
if [ -n "$PCT" ]; then
|
||||||
|
echo "pct=${PCT}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "line coverage (tests + self-test): ${PCT}%"
|
||||||
|
else
|
||||||
|
echo "coverage report produced no TOTAL line; badge left as committed"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "cargo-llvm-cov unavailable; coverage badge left as committed"
|
||||||
|
fi
|
||||||
|
|
||||||
# Refresh the committed README badges from live metrics and push any change
|
# 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
|
# 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
|
# fail the release. A badges-only push does not bump the version (see
|
||||||
@@ -108,10 +141,14 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
|
|
||||||
PASS=$(cargo test -p alkane-gui --offline 2>&1 \
|
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}')
|
| 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"
|
# Update the coverage badge only when the coverage step produced a number;
|
||||||
|
# otherwise leave the committed coverage.svg untouched.
|
||||||
|
COV="${{ steps.cov.outputs.pct }}"
|
||||||
|
COV_ARG=""
|
||||||
|
[ -n "$COV" ] && COV_ARG="--coverage $COV"
|
||||||
|
python3 ci/gen-badges.py --tests "${PASS:-0}" $COV_ARG --bench "row-render + scan-parse"
|
||||||
if [ -n "$(git status --porcelain badges)" ]; then
|
if [ -n "$(git status --porcelain badges)" ]; then
|
||||||
git config user.name "alkane-ci"
|
git config user.name "alkane-ci"
|
||||||
git config user.email "ci@bluefla.re"
|
git config user.email "ci@bluefla.re"
|
||||||
|
|||||||
@@ -13,9 +13,21 @@ members = [
|
|||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
|
|
||||||
|
# Release binary: small, self-contained, and fast enough for a fleet GUI whose
|
||||||
|
# hot path is network I/O, not CPU (round 18 #12). opt-level "s" + fat LTO +
|
||||||
|
# one codegen unit + symbol stripping cut the binary substantially. panic stays
|
||||||
|
# "unwind" on purpose: the scan runs many miners on tokio tasks and the wx event
|
||||||
|
# dispatch relies on unwinding so one miner's panic never aborts the whole app.
|
||||||
|
[profile.release]
|
||||||
|
opt-level = "s"
|
||||||
|
lto = "fat"
|
||||||
|
codegen-units = 1
|
||||||
|
strip = true
|
||||||
|
|
||||||
|
|||||||
@@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but not
|
|
||||||
limited to compiled object code, generated documentation, and
|
|
||||||
conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or Derivative
|
|
||||||
Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and do
|
|
||||||
not modify the License. You may add Your own attribution notices
|
|
||||||
within Derivative Works that You distribute, alongside or as an
|
|
||||||
addendum to the NOTICE text from the Work, provided that such
|
|
||||||
additional attribution notices cannot be construed as modifying
|
|
||||||
the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright 2026 Blueflare
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
@@ -79,6 +79,7 @@ cargo test -p alkane-gui --release -- --ignored bench_ # microbenchmarks
|
|||||||
cargo clippy -p alkane-gui --no-deps --bins -- -D warnings # lint gate
|
cargo clippy -p alkane-gui --no-deps --bins -- -D warnings # lint gate
|
||||||
xvfb-run -a env ALKANE_SELFTEST=1 \
|
xvfb-run -a env ALKANE_SELFTEST=1 \
|
||||||
"$CARGO_TARGET_DIR/release/alkane-toolkit" # headless UI self-test
|
"$CARGO_TARGET_DIR/release/alkane-toolkit" # headless UI self-test
|
||||||
|
ci/coverage.sh --summary-only # coverage (tests + self-test)
|
||||||
```
|
```
|
||||||
|
|
||||||
CI mirrors these: `verify.yml` runs the lint, tests, benchmarks, self-test, and
|
CI mirrors these: `verify.yml` runs the lint, tests, benchmarks, self-test, and
|
||||||
@@ -112,5 +113,4 @@ Encoded in code, from alkane-sdk `docs/install-methods.md`:
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Dual-licensed under either of [Apache-2.0](LICENSE-APACHE) or
|
Licensed under the [MIT license](LICENSE).
|
||||||
[MIT](LICENSE-MIT) at your option.
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="95.5" height="20" role="img" aria-label="coverage: 36%">
|
<svg xmlns="http://www.w3.org/2000/svg" width="95.5" height="20" role="img" aria-label="coverage: 46%">
|
||||||
<title>coverage: 36%</title>
|
<title>coverage: 46%</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
@@ -7,13 +7,13 @@
|
|||||||
<clipPath id="r"><rect width="95.5" height="20" rx="3" fill="#fff"/></clipPath>
|
<clipPath id="r"><rect width="95.5" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
<g clip-path="url(#r)">
|
<g clip-path="url(#r)">
|
||||||
<rect width="64.0" height="20" fill="#555"/>
|
<rect width="64.0" height="20" fill="#555"/>
|
||||||
<rect x="64.0" width="31.5" height="20" fill="#fe7d37"/>
|
<rect x="64.0" width="31.5" height="20" fill="#dfb317"/>
|
||||||
<rect width="95.5" height="20" fill="url(#s)"/>
|
<rect width="95.5" height="20" fill="url(#s)"/>
|
||||||
</g>
|
</g>
|
||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<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="15" fill="#010101" fill-opacity=".3">coverage</text>
|
||||||
<text x="32.0" y="14">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="15" fill="#010101" fill-opacity=".3">46%</text>
|
||||||
<text x="79.8" y="14">36%</text>
|
<text x="79.8" y="14">46%</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 919 B After Width: | Height: | Size: 919 B |
@@ -1,19 +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">
|
<svg xmlns="http://www.w3.org/2000/svg" width="89.0" height="20" role="img" aria-label="license: MIT">
|
||||||
<title>license: MIT OR Apache-2.0</title>
|
<title>license: MIT</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
<clipPath id="r"><rect width="180.0" height="20" rx="3" fill="#fff"/></clipPath>
|
<clipPath id="r"><rect width="89.0" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
<g clip-path="url(#r)">
|
<g clip-path="url(#r)">
|
||||||
<rect width="57.5" height="20" fill="#555"/>
|
<rect width="57.5" height="20" fill="#555"/>
|
||||||
<rect x="57.5" width="122.5" height="20" fill="#007ec6"/>
|
<rect x="57.5" width="31.5" height="20" fill="#007ec6"/>
|
||||||
<rect width="180.0" height="20" fill="url(#s)"/>
|
<rect width="89.0" height="20" fill="url(#s)"/>
|
||||||
</g>
|
</g>
|
||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<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="15" fill="#010101" fill-opacity=".3">license</text>
|
||||||
<text x="28.8" y="14">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="73.2" y="15" fill="#010101" fill-opacity=".3">MIT</text>
|
||||||
<text x="118.8" y="14">MIT OR Apache-2.0</text>
|
<text x="73.2" y="14">MIT</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 977 B After Width: | Height: | Size: 915 B |
@@ -1,5 +1,5 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="141.0" height="20" role="img" aria-label="lines of code: 12.5k">
|
<svg xmlns="http://www.w3.org/2000/svg" width="141.0" height="20" role="img" aria-label="lines of code: 13.2k">
|
||||||
<title>lines of code: 12.5k</title>
|
<title>lines of code: 13.2k</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<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="15" fill="#010101" fill-opacity=".3">lines of code</text>
|
||||||
<text x="48.2" y="14">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="15" fill="#010101" fill-opacity=".3">13.2k</text>
|
||||||
<text x="118.8" y="14">12.5k</text>
|
<text x="118.8" y="14">13.2k</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 952 B After Width: | Height: | Size: 952 B |
@@ -1,5 +1,5 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="121.5" height="20" role="img" aria-label="tests: 94 passing">
|
<svg xmlns="http://www.w3.org/2000/svg" width="121.5" height="20" role="img" aria-label="tests: 99 passing">
|
||||||
<title>tests: 94 passing</title>
|
<title>tests: 99 passing</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<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="15" fill="#010101" fill-opacity=".3">tests</text>
|
||||||
<text x="22.2" y="14">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="15" fill="#010101" fill-opacity=".3">99 passing</text>
|
||||||
<text x="83.0" y="14">94 passing</text>
|
<text x="83.0" y="14">99 passing</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 935 B After Width: | Height: | Size: 935 B |
@@ -2,9 +2,10 @@
|
|||||||
# Compute the next release version for alkane-toolkit from the latest release
|
# Compute the next release version for alkane-toolkit from the latest release
|
||||||
# tag and the paths changed since it. Version scheme X.Y.Z:
|
# tag and the paths changed since it. Version scheme X.Y.Z:
|
||||||
# X - major, bumped manually (ci/version-x.txt); a bump resets Y.Z to 0.0
|
# X - major, bumped manually (ci/version-x.txt); a bump resets Y.Z to 0.0
|
||||||
# Y - backend-logic changes (core/discovery/access/flash/artifacts/cli,
|
# Y - backend-logic changes (the alkane-* crates and any GUI crate source
|
||||||
# scan+model+main in the GUI crate, build/CI config); resets Z to 0
|
# other than the view files below, plus vendored deps and build/CI config);
|
||||||
# Z - UI changes (the GUI view + fixtures + the wx-rs widget bridge)
|
# resets Z to 0
|
||||||
|
# Z - UI changes (the GUI view: ui.rs + fixtures.rs + bin/ + the wx-rs bridge)
|
||||||
# When both backend and UI changed, backend wins (bump Y). Docs-only changes
|
# When both backend and UI changed, backend wins (bump Y). Docs-only changes
|
||||||
# produce no release.
|
# produce no release.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Measure line coverage from BOTH the unit tests AND the headless UI self-test.
|
||||||
|
#
|
||||||
|
# The self-test (ALKANE_SELFTEST=1) builds the real wxWidgets table, renders every
|
||||||
|
# fixture through the real widgets, and checks each cell against the model -- it
|
||||||
|
# exercises most of ui.rs. Because it runs as a separate binary invocation, a plain
|
||||||
|
# `cargo llvm-cov` (which only runs the #[test]s) never counts it, so ui.rs shows
|
||||||
|
# ~4% even though it is integration-tested. This combines both runs' coverage.
|
||||||
|
#
|
||||||
|
# Usage: ci/coverage.sh [extra `cargo llvm-cov report` args, e.g. --summary-only]
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export WX_RS_WXCONFIG="${WX_RS_WXCONFIG:-$HOME/.cache/wx-3.3.3-linux/bin/wx-config}"
|
||||||
|
|
||||||
|
# The dependency tree is fully vendored, so the instrumented builds run offline by
|
||||||
|
# default; override with CARGO_LLVM_COV_FLAGS if you need something else.
|
||||||
|
read -ra CARGO_FLAGS <<<"${CARGO_LLVM_COV_FLAGS:---offline}"
|
||||||
|
|
||||||
|
# A display for the self-test's real widgets.
|
||||||
|
need_xvfb() { command -v xvfb-run >/dev/null 2>&1; }
|
||||||
|
|
||||||
|
cargo llvm-cov clean --workspace
|
||||||
|
|
||||||
|
# 1. Unit tests.
|
||||||
|
cargo llvm-cov --no-report "${CARGO_FLAGS[@]}" -p alkane-gui --bin alkane-toolkit
|
||||||
|
|
||||||
|
# 2. Headless UI self-test, under the same instrumentation, its coverage appended.
|
||||||
|
if need_xvfb; then
|
||||||
|
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 \
|
||||||
|
cargo llvm-cov run --no-report "${CARGO_FLAGS[@]}" --bin alkane-toolkit
|
||||||
|
else
|
||||||
|
echo "coverage.sh: xvfb-run not found; skipping the self-test run (unit tests only)" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Merged report, our source only (vendored asic-rs + the patched wx-rs bridge
|
||||||
|
# are out of scope).
|
||||||
|
cargo llvm-cov report --ignore-filename-regex '(thirdparty|vendor)/' "$@"
|
||||||
@@ -61,10 +61,22 @@ fn endpoint(_firmware: &str) -> &'static str {
|
|||||||
/// could not run at all.
|
/// could not run at all.
|
||||||
pub fn probe_access(ip: &str, make: &str, user: &str, pass: &str) -> Result<Option<bool>, String> {
|
pub fn probe_access(ip: &str, make: &str, user: &str, pass: &str) -> Result<Option<bool>, String> {
|
||||||
if make.eq_ignore_ascii_case("whatsminer") {
|
if make.eq_ignore_ascii_case("whatsminer") {
|
||||||
return Ok(probe_whatsminer_access(ip, &whatsminer_password_candidates()));
|
// Try the caller's saved scan password first (round 18 #12: it was being
|
||||||
|
// ignored for WhatsMiner, so a miner opened with the operator's real
|
||||||
|
// password was mis-reported as locked), then the per-firmware override and
|
||||||
|
// factory defaults. All attempts are non-mutating.
|
||||||
|
let mut candidates = Vec::new();
|
||||||
|
if !pass.is_empty() {
|
||||||
|
candidates.push(pass.to_string());
|
||||||
|
}
|
||||||
|
for c in whatsminer_password_candidates() {
|
||||||
|
if !candidates.contains(&c) {
|
||||||
|
candidates.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Ok(probe_whatsminer_access(ip, &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 +85,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 +104,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 +140,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 +149,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.
|
||||||
@@ -205,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.
|
||||||
@@ -239,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)]
|
||||||
|
|||||||
@@ -39,12 +39,17 @@ fn load_creds() -> Option<(String, String)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn factory() -> MinerFactory {
|
fn factory() -> MinerFactory {
|
||||||
|
// This diagnostic CLI is a separate binary from the GUI, so it cannot share
|
||||||
|
// the GUI's credentials::configured_factory. It applies only the global scan
|
||||||
|
// credentials to every firmware; the GUI's per-firmware credential overrides
|
||||||
|
// are NOT read here (round 18 #12), which the message below makes explicit so a
|
||||||
|
// probe result is never mistaken for what the GUI (with overrides) would see.
|
||||||
let mut f = MinerFactory::new();
|
let mut f = MinerFactory::new();
|
||||||
if let Some((u, pw)) = load_creds() {
|
if let Some((u, pw)) = load_creds() {
|
||||||
for fw in asic_rs::factory::default_firmware_registry() {
|
for fw in asic_rs::factory::default_firmware_registry() {
|
||||||
f = f.with_firmware_discovery_auth(fw.as_ref(), MinerAuth::new(u.clone(), pw.clone()));
|
f = f.with_firmware_discovery_auth(fw.as_ref(), MinerAuth::new(u.clone(), pw.clone()));
|
||||||
}
|
}
|
||||||
eprintln!("(using saved scan credentials for discovery auth)");
|
eprintln!("(using the global scan credentials; per-firmware overrides are not applied)");
|
||||||
} else {
|
} else {
|
||||||
eprintln!("(no saved credentials -- backends use their default auth)");
|
eprintln!("(no saved credentials -- backends use their default auth)");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() {
|
||||||
@@ -216,8 +221,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn credentials_round_trip_and_file_perms() {
|
fn credentials_round_trip_and_file_perms() {
|
||||||
// config_path() reads $HOME; point it at a private temp dir. HOME is
|
// config_path() reads $HOME; point it at a private temp dir. HOME is
|
||||||
// process-global, so this stays one test and restores HOME afterward
|
// process-global, so serialise against other HOME-mutating tests via the
|
||||||
// (matching the pattern used by scan::tests::auto_secs_round_trip_and_defaults).
|
// shared lock and restore HOME afterward (round 18 #12).
|
||||||
|
let _home = crate::model::HOME_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
let prev = std::env::var_os("HOME");
|
let prev = std::env::var_os("HOME");
|
||||||
let dir = std::env::temp_dir().join(format!("alkane-cred-test-{}", std::process::id()));
|
let dir = std::env::temp_dir().join(format!("alkane-cred-test-{}", std::process::id()));
|
||||||
let _ = std::fs::remove_dir_all(&dir);
|
let _ = std::fs::remove_dir_all(&dir);
|
||||||
|
|||||||
@@ -9,13 +9,21 @@
|
|||||||
|
|
||||||
use crate::model::{BoardHealth, MinerRow};
|
use crate::model::{BoardHealth, MinerRow};
|
||||||
|
|
||||||
/// Escape one CSV field: quote it when it contains a comma, quote, CR or LF, and
|
/// Escape one CSV field: neutralise spreadsheet formula injection, then quote it
|
||||||
/// double any embedded quotes.
|
/// when it contains a comma, quote, CR or LF (doubling any embedded quotes).
|
||||||
|
///
|
||||||
|
/// Miner-supplied fields (hostname, worker, serial, ...) can start with a formula
|
||||||
|
/// trigger; prefixing a single quote makes Excel/Sheets treat the cell as text so
|
||||||
|
/// opening the export can't execute an injected formula (round 18 #12).
|
||||||
fn esc(s: &str) -> String {
|
fn esc(s: &str) -> String {
|
||||||
if s.contains([',', '"', '\n', '\r']) {
|
let mut val = s.to_string();
|
||||||
format!("\"{}\"", s.replace('"', "\"\""))
|
if val.starts_with(['=', '+', '-', '@', '\t', '\r']) {
|
||||||
|
val.insert(0, '\'');
|
||||||
|
}
|
||||||
|
if val.contains([',', '"', '\n', '\r']) {
|
||||||
|
format!("\"{}\"", val.replace('"', "\"\""))
|
||||||
} else {
|
} else {
|
||||||
s.to_string()
|
val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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()),
|
||||||
|
|||||||
@@ -61,8 +61,14 @@ fn tail(s: &str, max: usize) -> String {
|
|||||||
if s.len() <= max {
|
if s.len() <= max {
|
||||||
return s.to_string();
|
return s.to_string();
|
||||||
}
|
}
|
||||||
let start = s.len() - max;
|
// Nudge the cut forward to a UTF-8 char boundary first: a raw byte offset can
|
||||||
// advance to the next line boundary so we don't cut a line in half
|
// land inside a multi-byte character and slicing there would panic (round 18
|
||||||
|
// #12; miner logs are not guaranteed pure ASCII).
|
||||||
|
let mut start = s.len() - max;
|
||||||
|
while start < s.len() && !s.is_char_boundary(start) {
|
||||||
|
start += 1;
|
||||||
|
}
|
||||||
|
// then advance to the next line boundary so we don't cut a line in half
|
||||||
let start = s[start..]
|
let start = s[start..]
|
||||||
.find('\n')
|
.find('\n')
|
||||||
.map(|i| start + i + 1)
|
.map(|i| start + i + 1)
|
||||||
@@ -122,35 +128,45 @@ fn summarize_log(log: &str) -> Vec<String> {
|
|||||||
|
|
||||||
/// VNish: unlock -> bearer -> the full miner log.
|
/// VNish: unlock -> bearer -> the full miner log.
|
||||||
fn fetch_vnish_log(ip: &str, pass: &str) -> Result<String, String> {
|
fn fetch_vnish_log(ip: &str, pass: &str) -> Result<String, String> {
|
||||||
let unlock = curl(&[
|
// The password goes in the POST body read from stdin (-d @-), never on argv,
|
||||||
"-s",
|
// and is JSON-encoded by serde so it is both un-leakable and correctly escaped
|
||||||
"--connect-timeout",
|
// (round 18 #12).
|
||||||
"5",
|
let body = serde_json::json!({ "pw": pass }).to_string();
|
||||||
"--max-time",
|
let unlock = curl(
|
||||||
"9",
|
&[
|
||||||
"-X",
|
"-s",
|
||||||
"POST",
|
"--connect-timeout",
|
||||||
"-H",
|
"5",
|
||||||
"Content-Type: application/json",
|
"--max-time",
|
||||||
"-d",
|
"9",
|
||||||
&format!("{{\"pw\":\"{pass}\"}}"),
|
"-X",
|
||||||
&format!("http://{ip}/api/v1/unlock"),
|
"POST",
|
||||||
])?;
|
"-H",
|
||||||
|
"Content-Type: application/json",
|
||||||
|
"-d",
|
||||||
|
"@-",
|
||||||
|
&format!("http://{ip}/api/v1/unlock"),
|
||||||
|
],
|
||||||
|
Some(body.as_bytes()),
|
||||||
|
)?;
|
||||||
let token = serde_json::from_str::<serde_json::Value>(&unlock)
|
let token = serde_json::from_str::<serde_json::Value>(&unlock)
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|v| v.get("token").and_then(|t| t.as_str()).map(str::to_string))
|
.and_then(|v| v.get("token").and_then(|t| t.as_str()).map(str::to_string))
|
||||||
.filter(|t| !t.is_empty())
|
.filter(|t| !t.is_empty())
|
||||||
.ok_or_else(|| "VNish unlock rejected (check the VNish password in scan credentials)".to_string())?;
|
.ok_or_else(|| "VNish unlock rejected (check the VNish password in scan credentials)".to_string())?;
|
||||||
let log = curl(&[
|
let log = curl(
|
||||||
"-s",
|
&[
|
||||||
"--connect-timeout",
|
"-s",
|
||||||
"5",
|
"--connect-timeout",
|
||||||
"--max-time",
|
"5",
|
||||||
"12",
|
"--max-time",
|
||||||
"-H",
|
"12",
|
||||||
&format!("Authorization: Bearer {token}"),
|
"-H",
|
||||||
&format!("http://{ip}/api/v1/logs/miner"),
|
&format!("Authorization: Bearer {token}"),
|
||||||
])?;
|
&format!("http://{ip}/api/v1/logs/miner"),
|
||||||
|
],
|
||||||
|
None,
|
||||||
|
)?;
|
||||||
if log.trim().is_empty() {
|
if log.trim().is_empty() {
|
||||||
return Err("VNish returned an empty log".to_string());
|
return Err("VNish returned an empty log".to_string());
|
||||||
}
|
}
|
||||||
@@ -159,17 +175,23 @@ fn fetch_vnish_log(ip: &str, pass: &str) -> Result<String, String> {
|
|||||||
|
|
||||||
/// Stock Antminer web log (digest auth). Absent on older models (404).
|
/// Stock Antminer web log (digest auth). Absent on older models (404).
|
||||||
fn fetch_antminer_log(ip: &str, user: &str, pass: &str) -> Result<String, String> {
|
fn fetch_antminer_log(ip: &str, user: &str, pass: &str) -> Result<String, String> {
|
||||||
let body = curl(&[
|
// Credentials go through a curl config on stdin (-K -), never on argv, so they
|
||||||
"-s",
|
// can't be read from the process list (round 18 #12).
|
||||||
"--digest",
|
let config = format!("user = \"{}\"\n", curl_config_quote(&format!("{user}:{pass}")));
|
||||||
"-u",
|
let body = curl(
|
||||||
&format!("{user}:{pass}"),
|
&[
|
||||||
"--connect-timeout",
|
"-s",
|
||||||
"5",
|
"--digest",
|
||||||
"--max-time",
|
"--connect-timeout",
|
||||||
"12",
|
"5",
|
||||||
&format!("http://{ip}/cgi-bin/log.cgi"),
|
"--max-time",
|
||||||
])?;
|
"12",
|
||||||
|
"-K",
|
||||||
|
"-",
|
||||||
|
&format!("http://{ip}/cgi-bin/log.cgi"),
|
||||||
|
],
|
||||||
|
Some(config.as_bytes()),
|
||||||
|
)?;
|
||||||
if body.contains("404 - Not Found") || body.trim().is_empty() {
|
if body.contains("404 - Not Found") || body.trim().is_empty() {
|
||||||
return Err("this firmware does not expose a log over its web API".to_string());
|
return Err("this firmware does not expose a log over its web API".to_string());
|
||||||
}
|
}
|
||||||
@@ -186,17 +208,29 @@ fn fetch_whatsminer_errors(ip: &str) -> Result<String, String> {
|
|||||||
/// Run curl and return stdout, with a hard wall-clock cap. stdout is drained on a
|
/// Run curl and return stdout, with a hard wall-clock cap. stdout is drained on a
|
||||||
/// separate thread so a large log (hundreds of KB) never deadlocks on a full pipe
|
/// separate thread so a large log (hundreds of KB) never deadlocks on a full pipe
|
||||||
/// -- the reason a naive "wait then read" times out on the VNish log.
|
/// -- the reason a naive "wait then read" times out on the VNish log.
|
||||||
fn curl(args: &[&str]) -> Result<String, String> {
|
fn curl(args: &[&str], stdin_data: Option<&[u8]>) -> Result<String, String> {
|
||||||
use std::io::Read;
|
use std::io::{Read, Write};
|
||||||
let mut cmd = Command::new("curl");
|
let mut cmd = Command::new("curl");
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
cmd.stdout(std::process::Stdio::piped());
|
cmd.stdout(std::process::Stdio::piped());
|
||||||
cmd.stderr(std::process::Stdio::null());
|
cmd.stderr(std::process::Stdio::null());
|
||||||
|
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}"))?;
|
||||||
let mut stdout = child.stdout.take().ok_or("no curl stdout")?;
|
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/body
|
||||||
|
}
|
||||||
|
let stdout = child.stdout.take().ok_or("no curl stdout")?;
|
||||||
let reader = std::thread::spawn(move || {
|
let reader = std::thread::spawn(move || {
|
||||||
|
// Bound the buffer: a miner-controlled response must not exhaust memory
|
||||||
|
// (round 18 #12). The viewer only keeps the last MAX_LOG_BYTES anyway, so
|
||||||
|
// read a small multiple of that and drop the rest.
|
||||||
|
const READ_CAP: u64 = (MAX_LOG_BYTES as u64) * 8; // 2 MiB
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let _ = stdout.read_to_end(&mut buf);
|
let _ = stdout.take(READ_CAP).read_to_end(&mut buf);
|
||||||
buf
|
buf
|
||||||
});
|
});
|
||||||
let timeout = Duration::from_secs(20);
|
let timeout = Duration::from_secs(20);
|
||||||
@@ -208,6 +242,7 @@ fn curl(args: &[&str]) -> Result<String, String> {
|
|||||||
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)
|
||||||
timed_out = true;
|
timed_out = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -222,10 +257,25 @@ fn curl(args: &[&str]) -> Result<String, String> {
|
|||||||
Ok(String::from_utf8_lossy(&buf).into_owned())
|
Ok(String::from_utf8_lossy(&buf).into_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Escape a value for a curl `--config` file (double-quoted string).
|
||||||
|
fn curl_config_quote(s: &str) -> String {
|
||||||
|
s.replace('\\', "\\\\").replace('"', "\\\"")
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tail_does_not_panic_mid_multibyte_char() {
|
||||||
|
// A byte-offset cut can land inside a multi-byte character; tail must nudge
|
||||||
|
// to a char boundary rather than panic (round 18 #12).
|
||||||
|
let s = "\u{00e9}".repeat(200); // 400 bytes of 2-byte chars, no newlines
|
||||||
|
let out = tail(&s, 101); // cut at an odd offset -> inside a char
|
||||||
|
assert!(out.starts_with("[... earlier log trimmed ...]"));
|
||||||
|
assert!(out.len() < s.len());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn summarize_finds_pic_chains_and_errors() {
|
fn summarize_finds_pic_chains_and_errors() {
|
||||||
let log = "\
|
let log = "\
|
||||||
|
|||||||
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
|
/// Serialises tests that mutate the process-global `$HOME` (config paths read it),
|
||||||
|
/// so they never race each other under the parallel test harness (round 18 #12).
|
||||||
|
/// Lock it with `.lock().unwrap_or_else(|e| e.into_inner())` to shrug off a poison
|
||||||
|
/// from a panicking sibling test.
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) static HOME_TEST_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||||
|
|
||||||
/// A miner counts as "slow" when it is mining but running below this fraction
|
/// A miner counts as "slow" when it is mining but running below this fraction
|
||||||
/// of its model's expected hashrate (UI-SPEC "Slow" band). A missing expected
|
/// of its model's expected hashrate (UI-SPEC "Slow" band). A missing expected
|
||||||
/// hashrate (0.0) means the band is unknown, so the miner is never "slow".
|
/// hashrate (0.0) means the band is unknown, so the miner is never "slow".
|
||||||
@@ -682,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
|
||||||
}
|
}
|
||||||
@@ -1023,10 +1036,15 @@ pub enum Column {
|
|||||||
|
|
||||||
/// Every column, in registry order. Ip first, then the default-visible set
|
/// Every column, in registry order. Ip first, then the default-visible set
|
||||||
/// (UI-SPEC order), then all remaining metrics.
|
/// (UI-SPEC order), then all remaining metrics.
|
||||||
pub const ALL_COLUMNS: [Column; 46] = [
|
pub const ALL_COLUMNS: [Column; 47] = [
|
||||||
Column::Ip,
|
Column::Ip,
|
||||||
Column::Hashrate,
|
Column::Hashrate,
|
||||||
Column::Health,
|
Column::Health,
|
||||||
|
// The detailed per-board dot column (round 11 #10). Not in DEFAULT_VISIBLE
|
||||||
|
// (the Health column shows composite board health by default), but it belongs
|
||||||
|
// in ALL_COLUMNS so it is selectable in the column picker (round 18 #12: it
|
||||||
|
// was accidentally omitted, making the column unreachable).
|
||||||
|
Column::Hashboards,
|
||||||
Column::Power,
|
Column::Power,
|
||||||
Column::ChipTemp,
|
Column::ChipTemp,
|
||||||
Column::Cooling,
|
Column::Cooling,
|
||||||
@@ -1238,6 +1256,12 @@ impl Column {
|
|||||||
if !self.is_numeric() || self.cell(r).is_empty() {
|
if !self.is_numeric() || self.cell(r).is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
// The Boards column's sort_key is a composite (online*100 + total) tuned
|
||||||
|
// for sorting; a numeric filter must compare the actual detected board
|
||||||
|
// count the cell shows, not that score (round 18 #12).
|
||||||
|
if let Column::Hashboards = self {
|
||||||
|
return r.hashboards.map(|v| v as f64);
|
||||||
|
}
|
||||||
match self.sort_key(r) {
|
match self.sort_key(r) {
|
||||||
SortKey::Num(v) if v.is_finite() => Some(v),
|
SortKey::Num(v) if v.is_finite() => Some(v),
|
||||||
_ => None,
|
_ => None,
|
||||||
@@ -1342,7 +1366,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 +1609,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1858,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]
|
||||||
@@ -2337,6 +2396,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).
|
||||||
@@ -2597,6 +2681,21 @@ mod tests {
|
|||||||
assert_eq!(Column::TotalChips.num_value(&both), Some(190.0));
|
assert_eq!(Column::TotalChips.num_value(&both), Some(190.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hashboards_num_value_is_board_count_with_per_board_health() {
|
||||||
|
// With per-board health present (the normal live-scan case), the Boards
|
||||||
|
// filter must still compare the detected board count, not the composite
|
||||||
|
// sort score online*100+total (round 18 #12). The `both` fixture above
|
||||||
|
// leaves board_status empty, so it never exercised this path.
|
||||||
|
let r = MinerRow {
|
||||||
|
hashboards: Some(3),
|
||||||
|
expected_hashboards: Some(3),
|
||||||
|
board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Ok],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
assert_eq!(Column::Hashboards.num_value(&r), Some(3.0), "filter sees the board count, not 303");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cooling_column_joins_fan_rpms_and_sorts_by_min() {
|
fn cooling_column_joins_fan_rpms_and_sorts_by_min() {
|
||||||
let r = MinerRow { fan_rpms: vec![4200.0, 3990.0, 4500.0], ..Default::default() };
|
let r = MinerRow { fan_rpms: vec![4200.0, 3990.0, 4500.0], ..Default::default() };
|
||||||
|
|||||||
@@ -135,10 +135,13 @@ fn clean_antminer(id: &str) -> String {
|
|||||||
// asic-rs "Unknown" models pass the raw vendor string through with the brand
|
// asic-rs "Unknown" models pass the raw vendor string through with the brand
|
||||||
// still in it (e.g. "ANTMINER S19 (88)", a NoPIC S19); drop a redundant
|
// still in it (e.g. "ANTMINER S19 (88)", a NoPIC S19); drop a redundant
|
||||||
// leading brand word so the Model column never repeats the Brand column.
|
// leading brand word so the Model column never repeats the Brand column.
|
||||||
let id = if id.len() >= 9 && id[..9].eq_ignore_ascii_case("ANTMINER ") {
|
// `get(..9)` returns None (rather than panicking) when byte 9 is not a UTF-8
|
||||||
id[9..].trim_start()
|
// char boundary, so a multibyte miner-supplied model string can't crash here
|
||||||
} else {
|
// (round 18 #12). The prefix is 9 ASCII bytes, so a real match implies a
|
||||||
id
|
// boundary at 9 and the following `id[9..]` is safe.
|
||||||
|
let id = match id.get(..9) {
|
||||||
|
Some(p) if p.eq_ignore_ascii_case("ANTMINER ") => id[9..].trim_start(),
|
||||||
|
_ => id,
|
||||||
};
|
};
|
||||||
let bytes = id.as_bytes();
|
let bytes = id.as_bytes();
|
||||||
// Base = leading letters then digits ("S19", "KS5", "L3", "Z15"). Without a
|
// Base = leading letters then digits ("S19", "KS5", "L3", "Z15"). Without a
|
||||||
@@ -284,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
|
||||||
|
|||||||
@@ -82,10 +82,36 @@ pub fn save_all(field: PoolField, values: &[String]) -> std::io::Result<usize> {
|
|||||||
if let Some(dir) = p.parent() {
|
if let Some(dir) = p.parent() {
|
||||||
let _ = std::fs::create_dir_all(dir);
|
let _ = std::fs::create_dir_all(dir);
|
||||||
}
|
}
|
||||||
std::fs::write(&p, out.join("\n"))?;
|
// The password list can hold a pool password, so write it owner-only from the
|
||||||
|
// moment it is created -- never briefly world-readable (round 18 #12).
|
||||||
|
write_private(&p, out.join("\n").as_bytes())?;
|
||||||
Ok(out.len())
|
Ok(out.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Write `data` to `path` with owner-only (0600) permissions from creation on
|
||||||
|
/// Unix, so a secret is never momentarily world-readable between write and chmod.
|
||||||
|
/// `mode()` only takes effect when the file is created, so an already-existing
|
||||||
|
/// file is also re-tightened; elsewhere this is a plain write.
|
||||||
|
fn write_private(path: &std::path::Path, data: &[u8]) -> std::io::Result<()> {
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
use std::io::Write;
|
||||||
|
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
|
||||||
|
let mut f = std::fs::OpenOptions::new()
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
|
.mode(0o600)
|
||||||
|
.open(path)?;
|
||||||
|
let _ = std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600));
|
||||||
|
f.write_all(data)
|
||||||
|
}
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
{
|
||||||
|
std::fs::write(path, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 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> {
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ pub fn start_restore(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let tc = cancel.clone();
|
let tc = cancel.clone();
|
||||||
let _ = std::thread::Builder::new()
|
let err_tx = tx.clone();
|
||||||
|
let spawned = std::thread::Builder::new()
|
||||||
.name("restore-stock".into())
|
.name("restore-stock".into())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
let _ = tx.send(RestoreMsg::Started);
|
let _ = tx.send(RestoreMsg::Started);
|
||||||
@@ -92,6 +93,16 @@ pub fn start_restore(
|
|||||||
}
|
}
|
||||||
let _ = tx.send(RestoreMsg::Done);
|
let _ = tx.send(RestoreMsg::Done);
|
||||||
});
|
});
|
||||||
|
if spawned.is_err() {
|
||||||
|
// Never leave the restore subsystem wedged (round 18 #12): if the worker
|
||||||
|
// thread can't start, emit a failure + Done so the drain clears the handle.
|
||||||
|
let _ = err_tx.send(RestoreMsg::Result {
|
||||||
|
ip: String::new(),
|
||||||
|
ok: false,
|
||||||
|
detail: "could not start the restore worker thread".into(),
|
||||||
|
});
|
||||||
|
let _ = err_tx.send(RestoreMsg::Done);
|
||||||
|
}
|
||||||
RestoreHandle { rx, cancel }
|
RestoreHandle { rx, cancel }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,12 +121,19 @@ fn restore_one(t: &RestoreTarget, vnish_pass: &str, ssh_user: &str, ssh_pass: &s
|
|||||||
|
|
||||||
/// VNish: unlock -> bearer -> firmware/remove (self-restores + reboots ~3 s).
|
/// VNish: unlock -> bearer -> firmware/remove (self-restores + reboots ~3 s).
|
||||||
fn restore_vnish(ip: &str, pass: &str) -> (bool, String) {
|
fn restore_vnish(ip: &str, pass: &str) -> (bool, String) {
|
||||||
let unlock = match curl(&[
|
// serde-encode the body so a password with a quote/backslash can't break the
|
||||||
"-s", "--connect-timeout", "5", "--max-time", "9",
|
// JSON, and send it via stdin (-d @-) so the password never appears on curl's
|
||||||
"-X", "POST", "-H", "Content-Type: application/json",
|
// argv / the process list (round 18 #12).
|
||||||
"-d", &format!("{{\"pw\":\"{pass}\"}}"),
|
let body = serde_json::json!({ "pw": pass }).to_string();
|
||||||
&format!("http://{ip}/api/v1/unlock"),
|
let unlock = match curl(
|
||||||
]) {
|
&[
|
||||||
|
"-s", "--connect-timeout", "5", "--max-time", "9",
|
||||||
|
"-X", "POST", "-H", "Content-Type: application/json",
|
||||||
|
"-d", "@-",
|
||||||
|
&format!("http://{ip}/api/v1/unlock"),
|
||||||
|
],
|
||||||
|
Some(body.as_bytes()),
|
||||||
|
) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => return (false, format!("unlock request failed: {e}")),
|
Err(e) => return (false, format!("unlock request failed: {e}")),
|
||||||
};
|
};
|
||||||
@@ -126,11 +144,14 @@ fn restore_vnish(ip: &str, pass: &str) -> (bool, String) {
|
|||||||
let Some(token) = token else {
|
let Some(token) = token else {
|
||||||
return (false, "VNish unlock rejected (wrong web password?)".into());
|
return (false, "VNish unlock rejected (wrong web password?)".into());
|
||||||
};
|
};
|
||||||
match curl(&[
|
match curl(
|
||||||
"-s", "--connect-timeout", "5", "--max-time", "12",
|
&[
|
||||||
"-X", "POST", "-H", &format!("Authorization: Bearer {token}"),
|
"-s", "--connect-timeout", "5", "--max-time", "12",
|
||||||
&format!("http://{ip}/api/v1/firmware/remove"),
|
"-X", "POST", "-H", &format!("Authorization: Bearer {token}"),
|
||||||
]) {
|
&format!("http://{ip}/api/v1/firmware/remove"),
|
||||||
|
],
|
||||||
|
None,
|
||||||
|
) {
|
||||||
// The miner reverts + reboots after ~3 s; the response is {"after":N}.
|
// The miner reverts + reboots after ~3 s; the response is {"after":N}.
|
||||||
Ok(resp) if resp.contains("after") => (true, "reverting to stock (~3 s)".into()),
|
Ok(resp) if resp.contains("after") => (true, "reverting to stock (~3 s)".into()),
|
||||||
Ok(resp) => (false, format!("firmware/remove returned: {}", resp.trim())),
|
Ok(resp) => (false, format!("firmware/remove returned: {}", resp.trim())),
|
||||||
@@ -155,13 +176,29 @@ fn restore_luxos(ip: &str) -> (bool, String) {
|
|||||||
let Some(session) = session.filter(|s| !s.is_empty()) else {
|
let Some(session) = session.filter(|s| !s.is_empty()) else {
|
||||||
return (false, format!("no SessionID in logon response: {}", logon.trim()));
|
return (false, format!("no SessionID in logon response: {}", logon.trim()));
|
||||||
};
|
};
|
||||||
let cmd = format!("{{\"command\":\"uninstallluxos\",\"parameter\":\"{session}\"}}");
|
// serde-encode so the miner-supplied SessionID can't break or inject into the
|
||||||
|
// JSON-RPC command (round 18 #12).
|
||||||
|
let cmd = serde_json::json!({ "command": "uninstallluxos", "parameter": session }).to_string();
|
||||||
match lux_rpc(ip, &cmd) {
|
match lux_rpc(ip, &cmd) {
|
||||||
// Code 350 "Uninstalling LuxOS"; the miner reboots + reverts in background.
|
// Code 350 "Uninstalling LuxOS"; the miner reboots + reverts in background.
|
||||||
Ok(resp) if resp.contains("350") || resp.to_lowercase().contains("uninstall") => {
|
Ok(resp) if resp.contains("350") || resp.to_lowercase().contains("uninstall") => {
|
||||||
(true, "uninstalling LuxOS (reboots to stock)".into())
|
(true, "uninstalling LuxOS (reboots to stock)".into())
|
||||||
}
|
}
|
||||||
|
// The miner reboots as it reverts, so the reply is often dropped/empty
|
||||||
|
// after the command is accepted. The logon above already proved the miner
|
||||||
|
// was reachable, so an empty reply or a dropped connection here is the
|
||||||
|
// expected reboot, not a failure (round 18 #12).
|
||||||
|
Ok(resp) if resp.trim().is_empty() => {
|
||||||
|
(true, "uninstall accepted (miner rebooting to stock)".into())
|
||||||
|
}
|
||||||
Ok(resp) => (false, format!("uninstallluxos returned: {}", resp.trim())),
|
Ok(resp) => (false, format!("uninstallluxos returned: {}", resp.trim())),
|
||||||
|
Err(e)
|
||||||
|
if ["closed", "reset", "timed out", "broken pipe", "eof"]
|
||||||
|
.iter()
|
||||||
|
.any(|m| e.to_lowercase().contains(m)) =>
|
||||||
|
{
|
||||||
|
(true, "RPC dropped (miner rebooting to stock)".into())
|
||||||
|
}
|
||||||
Err(e) => (false, format!("uninstallluxos failed: {e}")),
|
Err(e) => (false, format!("uninstallluxos failed: {e}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,28 +209,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), None) {
|
||||||
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 +242,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 +303,115 @@ 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.
|
||||||
fn curl(args: &[&str]) -> Result<String, String> {
|
struct CmdOutput {
|
||||||
let mut cmd = Command::new("curl");
|
/// The process exit code, or `None` if it was killed / dropped / timed out.
|
||||||
cmd.args(args);
|
code: Option<i32>,
|
||||||
run_with_timeout(cmd, Duration::from_secs(15)).map(|o| String::from_utf8_lossy(&o).into_owned())
|
stdout: Vec<u8>,
|
||||||
|
stderr: Vec<u8>,
|
||||||
|
timed_out: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run a command, capture stdout, with a hard wall-clock timeout.
|
/// curl with a wall-clock cap. Errors only when the run produced no output and
|
||||||
fn run_with_timeout(mut cmd: Command, timeout: Duration) -> Result<Vec<u8>, String> {
|
/// 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], stdin_data: Option<&[u8]>) -> Result<String, String> {
|
||||||
|
let mut cmd = Command::new("curl");
|
||||||
|
cmd.args(args);
|
||||||
|
let out = run_with_timeout(cmd, Duration::from_secs(15), stdin_data)?;
|
||||||
|
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 with a hard wall-clock timeout, capturing stdout, stderr, and
|
||||||
|
/// 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).
|
||||||
|
/// `stdin_data`, when set, is written to the child's stdin and the pipe closed
|
||||||
|
/// (used to feed a request body without putting a secret on argv).
|
||||||
|
fn run_with_timeout(
|
||||||
|
mut cmd: Command,
|
||||||
|
timeout: Duration,
|
||||||
|
stdin_data: Option<&[u8]>,
|
||||||
|
) -> 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());
|
||||||
|
if stdin_data.is_some() {
|
||||||
|
cmd.stdin(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}"))?;
|
||||||
|
if let Some(data) = stdin_data {
|
||||||
|
if let Some(mut si) = child.stdin.take() {
|
||||||
|
let _ = si.write_all(data);
|
||||||
|
} // dropping `si` closes the pipe
|
||||||
|
}
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -498,11 +508,13 @@ fn board_index_from_text(text: &str) -> Option<usize> {
|
|||||||
let mut from = 0;
|
let mut from = 0;
|
||||||
while let Some(rel) = lower[from..].find(kw) {
|
while let Some(rel) = lower[from..].find(kw) {
|
||||||
let after = &lower[from + rel + kw.len()..];
|
let after = &lower[from + rel + kw.len()..];
|
||||||
let digits: String = after
|
// The number must IMMEDIATELY follow the keyword (after only separators
|
||||||
.trim_start_matches(|c: char| !c.is_ascii_digit())
|
// like " #-:._="), so "Chain 2 ..." -> 2 but "hashboard error, temp 65"
|
||||||
.chars()
|
// does not grab the temperature 65 far past the keyword (round 18 #12).
|
||||||
.take_while(|c| c.is_ascii_digit())
|
let rest = after.trim_start_matches(|c: char| {
|
||||||
.collect();
|
c.is_whitespace() || matches!(c, ':' | '#' | '-' | '_' | '.' | '=' | '(')
|
||||||
|
});
|
||||||
|
let digits: String = rest.chars().take_while(|c| c.is_ascii_digit()).collect();
|
||||||
if let Ok(n) = digits.parse::<usize>() {
|
if let Ok(n) = digits.parse::<usize>() {
|
||||||
return Some(n);
|
return Some(n);
|
||||||
}
|
}
|
||||||
@@ -564,6 +576,16 @@ mod board_index_tests {
|
|||||||
assert_eq!(board_index_from_text("Environment temperature is too high."), None);
|
assert_eq!(board_index_from_text("Environment temperature is too high."), None);
|
||||||
assert_eq!(board_index_from_text("Power current error."), None);
|
assert_eq!(board_index_from_text("Power current error."), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn does_not_grab_an_unrelated_number_far_past_the_keyword() {
|
||||||
|
// The number must immediately follow the keyword: a later temperature/count
|
||||||
|
// must not be mistaken for the board index (round 18 #12).
|
||||||
|
assert_eq!(board_index_from_text("hashboard error, chip temp 65C"), None);
|
||||||
|
assert_eq!(board_index_from_text("board voltage low, 12 chips offline"), None);
|
||||||
|
// A real "board <n>" still resolves even with trailing numbers.
|
||||||
|
assert_eq!(board_index_from_text("Chain 2 has 3 dead chips"), Some(2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Infer whether an Antminer's hashboards carry a per-board PIC MCU from the
|
/// Infer whether an Antminer's hashboards carry a per-board PIC MCU from the
|
||||||
@@ -577,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);
|
||||||
@@ -644,17 +666,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 +763,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 +1286,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 });
|
||||||
@@ -1802,7 +1845,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn auto_secs_round_trip_and_defaults() {
|
fn auto_secs_round_trip_and_defaults() {
|
||||||
// config_path() reads $HOME; point it at a private temp dir. HOME is
|
// config_path() reads $HOME; point it at a private temp dir. HOME is
|
||||||
// process-global, so this stays one test and restores HOME afterward.
|
// process-global, so serialise against other HOME-mutating tests and
|
||||||
|
// restore HOME afterward (round 18 #12).
|
||||||
|
let _home = crate::model::HOME_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
let prev = std::env::var_os("HOME");
|
let prev = std::env::var_os("HOME");
|
||||||
let dir = std::env::temp_dir().join(format!("alkane-test-{}", std::process::id()));
|
let dir = std::env::temp_dir().join(format!("alkane-test-{}", std::process::id()));
|
||||||
let _ = std::fs::remove_dir_all(&dir);
|
let _ = std::fs::remove_dir_all(&dir);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub const ID_PRESETS: i32 = 108;
|
|||||||
pub const ID_EXPORT: i32 = 109;
|
pub const ID_EXPORT: i32 = 109;
|
||||||
// Settings menu (round 15 #13): the toolbar button + its menu items.
|
// Settings menu (round 15 #13): the toolbar button + its menu items.
|
||||||
pub const ID_SETTINGS: i32 = 110;
|
pub const ID_SETTINGS: i32 = 110;
|
||||||
const ID_LANG_BASE: i32 = 790; // one id per language (790 + index)
|
const ID_LANG_BASE: i32 = 790; // one id per language (790 + Lang index); reserves 790..790+Lang::all().len()
|
||||||
const ID_LOGS_OPEN: i32 = 796; // open the Logs page
|
const ID_LOGS_OPEN: i32 = 796; // open the Logs page
|
||||||
const ID_LOGS_REFRESH: i32 = 797;
|
const ID_LOGS_REFRESH: i32 = 797;
|
||||||
const ID_LOGS_CLEAR: i32 = 798;
|
const ID_LOGS_CLEAR: i32 = 798;
|
||||||
@@ -86,12 +86,14 @@ const ID_CTX_POOLS: i32 = 736;
|
|||||||
const ID_POOLS_OK: i32 = 788;
|
const ID_POOLS_OK: i32 = 788;
|
||||||
const ID_POOLS_CANCEL: i32 = 789;
|
const ID_POOLS_CANCEL: i32 = 789;
|
||||||
// Pool-preset manager dialog (round 18 #8b): edit the whole saved list at once.
|
// Pool-preset manager dialog (round 18 #8b): edit the whole saved list at once.
|
||||||
const ID_POOL_PRESETS_SAVE: i32 = 790;
|
// NB: 790-795 belong to the language menu (ID_LANG_BASE + Lang index), so these
|
||||||
const ID_POOL_PRESETS_CANCEL: i32 = 791;
|
// live in a separate high block to avoid an id collision (round 18 #12).
|
||||||
|
const ID_POOL_PRESETS_SAVE: i32 = 1001;
|
||||||
|
const ID_POOL_PRESETS_CANCEL: i32 = 1002;
|
||||||
// Firmware profile/preset selector dialog (round 18 / roadmap G3).
|
// Firmware profile/preset selector dialog (round 18 / roadmap G3).
|
||||||
const ID_FWPRESET_OK: i32 = 792;
|
const ID_FWPRESET_OK: i32 = 1003;
|
||||||
const ID_FWPRESET_CANCEL: i32 = 793;
|
const ID_FWPRESET_CANCEL: i32 = 1004;
|
||||||
const ID_FWPRESET_CHOICE: i32 = 794;
|
const ID_FWPRESET_CHOICE: i32 = 1005;
|
||||||
// Pool-field "+" dropdown buttons (round 15 #1): 12 buttons (3 rows x 4 fields),
|
// Pool-field "+" dropdown buttons (round 15 #1): 12 buttons (3 rows x 4 fields),
|
||||||
// id = base + row*4 + field. The dropdown menu items use their own id range.
|
// id = base + row*4 + field. The dropdown menu items use their own id range.
|
||||||
const ID_POOL_PLUS_BASE: i32 = 800;
|
const ID_POOL_PLUS_BASE: i32 = 800;
|
||||||
@@ -291,7 +293,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 +647,16 @@ 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,
|
||||||
|
// Set when a scan streamed new rows this drain; flushed by tick() at most once
|
||||||
|
// per second (or immediately once the scan ends) so the full table refill runs
|
||||||
|
// ~1 Hz during a scan instead of every fast tick (round 18 #12).
|
||||||
|
rows_dirty: 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>,
|
||||||
@@ -695,6 +713,10 @@ pub struct App {
|
|||||||
// IPs the current config action targets, re-probed after it completes so the
|
// IPs the current config action targets, re-probed after it completes so the
|
||||||
// table reflects the change (e.g. the identify light toggling).
|
// table reflects the change (e.g. the identify light toggling).
|
||||||
action_targets: Vec<String>,
|
action_targets: Vec<String>,
|
||||||
|
// A new password from an in-flight ChangePassword action, applied to the saved
|
||||||
|
// credentials once the action succeeds so the toolkit keeps reaching the miners
|
||||||
|
// it just changed (round 18 #12).
|
||||||
|
pending_password_update: Option<String>,
|
||||||
// Per-miner in-flight operation label (round 14 #4): while a miner has an
|
// Per-miner in-flight operation label (round 14 #4): while a miner has an
|
||||||
// operation running (refresh, config action, light, firmware, restore, access
|
// operation running (refresh, config action, light, firmware, restore, access
|
||||||
// check), its Health cell shows this text instead of the component icons.
|
// check), its Health cell shows this text instead of the component icons.
|
||||||
@@ -727,6 +749,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 +1030,8 @@ pub fn build(frame: Widget) -> App {
|
|||||||
progress,
|
progress,
|
||||||
table: None,
|
table: None,
|
||||||
columns_autosized: false,
|
columns_autosized: false,
|
||||||
|
rows_dirty: 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())),
|
||||||
@@ -1033,6 +1062,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
action_total: 0,
|
action_total: 0,
|
||||||
action_done: 0,
|
action_done: 0,
|
||||||
action_targets: Vec::new(),
|
action_targets: Vec::new(),
|
||||||
|
pending_password_update: None,
|
||||||
op_status: std::collections::HashMap::new(),
|
op_status: std::collections::HashMap::new(),
|
||||||
confirm_dialog: frame,
|
confirm_dialog: frame,
|
||||||
pending_confirm: None,
|
pending_confirm: None,
|
||||||
@@ -1046,6 +1076,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 +1229,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,12 +1241,24 @@ 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 };
|
||||||
|
// Compute the shown columns once and reuse it everywhere below (with
|
||||||
|
// auto-hide-empty on, table_columns() scans every cell of every row, so it
|
||||||
|
// must not be called per section of this function -- round 18 #12).
|
||||||
|
let cols = self.table_columns();
|
||||||
|
// 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 cols != 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();
|
||||||
t.dvlc_clear();
|
t.dvlc_clear();
|
||||||
self.view_idx = self.view.view(&self.rows);
|
self.view_idx = self.view.view(&self.rows);
|
||||||
let cols = self.table_columns();
|
|
||||||
for &ri in &self.view_idx {
|
for &ri in &self.view_idx {
|
||||||
let r = &self.rows[ri];
|
let r = &self.rows[ri];
|
||||||
let cells: Vec<String> = cols.iter().map(|c| c.cell(r)).collect();
|
let cells: Vec<String> = cols.iter().map(|c| c.cell(r)).collect();
|
||||||
@@ -1799,6 +1846,17 @@ impl App {
|
|||||||
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
|
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// This path sets self.action directly, so it needs start_action's full
|
||||||
|
// exclusivity guard: don't write pools during a restore or a live scan
|
||||||
|
// (round 18 #12).
|
||||||
|
if self.restore.is_some() {
|
||||||
|
wx_rs::set_status_text("restore-to-stock in progress -- wait for it to finish");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if self.scanning {
|
||||||
|
wx_rs::set_status_text("scan in progress -- wait for it to finish");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Collect the raw rows: (address, account, worker_template, password).
|
// Collect the raw rows: (address, account, worker_template, password).
|
||||||
let mut rows: Vec<(String, String, String, String)> = Vec::new();
|
let mut rows: Vec<(String, String, String, String)> = Vec::new();
|
||||||
for row in 0..3usize {
|
for row in 0..3usize {
|
||||||
@@ -1846,6 +1904,12 @@ impl App {
|
|||||||
let ips: Vec<String> = targets.iter().map(|t| t.ip.clone()).collect();
|
let ips: Vec<String> = targets.iter().map(|t| t.ip.clone()).collect();
|
||||||
if let Some(old) = self.action.take() {
|
if let Some(old) = self.action.take() {
|
||||||
old.stop();
|
old.stop();
|
||||||
|
// Clear the superseded action's in-flight status so its Health cells
|
||||||
|
// don't stay frozen on the old label (round 18 #12).
|
||||||
|
let stale = std::mem::take(&mut self.action_targets);
|
||||||
|
for ip in stale {
|
||||||
|
self.op_status.remove(&ip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.pools_dialog.close(1);
|
self.pools_dialog.close(1);
|
||||||
self.action_targets = ips.clone();
|
self.action_targets = ips.clone();
|
||||||
@@ -1864,13 +1928,41 @@ impl App {
|
|||||||
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
|
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// A restore-to-stock is reverting + rebooting miners; a config action mid-
|
||||||
|
// revert could hit a unit in an undefined state (round 18 #12).
|
||||||
|
if self.restore.is_some() {
|
||||||
|
wx_rs::set_status_text("restore-to-stock in progress -- wait for it to finish");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// A scan is opening its own connections to these same miners; a mutating
|
||||||
|
// action racing the scan's probe traffic can be dropped or interleaved, so
|
||||||
|
// hold it until the scan finishes (round 18 #12 -- matches the flash/restore
|
||||||
|
// invariant).
|
||||||
|
if self.scanning {
|
||||||
|
wx_rs::set_status_text("scan in progress -- wait for it to finish");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if let Some(old) = self.action.take() {
|
if let Some(old) = self.action.take() {
|
||||||
old.stop();
|
old.stop();
|
||||||
|
// The superseded action's drain will never run again, so clear its
|
||||||
|
// miners' in-flight status or their Health cells stay frozen on the old
|
||||||
|
// "…ing" label forever (round 18 #12).
|
||||||
|
let stale = std::mem::take(&mut self.action_targets);
|
||||||
|
for ip in stale {
|
||||||
|
self.op_status.remove(&ip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Progress shows in each miner's Health cell (round 15 #8), not the scan
|
// Progress shows in each miner's Health cell (round 15 #8), not the scan
|
||||||
// line; the bottom-right indicator still surfaces failures at the end.
|
// line; the bottom-right indicator still surfaces failures at the end.
|
||||||
crate::logs::log(format!("apply {} to {} miner(s)", action.label(), ips.len()));
|
crate::logs::log(format!("apply {} to {} miner(s)", action.label(), ips.len()));
|
||||||
self.action_targets = ips.clone();
|
self.action_targets = ips.clone();
|
||||||
|
// Remember a password change so we can update our own saved credentials
|
||||||
|
// once it succeeds -- otherwise the toolkit keeps using the old password
|
||||||
|
// and locks itself out of the miners it just changed (round 18 #12).
|
||||||
|
self.pending_password_update = match &action {
|
||||||
|
scan::ConfigAction::ChangePassword(p) => Some(p.clone()),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
self.set_op_status(&ips, &action.progress_label());
|
self.set_op_status(&ips, &action.progress_label());
|
||||||
self.action = Some(scan::start_config_action(ips, action));
|
self.action = Some(scan::start_config_action(ips, action));
|
||||||
// Clear any stale error/warning from a previous operation; the new
|
// Clear any stale error/warning from a previous operation; the new
|
||||||
@@ -1898,13 +1990,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 +2013,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 +2056,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 +2082,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 +2139,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);
|
||||||
@@ -2031,10 +2180,10 @@ impl App {
|
|||||||
let mut oks = 0usize;
|
let mut oks = 0usize;
|
||||||
let mut fails: Vec<String> = Vec::new();
|
let mut fails: Vec<String> = Vec::new();
|
||||||
let mut op_clear: Vec<String> = Vec::new();
|
let mut op_clear: Vec<String> = Vec::new();
|
||||||
while let Ok(msg) = h.rx.try_recv() {
|
loop {
|
||||||
match msg {
|
match h.rx.try_recv() {
|
||||||
restore::RestoreMsg::Started => {}
|
Ok(restore::RestoreMsg::Started) => {}
|
||||||
restore::RestoreMsg::Result { ip, ok, detail } => {
|
Ok(restore::RestoreMsg::Result { ip, ok, detail }) => {
|
||||||
op_clear.push(ip.clone());
|
op_clear.push(ip.clone());
|
||||||
if ok {
|
if ok {
|
||||||
oks += 1;
|
oks += 1;
|
||||||
@@ -2042,7 +2191,17 @@ impl App {
|
|||||||
fails.push(format!("{ip}: {detail}"));
|
fails.push(format!("{ip}: {detail}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
restore::RestoreMsg::Done => done = true,
|
Ok(restore::RestoreMsg::Done) => {
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Err(std::sync::mpsc::TryRecvError::Empty) => break,
|
||||||
|
// The worker thread ended without a Done (e.g. it never started):
|
||||||
|
// finalise so the restore subsystem can't wedge (round 18 #12).
|
||||||
|
Err(std::sync::mpsc::TryRecvError::Disconnected) => {
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ip in &op_clear {
|
for ip in &op_clear {
|
||||||
@@ -2099,6 +2258,7 @@ impl App {
|
|||||||
let mut done = false;
|
let mut done = false;
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
let mut op_clear: Vec<String> = Vec::new();
|
let mut op_clear: Vec<String> = Vec::new();
|
||||||
|
let mut errors: Vec<String> = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
match h.rx.try_recv() {
|
match h.rx.try_recv() {
|
||||||
Ok(scan::AccessProbeMsg::Started { total }) => {
|
Ok(scan::AccessProbeMsg::Started { total }) => {
|
||||||
@@ -2107,11 +2267,17 @@ impl App {
|
|||||||
Ok(scan::AccessProbeMsg::Result { ip, locked, error }) => {
|
Ok(scan::AccessProbeMsg::Result { ip, locked, error }) => {
|
||||||
op_clear.push(ip.clone());
|
op_clear.push(ip.clone());
|
||||||
if let Some(r) = self.rows.iter_mut().find(|r| r.ip == ip) {
|
if let Some(r) = self.rows.iter_mut().find(|r| r.ip == ip) {
|
||||||
if error.is_none() {
|
// Only a definitive answer updates the cell; an indeterminate
|
||||||
|
// probe (locked = None) must not blank a previously-known
|
||||||
|
// locked/unlocked state (round 18 #12).
|
||||||
|
if error.is_none() && locked.is_some() {
|
||||||
r.write_locked = locked;
|
r.write_locked = locked;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Some(e) = &error {
|
||||||
|
errors.push(format!("{ip}: {e}"));
|
||||||
|
}
|
||||||
status = Some(match (&locked, &error) {
|
status = Some(match (&locked, &error) {
|
||||||
(_, Some(e)) => format!("access {ip}: {e}"),
|
(_, Some(e)) => format!("access {ip}: {e}"),
|
||||||
(Some(true), _) => format!("access {ip}: locked"),
|
(Some(true), _) => format!("access {ip}: locked"),
|
||||||
@@ -2142,6 +2308,12 @@ impl App {
|
|||||||
}
|
}
|
||||||
if done {
|
if done {
|
||||||
self.access_probe = None;
|
self.access_probe = None;
|
||||||
|
// Probe errors (a miner the check could not run against) were being
|
||||||
|
// dropped entirely; surface them in the failure indicator (round 18 #12).
|
||||||
|
if !errors.is_empty() {
|
||||||
|
self.set_error_indicator(&format!("access check: {} failed", errors.len()));
|
||||||
|
crate::logs::log(format!("access check errors: {}", errors.join("; ")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Operation progress stays out of the bottom-left scan line (round 15 #8);
|
// Operation progress stays out of the bottom-left scan line (round 15 #8);
|
||||||
// per-miner status shows in the Health column.
|
// per-miner status shows in the Health column.
|
||||||
@@ -2161,7 +2333,7 @@ impl App {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
// Settings menu Language items (round 15 #13).
|
// Settings menu Language items (round 15 #13).
|
||||||
if (ID_LANG_BASE..ID_LANG_BASE + 6).contains(&id) {
|
if (ID_LANG_BASE..ID_LANG_BASE + crate::i18n::Lang::all().len() as i32).contains(&id) {
|
||||||
self.set_language((id - ID_LANG_BASE) as usize);
|
self.set_language((id - ID_LANG_BASE) as usize);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@@ -2178,13 +2350,13 @@ 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 => {
|
||||||
// A flash needs exclusive hardware access; don't even prompt if
|
// A flash needs exclusive hardware access; don't even prompt if
|
||||||
// any scan / refresh / action is running (re-checked at confirm).
|
// any scan / refresh / action / restore is running (re-checked at confirm).
|
||||||
if self.flashing || self.scanning || self.action.is_some() || self.refresh.is_some() {
|
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 in progress) -- try again once it finishes");
|
wx_rs::set_status_text("busy (scan/action in progress) -- try again once it finishes");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@@ -2348,7 +2520,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);
|
||||||
@@ -2591,7 +2770,7 @@ impl App {
|
|||||||
// started while the dialog was open. A flash must never race another
|
// started while the dialog was open. A flash must never race another
|
||||||
// network operation on the same miner, so refuse rather than run the
|
// network operation on the same miner, so refuse rather than run the
|
||||||
// prior handle's `stop()` (which does not join the in-flight upload).
|
// prior handle's `stop()` (which does not join the in-flight upload).
|
||||||
if self.flashing || self.scanning || self.action.is_some() || self.refresh.is_some() {
|
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 started) -- flash cancelled, try again");
|
wx_rs::set_status_text("busy (scan/action started) -- flash cancelled, try again");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2633,7 +2812,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 +2847,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);
|
||||||
@@ -2718,6 +2898,13 @@ impl App {
|
|||||||
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
|
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
|
||||||
let user = user_ctrl.get_value();
|
let user = user_ctrl.get_value();
|
||||||
let pass = pass_ctrl.get_value();
|
let pass = pass_ctrl.get_value();
|
||||||
|
// A fully-blank row means "no override, use the shipped default" -- the
|
||||||
|
// natural way to clear one firmware's override. Without this, a blanked
|
||||||
|
// row was saved as an explicit ("","") override that then broke auth
|
||||||
|
// fleet-wide for that firmware (round 18 #12).
|
||||||
|
if user.trim().is_empty() && pass.trim().is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let default = credentials::firmware_default_for(name);
|
let default = credentials::firmware_default_for(name);
|
||||||
if (user.clone(), pass.clone()) != default {
|
if (user.clone(), pass.clone()) != default {
|
||||||
map.insert(name.clone(), (user, pass));
|
map.insert(name.clone(), (user, pass));
|
||||||
@@ -2794,6 +2981,34 @@ impl App {
|
|||||||
} else {
|
} else {
|
||||||
Some((false, format!("apply: {}/{total} miner(s) failed", total - ok)))
|
Some((false, format!("apply: {}/{total} miner(s) failed", total - ok)))
|
||||||
});
|
});
|
||||||
|
// A password change succeeded on every target: update our own
|
||||||
|
// saved global credential so the toolkit keeps reaching them. On
|
||||||
|
// a partial change we leave saved creds alone (we can't tell which
|
||||||
|
// password now works for which miner) and warn (round 18 #12).
|
||||||
|
// (self.pending_password_update is a different field than self.action,
|
||||||
|
// so this disjoint borrow is fine while `h` still holds self.action.)
|
||||||
|
if let Some(newpass) = self.pending_password_update.take() {
|
||||||
|
if ok == total && total > 0 {
|
||||||
|
let user = credentials::load_credentials()
|
||||||
|
.map(|(u, _)| u)
|
||||||
|
.unwrap_or_else(|| "root".into());
|
||||||
|
match credentials::save_credentials(&user, &newpass) {
|
||||||
|
Ok(()) => crate::logs::log(
|
||||||
|
"saved credentials updated to the new password".to_string(),
|
||||||
|
),
|
||||||
|
Err(e) => crate::logs::log(format!(
|
||||||
|
"could not update saved credentials after password change: {e}"
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
crate::logs::log(
|
||||||
|
"password change was partial -- saved credentials left unchanged; \
|
||||||
|
update Settings > Credentials manually so the toolkit can reach \
|
||||||
|
the changed miners"
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2979,30 +3194,49 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if changed {
|
if changed {
|
||||||
self.fill_rows();
|
if self.scanning {
|
||||||
|
// Still scanning: defer the whole-table refill to tick()'s ~1 Hz
|
||||||
|
// flush so streaming rows don't trigger a refill on every fast tick
|
||||||
|
// (round 18 #12).
|
||||||
|
self.rows_dirty = true;
|
||||||
|
} else {
|
||||||
|
// The scan just ended (or wasn't running): show the final state now.
|
||||||
|
self.fill_rows();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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);
|
||||||
|
// Flush a scan's batched row updates at most once per second (or right away
|
||||||
|
// once the scan has ended), so the whole-table refill runs ~1 Hz during a
|
||||||
|
// scan rather than on every fast tick (round 18 #12).
|
||||||
|
if self.rows_dirty && (!self.scanning || self.tick_accum.is_multiple_of(TICKS_PER_SEC)) {
|
||||||
|
self.rows_dirty = false;
|
||||||
|
self.fill_rows();
|
||||||
|
}
|
||||||
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,17 +3256,32 @@ 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
|
||||||
fn begin_scan(&mut self, lines: Vec<String>) {
|
/// 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.
|
||||||
|
/// 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;
|
||||||
|
}
|
||||||
|
// Symmetric to start_action's scan guard: don't start a scan (including an
|
||||||
|
// auto-rescan) while a config action or restore is writing to miners, so
|
||||||
|
// the two never race on the same unit (round 18 #12).
|
||||||
|
if self.action.is_some() || self.restore.is_some() {
|
||||||
|
wx_rs::set_status_text("operation in progress -- scan deferred");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if let Some(old) = self.scan.take() {
|
if let Some(old) = self.scan.take() {
|
||||||
old.stop();
|
old.stop();
|
||||||
@@ -3040,12 +3289,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
|
||||||
@@ -4081,7 +4332,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
|
||||||
@@ -4094,7 +4345,12 @@ impl App {
|
|||||||
pub fn run_fixture_selftest(&mut self) -> bool {
|
pub fn run_fixture_selftest(&mut self) -> bool {
|
||||||
self.rows = crate::fixtures::bench_fleet();
|
self.rows = crate::fixtures::bench_fleet();
|
||||||
self.view = ViewState::default();
|
self.view = ViewState::default();
|
||||||
self.fill_rows();
|
// Show the detailed per-board Boards column so its dot-sentinel rendering
|
||||||
|
// is actually exercised (round 18 #12: it is opt-in, not default-visible,
|
||||||
|
// so without this the Boards check below was dead). rebuild_table (not
|
||||||
|
// fill_rows) so the widget's columns match the changed visible set.
|
||||||
|
self.view.visible.insert(crate::model::Column::Hashboards);
|
||||||
|
self.rebuild_table();
|
||||||
|
|
||||||
let mut ok = true;
|
let mut ok = true;
|
||||||
let mut check = |name: &str, pass: bool, detail: String| {
|
let mut check = |name: &str, pass: bool, detail: String| {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ ignore = [
|
|||||||
|
|
||||||
[licenses]
|
[licenses]
|
||||||
version = 2
|
version = 2
|
||||||
# The project is MIT OR Apache-2.0; only permissive licenses are allowed in the
|
# The project is MIT; only permissive licenses are allowed in the
|
||||||
# dependency tree.
|
# dependency tree.
|
||||||
allow = [
|
allow = [
|
||||||
"MIT",
|
"MIT",
|
||||||
|
|||||||
@@ -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) };
|
||||||
|
|||||||