9 Commits
Author SHA1 Message Date
morningstar-sudo c91b21dbb9 refactor!: drop upgrade paths from pre-2026-10-09 servers
No server runs an older version; every deploy starts fresh, so the
code that migrated old installs goes.

- remove LIO/zram-kernel cleanup, dnsmasq/tftpd takeover, old
  directory layout move, admin_pw → owner account conversion
- remove DB migrations: schema comes from SCHEMA only, unique
  indexes live there; leases lose the always-"full" source column
- rename config keys ltsp_user/ltsp_password → guest_user/
  guest_password
- golden: no ServeFile fallback for a golden.vhdx file (404 →
  publish again), drop tower dependency
- versions: drop 4 MB chunk versions, a version is its file only
- iscsid: peers is a plain list, no "old daemon" branch
- publish refuses a golden prepped without the script stubs
  (was a warning: its scripts never updated)
- stage/linux-cache: stop cleaning delta-update leftovers
- tests: reuse disk.rs readers in vhdx tests
- docs: README rewritten shorter (618 → 259 lines), Pages updated,
  imaging (capture/deploy) added to the comparisons

BREAKING CHANGE: an existing bootrom.db is not migrated: start with
a new one. Goldens prepped before 2026-10-09 must be prepped again
in the VM before upload.
2026-10-19 01:41:33 +07:00
morningstar-sudo e5ce3501e1 Refactor and optimize various components for improved performance and maintainability
- Enhanced `serve` function in `goldenram.rs` to read and send data in 1 MB chunks concurrently, improving throughput.
- Updated `hash.rs` to implement a more efficient `sha256_with` function that reads data in parallel while hashing, reducing overall processing time.
- Modified `write_chunk` in `images.rs` to skip writing zeroed MBs, optimizing disk usage.
- Improved `command` function in `conn.rs` to streamline read operations.
- Optimized `read_at` method in `overlay.rs` to read neighboring blocks in a single call, reducing disk access overhead.
- Adjusted `main.rs` to increase the buffer chunk size for TFTP service, enhancing data transfer efficiency.
- Refined `status` function in `monitor.rs` to limit concurrent pings, improving responsiveness and resource management.
- Changed default `boot_timeout` in `settings.rs` from 10 to 3 seconds for quicker boot processes.
- Updated `autoexec` function in `tftp.rs` to utilize existing IP addresses, reducing DHCP wait times.
- Enhanced `sha256` function in `vhdx.rs` to leverage the new `sha256_with` for better performance.
- Added tests for sparse file writing and hash caching behavior in `hash.rs` and `golden.rs` to ensure correctness and performance.
2026-10-14 18:17:20 +07:00
morningstar-sudo a4fe5f8c04 feat: enhance benchmarking functionality with live iSCSI data and improve logging 2026-10-12 10:13:12 +07:00
morningstar-sudo e392cb2548 feat: add benchmarking functionality for server disk, iSCSI, and client performance
- Implemented a new benchmark module to track server disk performance, including sequential and random read speeds.
- Added database support for storing benchmark results with a new BenchRow struct and associated methods in the Db trait.
- Enhanced the SQLite database schema to include a new table for benchmark results.
- Created a new benchmark page in the web interface, allowing users to view current and historical benchmark data.
- Integrated iSCSI read statistics into the benchmark page, displaying real-time data on client read performance.
- Updated the main application routing to include the new benchmark page and its associated API endpoints.
- Added JavaScript functionality to dynamically load benchmark data and handle user interactions for initiating benchmarks.
2026-10-12 09:47:26 +07:00
morningstar-sudo dacc97240e chore: wget timeouts in the stage, cache-list waits for the network, label read without blkid, dead code
- stage: GNU wget defaults to a 30 s read timeout and 3 tries (was 15 min x 20)
  so a stalled server can't hang the stage.
- linux cache: waits up to a minute for the network before fetching the
  cache list (on a cache HIT the initramfs never brought it up).
- linux hook: the broomcache label is read from the ext4 superblock — with a
  busybox blkid the kept cache was formatted on every boot.
- publish: the Secure Boot shim is copied to a temp file and renamed in.
- startup clean-up also removes driver upload/extract dirs, the stage build's
  initramfs config, driver archive temps and upload/unzip.
- web: an expired session on a page load goes to /login instead of caching
  the "login required" text as the page.
- broom-done: the BASE MODE message warns that a hard power-off loses the
  setup.
- removed: GET /api/machines, /api/machines/group, /api/dhcp/apply, the
  tftp::serve wrapper and dhcp::handle's unused parameters.

Scripts changed -> the next publish rebuilds the golden/stage once.
2026-10-04 21:44:01 +07:00
morningstar-sudo 06937323aa fix: server IP at boot time, DoS/flood limits, license ARP check, session room, safer upload/cache mode/delete
- boot: boot scripts use ${broom-srv}, set by /boot/start from the current
  Server IP — changing it needs no republish (once more after this upgrade).
- images: the SSD switch asks for a republish when the boot script predates
  it; an upload to a disk-cache Linux image with clients is refused before
  the convert; cache mode goes back when its publish fails.
- linuxfs/vmdk: LVM metadata nesting capped (a crafted one overflowed the
  stack and aborted the server), kernel/initrd read capped at 512 MiB, VMDK
  grain directory capped at 16 MiB (sparse uploads).
- settings/dhcp: the interface must exist to be saved; at start a failed :67
  bind still leaves TFTP serving; each DHCP packet's DB work runs on a
  blocking thread.
- limits: pxe_seen holds at most 4096 MACs; the remembered IP is the
  connection's, not the claimed ?ip=; /api/status pings at most 32 at once.
- license: an ARP entry matching the machine's MAC is required; /api/status
  no longer carries full keys (machine detail still does).
- stage: step 0 keeps >= 20 GB / 10 % free on BROOMWIN by evicting the oldest
  parked images; files.sha256 names its golden and a client on another
  golden never applies it.
- linux cache: a golden larger than the cache partition evicts nothing.
- devices: bulk Register takes the PXE-seen IP when there is no lease.
- main: one instance per data directory (flock on bootrom.lock).
- db: deleting the default moves it only to a published image of the same OS.
- versions: delete reports success even if the following gc fails; snapshot
  checks free space. golden: converted image fsynced before the rename.

Scripts changed -> publish every image again (boot scripts gain ${broom-srv}).
2026-10-04 20:18:15 +07:00
morningstar-sudo bd20a76152 feat: per-image SSD on/off, every image keeps its own copy, Broom SSD shared by Windows and Linux
Shared SSD layout: p1 BROOMEFI 512M | p2 BROOMWIN | p3 broomwb 30G | p4
broomcache, found by GPT partition name (sysfs) by both the Windows stage
and the Linux initrd hook. Whichever OS boots first lays it out and formats
only its own partitions — switching images no longer wipes the disk.

Every image a machine boots keeps its copy: Windows sets parked in
broom\img.<image>\ (the booting one at the top, so the BCD and broom-done
are unchanged; a rename, VHDX parent links are relative), Linux goldens as
<image>.img in broomcache. On every boot the machine fetches
/api/cache-list ("name hash" of images it may keep: published and using the
SSD) and removes the others; no answer -> nothing removed; the running copy
is never touched. Out of space -> the copy unused the longest goes.

SSD on/off per Linux image (Images page, POST /api/images/ssd): off = the
SSD is never touched, golden over iSCSI, writes in RAM. Windows always uses
the SSD. Read per boot (broom.ssd); the Linux share of a new layout is
30 GB + the total of the Linux goldens using the SSD + 5 GB (broom.lxgb).

Also:
- vmdk/linuxfs: crafted headers refused (no giant buffer / panic).
- stage: one disk on a registered machine is looked at again after 5 s
  before it is wiped (a late Broom SSD / second disk).
- iscsi: idle superseded generations (and their zram) dropped every 60 s.
- winstage: single-partition GPT written before the holes are punched.

Upgrade: publish every image again (boot scripts gain broom.lxgb, broom.ssd,
broom.srv). Scripts changed -> golden/stage rebuilt once.
2026-10-04 16:15:02 +07:00
morningstar-sudo 09e855063d fix: license/guest hardening, image delete, Network Apply; golden always downloaded whole
Golden download (Windows stage + Linux SSD cache): always one whole file, no
4 MB chunk delta. The old copy goes first, the new one is written in one
sequential stream (less fragmentation, nothing to compare) and hashed on the
way; it is accepted only when the hash AND the size (new golden.size from the
server) match, so a disk-full or cut download is never taken. The stage checks
free space first and resumes a cut download with wget -c. Removed: delta(),
/api/golden-chunk, the compressed chunk cache, the zstd crate, broom.srv on
the Linux cmdline. chunks.rs -> hash.rs (file_hash only).

Windows publish: the stage bundle and server IP are checked before anything
is written; golden.sha256/size/key are removed only right before the new
golden replaces the old one and golden.sha256 is written last; the .tmp file
is removed on error.

- drivers: a client can no longer re-arm its own license key. Re-arming on a
  driver-set change is decided on the server (driver upload/delete/targets,
  machine group change) from the stored hardware IDs.
- devices: renaming a machine or giving it another image re-arms its key.
- stage: first.pending next to an existing base is ignored (a guest could make
  the reset child the base -> base pointing at itself, machine never boots).
- stage: driver archives are kept; every base build extracts them again after
  a sha256 check, so a folder the guest edited on BROOMWIN never reaches base.
- stage: `cp base-template.vhdx child.vhdx` checked.
- images: delete refuses while a Linux client uses the image, removes files
  before the DB row, and claims the job slot under the lock. The DB unlinks
  machines from the deleted id (SQLite reuses it) and moves the default.
- iscsi: per-target session check from LIO's dynamic_sessions replaces the
  portal-wide `ss` check (publish, rollback, gc of superseded generations).
- publish (Linux): every refusal before anything is written; kernel/initrd
  are built in <name>.new and swapped in right before the new boot script is
  saved. Rollback of a disk-cache image drops its targets before rewriting.
- Network page: Apply works with the DHCP server off (range fields may be
  blank; checked only in full mode: start <= end, inside the subnet).
  dhcp_mode 'proxy' migrated to 'off'. Lease accepts s/m/h/d like the parser;
  gateway is a single IP; server IP must be one of this host's.
- auth: Host check accepts any IP literal, localhost and the machine's
  hostname (DNS rebinding always carries a domain name).
- web: the Images "Boot" button works again.
- publish: bundled shim path restored (broom-stage/shimx64.efi).

Residual: a guest can still fetch an *armed* key through /boot/start +
/api/license (a local admin can fake the pre-boot side).

Upgrade: publish each Windows image once (writes golden.size; the scripts
changed, so the golden/stage are rebuilt anyway). Each Windows machine then
downloads the golden whole and rebuilds its base once.
2026-10-04 14:10:16 +07:00
morningstar-sudo 6baa0f37f1 refactor: scripts as files, split winstage/publish/machines, shared API helpers
- the 8 embedded shell/PowerShell scripts move to mgmt/scripts/ (still
  include_str! into the binary, byte-identical: same golden key, no client
  rebuild); .gitattributes keeps them LF on every checkout
- winstage.rs → winstage/{mod.rs (publish + golden), stage.rs (client
  stage bundle), prep.rs (what goes into the golden)}
- publish.rs → golden.rs (upload → raw) + chunks.rs (hashes, manifest,
  delta chunks) + publish.rs (Linux iSCSI/zram)
- machines.rs → machines.rs (table) + license.rs (keys, boot reports) +
  settings.rs (boot menu, zram, DHCP, guest user)
- api.rs: ApiError/ise/bad/ok shared instead of 4 copies; duplicate now()
  helpers use crate::now_secs
- fix: pxe_seen (fed by public endpoints) drops entries older than 30 min;
  the driver-set baseline is kept for registered machines only — neither
  grows with made-up MACs any more
2026-10-04 08:45:15 +07:00