feat(cluster): LAN auto-discovery + unified read-only fleet view (v2.5)#18
Merged
Conversation
added 4 commits
June 11, 2026 21:54
Nodes on the same network discover each other via signed UDP broadcast beacons (HMAC over a shared key; no mDNS) and one node aggregates every node's mappings into a single read-only table on the dashboard, each row tagged with its host (name + IP). - app/engine/cluster.py: ClusterDiscovery — asyncio UDP beacon/listener, HMAC-signed beacons, TTL-pruned peer table, server-side peer fetch. - config: ClusterSettings (enabled/key/discovery_port/advertise_ip) + persisted instance_id; opt-in, off by default (needs enable + shared key). - web: GET /api/cluster/local (shared-key guarded, in PUBLIC_PATHS) and GET /api/cluster/status (session-authed, fans out to peers); Settings -> LAN cluster section; dashboard panel + _cluster_body.html unified table. - tests/test_cluster.py: beacon sign/verify, wrong-key/forged rejection, self-ignore, TTL expiry, key-guarded endpoint, aggregated table. - docs: README (TR/EN) + ROADMAP; version bumped to 2.5.0.
A wedged test must fail loudly with its partial output instead of hanging the CI job to the 6-hour runner limit. Caps each test at 240s (longest real test ~7s) and adds a missing request timeout in the cluster test.
…3.12 Python 3.12 changed asyncio.Server.wait_closed() to block until every active connection finishes (3.11 returned immediately). The Modbus gateway/poll tests called bare `await server.wait_closed()` with a live handler connection still open, hanging py3.12 CI to the 6-hour runner limit (3.10/3.11/3.13 passed). Wrap each wait_closed() in asyncio.wait_for(timeout=2), matching how the engine (modbus_gateway.py / bridge.py) already guards its own shutdown. Pre-existing on main; surfaced now that run_all enforces a per-test timeout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Install ser2net on several machines on the same LAN, open any one of them, and see every node's mappings in one read-only table — each row tagged with the host it belongs to (name + IP). Requested feature: nodes find each other and show each other's mappings.
How it works
cluster.discovery_port(default 41750), signed with HMAC-SHA256 over a shared cluster key. Only same-key nodes trust each other; mismatched/forged beacons are dropped. Peers expire after 20s of silence. (app/engine/cluster.py)GET /api/cluster/statusfans out to each discovered peer'sGET /api/cluster/local(guarded by the shared key, not a session), then renders the unified table. Remote rows are read-only with an Open link to that host's UI; local mappings stay fully managed on the normal dashboard.Scope
Read-only federated view (per the agreed design). Remote control (start/stop/edit a peer's mappings from one screen) is the next ROADMAP item.
Tests
tests/test_cluster.py(added to the portable suite): beacon sign/verify, wrong-key + forged-beacon rejection, self-ignore, TTL expiry, key-guarded endpoint (403/403/200), and the aggregated table showing host + mapping. Full suite: 32/32 pass.Notes
cluster,instance_id) round-trip throughconfig.json; absent on old configs → cluster simply stays off.