Skip to content

feat(server-management): replace node agent with direct server API integration - #425

Open
hashbk wants to merge 1 commit into
mainfrom
feat/direct-server-management
Open

hashbk wants to merge 1 commit into
mainfrom
feat/direct-server-management

Conversation

@hashbk

@hashbk hashbk commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace the intermediary node agent layer with direct Console-to-server API integration. Console now calls hbbs/hbbr management APIs directly, eliminating the agent process, Docker socket mount, and container recreation logic.

Motivation

PR #396 introduced a three-layer architecture: Console → Node Agent → Docker → hbbs/hbbr. The agent was a pure middleman for most operations (status, config, peers, sessions, bans), adding a network hop and failure point with no value. It required Docker socket access (equivalent to host root), used a static RUSTDESK_NODES environment variable for node configuration, and could not natively support the 1 hbbs + n hbbr topology across multiple hosts.

Changes

  • Server registry in database: New ServerNode entity (server_nodes table) with UUID primary key, role (hbbs/hbbr), name, management API URL, and management token. URLs and tokens use select: false to prevent accidental credential exposure. Nodes are managed via CRUD API — no restart needed to add or remove servers.
  • Ban policy in database: New ServerBanPolicy entity (server_ban_policies table) as the single source of truth. PUT /api/servers/bans fans out to all registered nodes and reports per-node applied/pending synchronization.
  • Direct API calls: ServerManagementService calls hbbs/hbbr /v1/* endpoints directly using the registered node's URL and Bearer token. No agent hop.
  • Health monitoring: ServerHealthService with @Interval(30000) polls each server's /v1/status and updates the status (online/offline/degraded) and lastCheckedAt columns.
  • New permission: servers.manage for server registry CRUD operations.
  • Removed: agent/ directory (app.mjs, docker.mjs, index.mjs, schema.json, Dockerfile, tests), RUSTDESK_NODES env var, Docker socket mount, container lifecycle endpoints (start/stop/restart/apply), Docker log endpoint, agent-build CI job.
  • Migration: 1790985600002-AddServerNodes creates server_nodes and server_ban_policies tables for both SQLite and MySQL.

API

Endpoint Methods Permission
/api/servers GET, POST servers.view, servers.manage
/api/servers/:id PATCH, DELETE servers.manage
/api/servers/:id/peers GET servers.view
/api/servers/:id/sessions GET servers.view
/api/servers/:id/sessions/:uuid DELETE servers.disconnect
/api/servers/:id/config GET, PUT servers.config
/api/servers/bans GET, PUT servers.ban

Topology

The create endpoint enforces at most 1 hbbs node and at most 100 total nodes, matching the 1 APIServer + 1 hbbs + n hbbr client constraint.

CI scope

Removed the agent-build job and the node --test agent/*.test.mjs step from the test job. Backend tests cover the direct-connect service, ban fan-out, topology enforcement, and permission requirements. No local compilation, application execution, or tests were performed.

Companion pull requests

  • rustdesk-server#52 — management APIs for hbbs/hbbr (already merged, unchanged)
  • rustdesk-console-web — frontend updates to follow

…tegration

Eliminate the intermediary node agent layer and have Console call hbbs/hbbr
management APIs directly. The server registry is now stored in the database
with a CRUD API instead of a static RUSTDESK_NODES environment variable,
allowing nodes to be added or removed without a backend restart.

Key changes:
- Add ServerNode entity (role, name, url, managementToken, status) and
  ServerBanPolicy entity for persistent ban policy storage
- Add migration 1790985600002 creating server_nodes and server_ban_policies
  tables for both SQLite and MySQL
- Rewrite ServerManagementService to call hbbs/hbbr management APIs directly
  using the registered node's URL and token, removing the ConfigService
  dependency on RUSTDESK_NODES
- Add ban fan-out: PUT /api/servers/bans distributes policy to all registered
  nodes and reports per-node applied/pending synchronization
- Add ServerHealthService with @interval(30000) polling each server's
  /v1/status and updating the status column
- Add servers.manage permission for server registry CRUD operations
- Remove agent/ directory (app.mjs, docker.mjs, index.mjs, schema.json,
  Dockerfile, tests) and the agent-build CI job
- Remove Docker socket mount from the integrated deployment; Console reaches
  hbbs/hbbr management ports over the internal Docker network
- Remove container lifecycle endpoints (start/stop/restart/apply) and Docker
  log endpoint; container orchestration is handled by the deployment layer
- Update integrated Compose to remove the rustdesk-agent service
- Update CI workflow to remove agent tests and agent image build
- Update docs and environment examples for the new architecture
@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6d56a36-8b1a-4694-9c8a-5f1ee18d033f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant