Skip to content

Feature: TrueNAS WebSocket API for disk health and system summary - #546

Merged
SandObserver merged 2 commits into
mainfrom
feat/truenas-websocket-api
Oct 23, 2026
Merged

SandObserver merged 2 commits into
mainfrom
feat/truenas-websocket-api

Conversation

@SandObserver

Copy link
Copy Markdown
Owner

Summary

  • Add api/src/websocket.js: an RFC 6455 client (masked text frames, fragments, ping/pong, close, 4 MiB message cap) and a JSON-RPC 2.0 session with calls and notification waits.
  • Add jsonRpcChecked and jsonRpcUnchecked to the outbound boundary in proxy.js. The upgrade request reuses the SSRF guard, IP pinning with SNI, resolveSkipTls and one deadline for connect and calls.
  • Expose ctx.jsonRpc to widget data.js, checked unless the fetcher is the saved-config one, inside the widget budget.
  • Disk Health: read TrueNAS pools with auth.login_with_api_key and pool.query on /api/current. Fall back to REST /api/v2.0/pool when the upgrade is refused (TrueNAS before 25.04). Default a bare address to https, refuse http:// before the key is sent, add truenasSkipTls.
  • System Summary: add a truenas source. CPU, CPU temperature and memory from the reporting.realtime event, memory without the ZFS ARC. Pool usage from each pool's top dataset, an empty slot reads the first pool. Uptime from system.info only for the uptime row, null when the key lacks READONLY_ADMIN.
  • Add the new fields to both manifests and all six locales, and TrueNAS to the README source list.

Testing
All green, plus e2e. Added transport tests against a local WebSocket server, and TrueNAS tests for both widgets on a shared fake session; verified against TrueNAS 27.0.0-RC.1 with a key limited to REPORTING_READ, POOL_READ and DATASET_READ.

Changelog

Added

  • TrueNAS as a System Summary source.
  • Allow Self-Signed Certificate for TrueNAS disk health.

Changed

  • TrueNAS disk health reads TrueNAS 25.04 and later over the WebSocket API, so it keeps working on TrueNAS 27.
  • TrueNAS disk health refuses an http address, because TrueNAS revokes an API key sent over http.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.

Add a WebSocket client and JSON-RPC session on Node core HTTP, behind the
outbound guard. Disk Health reads TrueNAS pools over it, with REST kept for
TrueNAS before 25.04. System Summary gains a TrueNAS source. Both refuse an
http address and offer a self-signed certificate switch.
- Mark every pending JSON-RPC call and notification wait as handled, so a
  session that ends with promises nobody awaited does not exit the process.
- End the WebSocket connection when more than 64 KiB of outbound frames
  queue up, so a peer that sends pings and reads no pongs cannot grow memory.
- End the connection on reserved control opcodes, as RFC 6455 requires.
- Store the TrueNAS CPU temperature under the key the System Summary
  temperature slot reads.
- Reject pending waits on close in the fake session, like the real one.
@SandObserver
SandObserver merged commit c6e6b76 into main Oct 23, 2026
6 checks passed
@SandObserver
SandObserver deleted the feat/truenas-websocket-api branch October 23, 2026 05:17
stackyard-release Bot pushed a commit that referenced this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant