Repository navigation
Conversation
…E events Let a single hbbs management endpoint aggregate and control any number of hbbr instances so the console only ever needs one upstream. - /v1/control (WebSocket, hbbs only): hbbr connects outbound with RD_HBBS_API_URL, registers its relay identity, reports heartbeats, session lifecycle events and session snapshots, and receives policy commands; re-registration replaces the previous connection and stale generations are ignored - ban policies now fan out from hbbs to every registered relay on update and on registration; relays persist the forwarded policy locally so it stays active across restarts even when hbbs is unreachable - relay discovery: addresses reported at registration are folded into the live relay server list (static relay-servers plus registered relays) through a service-registered RelaySync callback - new hbbs endpoints: GET /v1/relays (health and aggregation metadata), GET /v1/relays/:id/sessions (aggregated relay sessions) and DELETE /v1/relays/:id/sessions/:uuid (proxied disconnect) - GET /v1/events (SSE): aggregated event stream with peer online/offline, relay session lifecycle, relay registration and policy changes; peer events come from snapshot diffing, so nothing is lost to polling gaps - shared apply_bans_update extracted for the HTTP handler and the relay control channel; sessions_snapshot and disconnect_session reused by both the local endpoints and the control client
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
hashbk
changed the base branch from
master
to
feat/management-api-v2-dynamic-config
October 16, 2026 16:22
…dpoints Management clients talk to hbbs only, so relay-scoped configuration reads and writes, log reads and restarts are proxied over the control channel using request ids and HTTP-equivalent responses. Extract validate_update, apply_config_update and logs_view for reuse by the relay control client, add POST /v1/restart to both services, and cancel pending relay requests when a relay disconnects.
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.
Summary
Second step of the management API v2 rework: a single hbbs management endpoint can now aggregate and control any number of hbbr instances, so the console only ever needs one upstream and one credential. Complements #58 (dynamic config) and is independently mergeable.
GET /v1/control(WebSocket, hbbs only) — whenRD_HBBS_API_URLis set, hbbr opens an outbound WebSocket to hbbs, registers its relay identity (RD_RELAY_ID/HOSTNAME,RD_RELAY_ADDRESS), reports heartbeats (10s), session lifecycle events and session snapshots, and receives policy commands. hbbr never exposes a management listener for aggregation; re-registration replaces the previous connection (generation guard prevents stale sockets from corrupting state), and connections silent for 45s are dropped.PUT /v1/banson hbbs pushes the active policy to every registered relay immediately (and on registration). Relays persist the forwarded policy locally, so it stays active across restarts even when hbbs is unreachable. The 10-second polling reconciliation in the console agent becomes unnecessary.relay-serversplus registered relays) through aRelaySynccallback, reusing the existingData::RelayServers0hot-update channel and the built-in relay health checks.GET/PUT /v1/relays/:id/config,GET /v1/relays/:id/logsforward relay configuration and log reads/writes over the control channel using request ids and HTTP-equivalent responses (status + body are forwarded verbatim, so proxied endpoints keep the semantics of the direct ones; a relay that stays silent fails the request after 10 seconds, and pending requests fail fast when the relay disconnects). The relay control client validates, persists and activates forwarded config updates through the same shared core as its own HTTP handler.POST /v1/restarton both services andPOST /v1/relays/:id/restarton hbbs: the process exits shortly after the response is flushed (202,state: restarting), relying on the supervisor (container restart policy or systemd) to bring it back with persisted configuration applied. Relay restarts are fire-and-forget; the relay re-registers when it comes back.GET /v1/relays(health + aggregation metadata),GET /v1/relays/:id/sessions(aggregated relay sessions),DELETE /v1/relays/:id/sessions/:uuid(proxied disconnect, same202 closingsemantics).GET /v1/events(SSE) — aggregated event stream:peer_online/peer_offline(from snapshot diffing, so short-lived activity is never lost to polling gaps),session_opened/session_closed(withrelay_id),relay_registered/relay_disconnected,bans_replaced; 15s keep-alive.validate_update,apply_config_update,config_viewandlogs_viewextracted for reuse by both the HTTP handlers and the relay control channel;apply_bans_updatelikewise;sessions_snapshot/disconnect_sessionshared by local endpoints and the control client.Test plan
cargo test --lib— 24 passed (new: relay proxy requests incl. status forwarding and fire-and-forget restart, cancellation of pending relay requests)cargo check --locked --all-features --all-targets(CI parity)cargo build --bin hbbs --bin hbbrwith no new warnings