1217 Commits

Author SHA1 Message Date
UNITRONIX 9436e90f8a Fix user ID type mismatch causing broken buttons (#85)
- users.js: Change parseInt(userId, 10) to Number() on both sides of
  comparison to handle BigInt/string/number ID types correctly
- dbAdapter.js: Wrap all lastInsertRowid with Number() to prevent
  BigInt leak from better-sqlite3 v9+ (BigInt === Number is always false)

Root cause: better-sqlite3 v9+ returns lastInsertRowid as BigInt.
If user objects with BigInt IDs ended up in the users array, strict
equality (===) with parseInt result (Number) always fails silently,
making edit/reset-password/delete buttons appear unresponsive.
2026-04-06 21:07:40 +02:00
UNITRONIX a3202515d6 Fix Node.js 20 deprecation and Docker secrets lint warnings
GitHub Actions:
- actions/checkout: v4 -> v6 (Node.js 24 native)
- docker/login-action: v3 -> v4 (Node.js 24 native)
- docker/metadata-action: v5 -> v6 (Node.js 24 native)

Docker lint:
- Add check=skip=SecretsUsedInArgOrEnv to Dockerfile + Dockerfile.console
  (PUB_KEY_PATH and API_KEY_PATH are file paths, not secrets)
2026-04-06 17:19:30 +02:00
UNITRONIX 23567a7042 Update GitHub Actions to Node.js 24 compatibility
- docker/setup-buildx-action: v3 -> v4
- docker/build-push-action: v5 -> v6
- Add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true env var
  (Node.js 20 deprecated June 2, 2026)
2026-04-06 17:09:56 +02:00
UNITRONIX 3a73870706 Fix port 21121 connection refused in Docker (API_HOST binding)
Root cause: config.js defaults apiHost to 127.0.0.1 (localhost-only).
Inside Docker containers, this means port 21121 only listens on the
loopback interface, making it unreachable from outside the container
despite docker port mapping.

docker-compose.single.yml already had API_HOST=0.0.0.0, but
docker-compose.yml (multi-container) and docker-compose.quick.yml
(GHCR pre-built) were missing it.

Fixes:
- docker-compose.yml: Add HOST=0.0.0.0 and API_HOST=0.0.0.0
- docker-compose.quick.yml: Add HOST=0.0.0.0 and API_HOST=0.0.0.0
- Dockerfile.console: Add ENV API_HOST=0.0.0.0
- Dockerfile (single): Add ENV API_HOST=0.0.0.0
- docker/entrypoint.sh: Export API_HOST and HOST defaults
- docker/supervisord.conf: Add API_HOST and HOST to console env

Fixes #78
2026-04-06 17:03:11 +02:00
UNITRONIX 2b61726da6 Fix installer bugs and Go server JSON 404 response
betterdesk.sh:
- Preserve existing .api_key on update (no longer regenerates every time)
- Escape PostgreSQL URI $ -> $$ in setup_services_minimal() for systemd
- Use awk instead of sed for password reset (handles |, &, $ in passwords)
- Fix certbot cron to restart both betterdesk-console and betterdesk-server

betterdesk.ps1:
- Add UTF-8 BOM for PowerShell 5.1 compatibility (fixes Issue #84)
- Replace Unicode chars (em dash, arrow) with ASCII equivalents
- Fix Repair-Services to check betterdesk-server.exe (not legacy hbbs.exe)
- Quote admin password in -init-admin-pass for special character handling

betterdesk-server/api/server.go:
- Add JSON catch-all 404 handler (fixes RustDesk client FormatException)
- Go default HTML 404 broke Dart client JSON parsing (Issue #78)

Closes #84, Addresses #78, Addresses #72
2026-04-06 12:35:01 +02:00
UNITRONIX 05ebd71072 Fix Docker permission denied on console data + remove :ro mount (#78)
Three related issues reported by user:
1. SQLITE_READONLY: docker-compose.quick.yml mounted /opt/rustdesk as :ro
   but console needs read access to .api_key (mode 600). Removed :ro.
2. EACCES .session_secret: Dockerfile.console ran as USER betterdesk
   (UID 10001) but volume files owned by different host UID.
3. docker exec fails: container in restart loop due to permission crash.

Fix:
- Add docker/console-entrypoint.sh: starts as root, chown data dirs
  to betterdesk user, then drops privileges via su-exec
- Add su-exec to Dockerfile.console runtime packages
- Remove USER betterdesk (entrypoint handles privilege drop)
- Remove :ro from /opt/rustdesk volume mount in docker-compose.quick.yml
2026-04-05 22:28:29 +02:00
UNITRONIX c93a8eb546 Fix permission denied on id_ed25519 in Docker volumes (#78)
Root cause: Dockerfile.server ran as USER betterdesk (UID 10001) but
Docker volume files retain UID/GID from host or previous container.
Private key id_ed25519 (mode 600) owned by different UID = unreadable.

Fix:
- Add docker/server-entrypoint.sh: starts as root, chown+chmod volume
  files to betterdesk user, then drops privileges via su-exec
- Add su-exec to Dockerfile.server runtime packages
- Remove USER betterdesk directive (entrypoint handles privilege drop)
- Add explicit chmod 600 + chown for id_ed25519 in all-in-one entrypoint
2026-04-05 21:13:41 +02:00
clarencetw 31b207fa5a Add Traditional Chinese (zh-TW) i18n translations
- Add zh-TW translations for web console, agent client, and MGMT client
- Update VALID_LANG_CODE regex to support BCP 47 tags (e.g. zh-TW)
- Add zh-TW to LANGUAGE_META in i18nService
2026-04-05 21:47:13 +08:00
UNITRONIX 66c46f7d93 Fix SBOM/Trivy GHCR auth for private packages 2026-04-05 14:28:28 +02:00
UNITRONIX e0290794ab Merge branch 'Betterdesk-3.0.0-Alpha' 2026-04-05 13:43:37 +02:00
UNITRONIX dd0889e3d6 Add SessionManager; update docs, i18n & CI
Introduce a SessionManager for relay-based remote sessions in the Tauri MGMT client: new SessionCommand API, start/stop/session input routing, clipboard/recording/quality controls, and notification read/dismiss state. Wire AppState with new mutexes and show main window on startup. CI: add SBOM generation (anchore) and Trivy vulnerability scan steps. Misc: change console Docker DB path, large README/CHANGELOG updates (chat E2E, unattended access/WOL, i18n expansion, CDAP/SDK docs), and many web-nodejs assets/locales/routes/views/services and server-side changes.
2026-04-05 13:42:07 +02:00
UNITRONIX 327f5f123b Add API proxy and multiple UI panels
Introduce a server-side API proxy and cookie-enabled HTTP client in the Tauri backend to bypass WebView CORS/mixed-content limitations and support session-based auth. Cargo.toml enables reqwest cookie_store; AppState and lib.rs build and expose a shared reqwest::Client and register api_proxy and api_clear_session commands. commands.rs implements api_proxy (forwards requests, returns JSON with __status and proper error reporting) and a stubbed api_clear_session.

Add a large set of frontend UI components and features: AutomationPanel, ChatPanel, DataGuardPanel, DeviceDetail, FileTransferPanel, HelpRequestsPanel, NotificationCenter, RemoteView, ServerPanel, SessionHistoryPanel, ToastContainer and a toast store. Update Dashboard and DeviceList to include recent sessions, help requests, device actions/WOL, retry buttons, and an actions menu. Also update layout/Sidebar/Settings, add locale strings (en/pl), and tweak global styles and some web-nodejs assets (desktop widgets, desktop-mode, tutorial, main layout) to support the new panels and behavior.
2026-04-04 12:59:32 +02:00
UNITRONIX f1b4086e6b Restructure mgmt UI: auth, layout, remove panels
Simplify the management app startup and UI: App.tsx now initializes auth and conditionally renders Login or Layout with a minimal Splash. Introduces an auth store and new Login/Layout components, adds DeviceList and Settings components, and updates Sidebar, Dashboard, locales and global styles. Removes the legacy chat window (HTML + entry), the tauri chat window entry, and many panel components that were unused (Activity, Automation, CDAP, ChatWindow, Connection, RemoteAgent, Management, NotificationCenter, Operator, OrgLogin, PasswordDialog, RemoteBadge, RemoteView, ServerPanel, SettingsPanel, SetupWizard, TotpDialog, Toolbar, etc.). Also adds a favicon and updates vite/server config and main entry adjustments to reflect the new streamlined, auth-driven layout.
2026-04-03 01:44:39 +02:00
UNITRONIX be9e65dcae Add MGMT and Agent Tauri clients
Introduce two new desktop apps: betterdesk-mgmt (operator/admin console) and betterdesk-agent-client (lightweight endpoint agent).

Key changes:
- Add complete betterdesk-agent-client scaffold: frontend (index.html, TSX components, i18n, styles, Vite/TS configs, package.json) and Rust Tauri backend (Cargo.toml, build.rs, tauri.conf.json, commands.rs, config.rs, registration.rs, sysinfo_collect.rs, NSIS language file).
- Add betterdesk-mgmt entries and assets (registered in docs) and update repo docs to describe both MGMT and Agent clients.
- Update .github/copilot-instructions.md to reflect MGMT/Agent client split and add detailed TODO/feature lists.
- Update .gitignore to exclude build artifacts for both new Tauri apps.
- Add docs/new_agents/client1.md and docs/new_agents/client2.md.
- Minor changes to server DB files and web-nodejs i18n/asset files.

This commit adds the initial scaffolding and core IPC/registration/diag features for the agent and registers the MGMT client in repository docs; further implementation and testing remain.
2026-04-03 00:41:49 +02:00
UNITRONIX 76e65a808e Create MGMT_CLIENT_PROMPT.md 2026-04-01 23:45:58 +02:00
UNITRONIX fad12703c3 Add topbar shortcuts and slim taskbar UI
Introduce a topbar shortcuts feature with edit mode and drag/drop support, backed by localStorage. Add translations for the new "edit_shortcuts" label across locales and update the main layout to include the shortcuts container and edit button. Rework desktop-mode CSS/JS to replace the previous compact taskbar with a slim full-width taskbar that expands on hover and shows tab-style indicators; update TASKBAR_HEIGHT and taskbar rendering logic. Add drag support to app-drawer tiles for adding shortcuts, implement shortcut rendering/reordering/removal, and fix snap preview assignment order.
2026-03-29 13:00:13 +02:00
UNITRONIX bbf839754e Harden bd-mgmt, API key, and WS security
Add multiple security hardenings across the server and web console: enforce proof-of-possession for /ws/bd-mgmt using Ed25519-signed headers with timestamp/nonce and replay protection (public key binding, canonicalization, storage, verification, and tests); remove legacy API key query param and config-table fallback in favor of scoped api_keys (migrate bootstrap key into api_keys); tighten WebSocket origin handling for relay and signal servers to allow only localhost origins by default unless an explicit allowlist is set; update auth middleware public paths and test helpers to use X-API-Key header; add ensureScopedAPIKey migration and related helpers; add a GitHub Secret Scan workflow and an audit report. Misc: propagate audit logging on bd-mgmt connect/disconnect and validate enrollment public keys during device register.
2026-03-29 01:48:14 +01:00
UNITRONIX 843298daf4 Add Web Remote UI, multi-session tabs & crypto
Introduce a Web Remote experience with multi-session management, UI and security improvements.

Highlights:
- Add i18n keys for web_remote, new_connection, device_id_placeholder and http_warning across locales.
- UI/CSS: replace single viewer with session/tab UI, session tab bar, HTTP/security banners, toolbar repositioning and numerous style additions for multi-tab sessions and warnings.
- devices.js: add a Web Remote action and use BroadcastChannel to attempt adding a session to an existing remote page (fallback to opening a new tab).
- remote.js: large refactor to support multiple concurrent RDClient sessions (SessionInfo), tab creation/switching/closing, shared toolbar syncing, session lifecycle management, reconnect logic and autoplay/overlay handling.
- rdclient: security and robustness enhancements:
  - rdclient/crypto.js: add Ed25519 SignedId verification (verifySignedId, _hexToBytes) and expose signatureVerified metadata.
  - rdclient/client.js: log severity changes, emit encryption/signature warnings, verify server-signed IdPk to detect MITM, expose renderer cursor readiness via events, and reduce stall detection thresholds / quicker recovery.
  - rdclient/renderer.js: notify when remote cursor image is ready so CSS can hide local cursor.
  - rdclient/video.js: improved MSE health checks, dynamic buffer trimming, JMuxer reinitialization for stuck pipelines, switch timing to ~60fps timestamps, and more aggressive playback catch-up behavior.

These changes improve UX for web remote sessions, add security verification against server-signed identity, and make video playback and recovery more robust.
2026-03-28 20:04:49 +01:00
UNITRONIX 3af0be1a10 Add desktop layout overlay & operator session API
Introduce a dedicated desktop layout overlay and auto-arrange features plus operator session endpoints. UI changes: add BD_icon_small.png, update .gitignore, add new overlay styles in desktop-mode.css, and rename widget snap CSS classes in desktop-widgets.css to avoid conflicts. JS updates: implement open/close layout overlay, autoArrangeWindows, shouldReserveTaskbarSpace, improved taskbar hide/toggle logic, and expose layout APIs from DesktopMode; widgets will call DesktopMode.openLayoutOverlay when available and otherwise use the widget picker. Backend changes: add requireOperatorRole middleware, helpers (normalizeSessionAction, toTimestamp, buildSessionHistory), enforce operator/admin checks on device/help-request endpoints, and add POST /api/bd/operator/sessions and GET /api/bd/operator/sessions to record and retrieve operator session history with input validation and duration computation.
2026-03-28 02:13:48 +01:00
UNITRONIX af28d0d766 Add draggable zone borders, access policies, WOL fix, i18n 2026-03-28 00:08:42 +01:00
UNITRONIX d39110b2ae Add tests, i18n updates, chat & remote fixes
Add unit tests and test helpers (5 suites, 41 tests) and test npm scripts; introduce deviceStatusPush service and WS real-time device status push integration. Fix chatRelay to acknowledge connections (send `welcome`), and apply multiple web remote/rdclient fixes (video ack/timing, keyframe refresh, SourceBuffer trimming, input focus handling) to improve FPS and control. Add new server route file (system.routes.js), new device-status service, update server.js and package.json, and modify various frontend CSS/JS/views. Update English and Polish locale files with many new widget/i18n keys and remove the Russian locale file (ru.json). Also include assorted UI/desktop-widget dashboard tweaks and documentation status updates in .github/copilot-instructions.md.
2026-03-27 00:34:12 +01:00
UNITRONIX 22c7946e74 Refactor desktop widgets UI; add edit/reset
Add localization keys (en/pl) for uptime and widget actions. Update widget CSS to position panels absolutely, improve scrolling behavior and layout containment. Simplify desktop mode JS by removing the start menu, taskbar console button and clock logic, and related markup in main layout. Adjust canvas sizing math to match new topnav/sidebar dimensions and replace many sidebar route buttons with Edit/Reset actions; implement edit-mode toggle and a reset that clears stored layout and re-initializes widgets. These changes streamline the desktop/widgets UX and fix layout/scrolling issues.
2026-03-25 21:39:21 +01:00
UNITRONIX 95f2beb744 feat: organizations, desktop mode, i18n (ja/ko/ru), security docs, client i18n integration 2026-03-25 20:27:04 +01:00
UNITRONIX 3e3f6748db Add chat API, management WS, and DB support
Introduce persisted chat features and a BetterDesk desktop management WebSocket channel. Adds new REST chat handlers (history, send, read, unread, contacts, groups), bd-mgmt WebSocket and management REST endpoints, and routes in the HTTP server. Extend Database interface and models (ChatMessage, ChatGroup, ChatContact) and implement schema migrations + CRUD for PostgreSQL and SQLite. Adjust auth middleware to allow /ws/bd-mgmt/* and relax server WriteTimeout / increase IdleTimeout to accommodate long-lived WS connections. Also add a 3.0 roadmap document and minor frontend/localization/service updates related to chat and relay.
2026-03-25 06:40:42 +01:00
UNITRONIX 99afeecd95 Remote: use /remote-desktop and harden relays
Update client links to open the remote-desktop UI (replace /remote/ with /remote-desktop/). In remoteRelay: transform viewer 'input' frames into the agent's expected InputEvent shape (map event_type -> type) before forwarding, and decode+validate the agent device ID on WebSocket upgrade (reject malformed IDs) to reduce path-traversal/abuse risk. In bdRelay: simplify upgrade handling so this handler only processes /ws/bd-relay and /ws/bd-signal paths and otherwise yields to other upgrade handlers, avoiding manual delegation. These changes improve compatibility, security, and routing correctness.
2026-03-24 01:06:27 +01:00
UNITRONIX 1e2047c033 BetterDesk 3.0.0 Alpha 2026-03-24 00:26:25 +01:00
UNITRONIX 9c3631c1e8 Disable API TLS, escape $ in systemd, fix ports
Prevent breaking RustDesk clients by keeping the API port HTTP-only and removing automatic API TLS: update APITLSEnabled logic (config.go) and remove/add-removal of -tls-api / -force-https from install scripts and service updates (betterdesk.sh, betterdesk.ps1). Fix systemd escaping for admin password and PostgreSQL URL by converting $ → $$ before writing ExecStart/Environment so credentials with $ are preserved. Add MainThread to port diagnostic patterns to avoid false positives for Node.js on newer Linux (betterdesk.sh). Also include minor struct/tag formatting and response key alignment in CDAP Go code and update changelog and copilot instructions. These changes restore client compatibility, harden installer/service writes, and improve diagnostics.
2026-03-21 00:20:53 +01:00
UNITRONIX a957f3fe2a Add CDAP gateway & redesign devices UI
Introduce full CDAP subsystem and devices UI overhaul. Adds a new CDAP WebSocket gateway (cdap/gateway.go) with auth, connection lifecycle, message loop, heartbeat monitor and APIs (cdap/api.go, cdap/auth.go, cdap/handler.go, cdap/manifest.go, cdap/messages.go). Wire CDAP into the server (api/server.go + handlers in api/cdap_handlers.go) exposing REST endpoints for status, device list, info, manifest, state and sending commands. Enhance peer handling: CDAP-connected overlay in peer list/get, device revocation/cascade support in handleDeletePeer (blocklist, connection teardown, events + audit), and new audit action ActionPeerRevoked. Frontend updates include CDAP device page, widgets, commands, styles and services; major devices page UI redesign (responsive folder chips, toolbar, slim table, kebab menu) plus related CSS/JS/views, translations, docs and assets. Overall adds CDAP features, revocation workflow, and a responsive devices UI.
2026-03-20 02:01:48 +01:00
UNITRONIX 98209249f3 Fix ForceRelay UUID mismatch; add GHCR notes
Change ForceRelay TCP path to return a PunchHoleResponse with NatType=SYMMETRIC instead of sending a server-generated RelayResponse, so clients will send RequestRelay with their own UUIDs and both sides use the same UUID (resolves relay pairing mismatch, Issue #66). Add diagnostic log.Printf calls in handleRequestRelay (UDP) and handleRequestRelayTCP to aid relay pairing debugging. Update docs and CI: add GHCR "pull access denied" troubleshooting and package visibility guidance to DOCKER_QUICKSTART.md, docker-compose.quick.yml, and the docker-publish workflow summary (addresses Issue #67). Also update changelog entry in .github/copilot-instructions.md and add related files to .gitignore.
2026-03-19 22:41:24 +01:00
UNITRONIX 511971b3ce PS1 RNG fix and Rust→Go upgrade detection
Replace .NET 6-only RandomNumberGenerator::Fill() with RNGCryptoServiceProvider.GetBytes() in betterdesk.ps1 to restore API key generation on Windows PowerShell 5.1 (fixes issue #38). Add Rust→Go upgrade detection and handling to both betterdesk.ps1 and betterdesk.sh: detect SERVER_TYPE=rust, warn users that migration requires a fresh install, redirect in auto mode or prompt interactively, and avoid a broken upgrade path from legacy Rust (hbbs/hbbr) to the Go server (addresses issues #66 and #38). Update .github/copilot-instructions.md changelog and last-updated footer to document the changes.
2026-03-19 17:55:46 +01:00
UNITRONIX 2d6b730f99 Add Docker quickstart and GHCR publish workflow
Add Docker quickstart flow and CI to publish images to GitHub Container Registry. Creates a new GitHub Actions workflow (.github/workflows/docker-publish.yml) that builds multi-arch images (server, console, all-in-one) and pushes to ghcr.io. Adds docker-compose.quick.yml using pre-built GHCR images and a DOCKER_QUICKSTART.md with a 30s one‑line quick start, troubleshooting, and configuration notes. Update README Docker section to surface the quick start and adjust docker-compose.yml header to reference the quick file. Also update .github/copilot-instructions.md to document the Docker quick start and publishing phase.
2026-03-19 06:47:18 +01:00
UNITRONIX 199a321fe5 Add peer metrics, PATCH updates & relay fixes
Introduce peer metrics persistence and partial peer updates, plus relay UUID recovery and soft-delete protections.

- DB: add PeerMetric type and new Database methods (SavePeerMetric, GetPeerMetrics, GetLatestPeerMetric, CleanupOldMetrics, UpdatePeerFields, IsPeerSoftDeleted). Add peer_metrics table and indexes in SQLite and PostgreSQL migrations; implement all methods for both backends.
- API: handleClientHeartbeat now parses cpu/memory/disk and saves metrics; new endpoints PATCH /api/peers/{id} to update note/user/tags and GET /api/peers/{id}/metrics for historical metrics. handleSetPeerTags now accepts either string or array JSON payloads. Added audit.ActionPeerUpdated.
- Signal server: add pendingRelayUUIDs store (with TTL cleanup, store/get helpers) to recover missing UUIDs from old clients when RelayResponse contains empty uuid; store pending UUIDs when forwarding RequestRelay/PunchHole. Add IsPeerSoftDeleted checks to reject re-registration of soft-deleted devices.
- Node.js panel: betterdeskApi.setPeerTags now sends tags as array and exposes updatePeer() for PATCH; serverBackend.updateDevice routes note/user updates through Go PATCH endpoint and preserves local auth.db writes as fallback; devices.routes deletes now call cleanupDeletedPeerData.
- dbAdapter: add cleanupDeletedPeerData implementations for SQLite and Postgres to remove related auth.db rows when a peer is deleted.

These changes fix zombie device re-registration, ensure metrics are stored & retrievable, centralize peer metadata updates through the Go API, and recover relay pairing failures with legacy clients.

Co-Authored-By: boruto79 <176351662+boruto79@users.noreply.github.com>
Co-Authored-By: БлагоЯр <3672314+blagoyar@users.noreply.github.com>
2026-03-18 22:09:48 +01:00
UNITRONIX c461a1aa13 Improve web client cursor, video and input handling
Fix several stability and UX issues in the web remote client: prevent ImageData crashes by validating and normalizing cursor bytes (skip zstd/compressed or truncated data) and wrapping updateCursor in try/catch; avoid unhandled promise rejections by adding a .catch() around renderer.updateCursor calls; reduce JMuxer-induced stutter and unnecessary seeks by increasing seek thresholds and offsets and tuning health-check intervals/playback-rate logic; send preferred FPS to the peer after login (default 30fps) and negotiate supported codecs dynamically based on WebCodecs/JMuxer availability; ensure focus management after login (blur hidden password input and focus canvas) and toggle a .streaming CSS class on the viewer container for cursor visibility. These changes improve robustness against malformed cursor payloads, reduce playback stutter, and improve input focus behavior.
2026-03-17 00:41:59 +01:00
UNITRONIX 9ff8968e3f Make API TLS opt-in via --tls-api flag
Fix automatic API HTTPS behavior by making HTTP API TLS opt-in. Add TLSApi config field, APITLSEnabled() helper and --tls-api CLI flag (implied by --force-https). Use APITLSEnabled() in api/server.go so the API stays HTTP unless explicitly requested, avoiding Node.js -> Go HTTPS handshake errors with self-signed certs. Update logging to show API scheme, and add TLS API handling across installers and scripts: betterdesk.sh and betterdesk.ps1 now only enable -tls-api and switch .env/API URLs to https for proper (non-self-signed) certs; self-signed certs keep API on http while still enabling TLS for signal/relay. Also update diagnostics to detect --tls-api/--force-https, remove stale legacy services, and add migration-tool auto-compilation and basic version validation.
2026-03-17 00:09:25 +01:00
UNITRONIX 352d85a0a2 Preserve auth/keys and harden installer services
Stop wiping credentials on update and make service setup more resilient. Changes:
- Preserve existing .api_key, admin credentials and auth.db during updates in betterdesk-docker.sh; only regenerate on fresh installs.
- Preserve SESSION_SECRET, DEFAULT_ADMIN_PASSWORD and avoid removing auth.db on updates in betterdesk.sh and betterdesk.ps1; only force-reset on fresh installs via sentinel file.
- Add safety-net re-read of .env in Linux and Windows Setup-Services to recover PostgreSQL config (prevents PG→SQLite regression).
- Remove legacy Flask betterdesk-api service cleanup (systemd/NSSM) and propagate DB_TYPE/DATABASE_URL to NSSM env.
- Detect node binary dynamically in systemd service and route stdout/stderr to journal (SyslogIdentifier set) for better logs.
- Fix Windows update/service flow (Do-Update now calls Setup-Services) and Repair-Binaries checks for betterdesk-server.exe with hbbs.exe fallback.
- Update .github/copilot-instructions.md summary to reflect these installer stability fixes.
2026-03-16 23:34:35 +01:00
UNITRONIX 3390c75547 Fix relay empty-UUID & Docker apk retries
Generate a UUID when RequestRelay/RelayResponse messages contain an empty uuid to prevent relay pairing failures (updates in signal/handler.go: handleRequestRelay, handleRequestRelayTCP, handleRelayResponseForward). Add validation in config.GetRelayServers to reject obviously invalid/too-short hosts (prevents relay entries like "a:21117"). Add retry wrappers to apk add commands in Dockerfile, Dockerfile.server, and Dockerfile.console to work around transient DNS failures during image builds. Update changelog (.github/copilot-instructions.md) with these fixes and related notes.
2026-03-16 23:00:14 +01:00
UNITRONIX 60657da980 Add Address Book API, relay env & UI fixes
Implement address book support and related fixes: add address_books table and Get/SaveAddressBook to DB interface with SQLite/Postgres migrations and upsert, add handlers for /api/ab, /api/ab/personal and /api/ab/tags (GET/POST) and normalize/limit incoming data. Signal server: generate relay UUIDs, send RelayResponse (with UUID and signed PK) and forward RequestRelay to targets to ensure hbbr pairing. Docker/compose/supervisord/entrypoint: introduce RELAY_SERVERS env, expose it in Dockerfile and supervisord, add docker-compose hint, and add entrypoint auto-detection/warnings for public IP inside containers. Web UI fixes: align settings password field names and include confirmPassword, modal input supports inputType, fix change-id request body key, add i18n strings for device actions/errors, and improve device delete route error handling. Also update changelog (.github/copilot-instructions.md) and add some API logging and validations.
2026-03-16 22:30:44 +01:00
UNITRONIX a594f2e737 Align AllowedWSOrigins struct spacing
Adjust whitespace in the Config struct (betterdesk-server/config/config.go) to align the AllowedWSOrigins field with neighboring fields for improved readability. No functional change.
2026-03-15 20:30:58 +01:00
UNITRONIX 8a7fd86424 Fix relay IP detection, logging, and build scripts
Call startIPDetectionRetry and improve public IP detection to avoid returning an unusable bare :port; prefer LAN IP and log clear warnings when no public IP is available. Add retry goroutine (60s ticker) and extend detectPublicIP with HTTPS then HTTP fallbacks and longer timeout. Throttle frequent sysinfo log messages (per-device 5min cooldown) in heartbeat handler to prevent spam. Accept numeric IDs from RustDesk by coercing host_id/host_uuid/peer_id to strings in /api/audit/conn to fix 400 errors. Add force-recompile logic to PowerShell and shell install/update scripts so binaries are rebuilt when sources are newer (and expose ForceRecompile flag). Minor docs and .gitignore updates.
2026-03-15 19:50:57 +01:00
UNITRONIX e548f207bb Auto-generate API key + runtime reload on 401
Fix Docker single-container auth gap by ensuring an API key exists and is discoverable by both the Go server and Node.js console. Changes:
- betterdesk-server/main.go: loadAPIKey() now checks the server_config DB entry and, if absent, auto-generates a 32-byte hex API key, writes it to .api_key (with logging) and continues to sync to the DB.
- docker/entrypoint.sh: generates/persists a 32-byte hex API key at container startup (uses openssl with /dev/urandom fallback) and writes API_KEY env to file if provided.
- web-nodejs/services/betterdeskApi.js: adds fs import and an Axios 401 interceptor that reloads .api_key from disk once and retries the failed request to handle race conditions where the Go server generates the key after Node cached an empty value.
- .github/copilot-instructions.md: documents the Docker API key auto-generation (Phase 16) and related fixes.
- tasks/lessons.md and tasks/todo.md: add lightweight triage notes and actions.
This resolves the issue where the Devices page returned empty results due to missing X-API-Key in the single-container Docker setup and improves resilience during first-run key generation.
2026-03-15 19:20:11 +01:00
UNITRONIX 5b4408a190 Harden API/installer security & opt-in creds
Security hardening and installer fixes across the Go API, installers and Node console.

Key changes:
- WebSocket: removed InsecureSkipVerify and added API_WS_ALLOWED_ORIGINS allowlist (parsed in config) used by the API events WS endpoint.
- Node.js console: added HOST and API_HOST envs and used apiHost in the server; docker-compose and installer templates updated accordingly.
- Admin credentials: plaintext .admin_credentials persistence is now opt-in via STORE_ADMIN_CREDENTIALS (default false); installers and reset flows no longer persist creds unless explicitly enabled.
- Installer hardening: added sql_escape_literal for safe SQL literals, PostgreSQL identifier validation, and safer CREATE/ALTER/psql invocations; API key and password updates now pass secrets via environment variables to Python/Node fallbacks to avoid unsafe shell interpolation.
- Docker compose/scripts: preserve_compose_database_config to keep DB mode during regen, escaped API key insertion into sqlite, and various compose generation formatting fixes.
- Go toolchain & checks: go.mod toolchain set to go1.26.1 and installers now reject known-vulnerable Go 1.26.0 stdlib.
- Dependency: bumped web-nodejs tar override to ^7.5.11.

These changes reduce attack surface for cross-origin WS usage, eliminate unsafe credential persistence by default, and harden installer DB operations and password reset paths.
2026-03-15 14:53:55 +01:00
UNITRONIX a85e3cb557 Add get_public_ip and relay fixes
Add a reusable get_public_ip() to betterdesk.sh and betterdesk-docker.sh (prefers IPv4) and replace inline curl-based IP detection with calls to it. Warns when a private/loopback IP is detected and adds RELAY_SERVERS env var override in both shell and PowerShell installers to allow manual public-IP configuration. Update betterdesk-server/config.GetRelayServers() to auto-append the default relay port when missing and correctly handle IPv6 addresses using net.SplitHostPort/net.JoinHostPort. Update documentation (.github/copilot-instructions.md) and last-updated note. Addresses Issue #58 and improves relay compatibility.
2026-03-15 13:49:08 +01:00
UNITRONIX d29106ed3c Add SIGNAL_PORT and avoid port 5000 conflict
Fix port collision between Node.js console (PORT=5000) and Go signal server by introducing SIGNAL_PORT with higher precedence. Changes:
- betterdesk-server/config/config.go: prefer SIGNAL_PORT over PORT when setting SignalPort.
- Dockerfile: add ENV SIGNAL_PORT=21116 default.
- docker/entrypoint.sh: export SIGNAL_PORT with default 21116 before supervisord start.
- docker/supervisord.conf: set SIGNAL_PORT=21116 in Go server environment.
- .github/copilot-instructions.md: document the root cause and fixes; update last-modified date.
This prevents EADDRINUSE races in the single-container Docker setup while keeping multi-container setups unaffected.
2026-03-15 13:19:19 +01:00
UNITRONIX 5676c6c65a Update TLS env handling and fix peer stats
Make the installer enable and propagate HTTPS settings to the Node.js console and systemd services when self-signed TLS certs are generated. Adds Update-EnvForTLS (PowerShell) and .env updates (bash) to set HTTPS_ENABLED, SSL_CERT_PATH, SSL_KEY_PATH, NODE_EXTRA_CA_CERTS and switch local API URLs to https. Systemd unit generation and do_configure_ssl now inject/sync HTTPS and cert paths (and NODE_EXTRA_CA_CERTS for self-signed CAs). Also fix a bug in web-nodejs/dbAdapter.getPeerStats by computing the total peer count so offline is calculated correctly.
2026-03-14 23:20:01 +01:00
UNITRONIX fc943e808d Streamline Docker builds, add .dockerignore
Add .dockerignore to trim Docker build context and exclude local artifacts (node_modules, dev files, secrets, runtime DBs, etc.). Simplify Dockerfiles: remove unnecessary sqlite-dev and rely on better-sqlite3's bundled SQLite; use npm install --production in build stages; copy application files first then overlay compiled node_modules from the builder to avoid local node_modules clobbering Alpine-compiled native modules. Update Docker console image similarly. Change supervisord to log to /dev/stdout and /dev/stderr so logs appear in docker logs. Remove explicit compose 'version' keys. Also set SQLite busy_timeout for main and auth DBs to reduce locking errors during concurrent access.
2026-03-14 23:05:02 +01:00
UNITRONIX 82475de81d Disable CGO, use DB_URL env for DB config
Switch Go builds to CGO_ENABLED=0 and remove system SQLite build deps and static extldflags (modernc.org/sqlite is pure-Go). Remove hardcoded -db flags from server CMD/supervisord and introduce a DB_URL environment variable propagated from entrypoint.sh. entrypoint.sh now sets DB_URL based on DB_TYPE/DATABASE_URL (Postgres or SQLite) and prints the chosen DB, and supervisord is updated to inject DB_URL into the server process. docker-compose files and docs updated to default to SQLite, expose DB_TYPE/DB_URL configuration, and document using a .env or postgres profile for PostgreSQL setups.
2026-03-14 18:45:31 +01:00
UNITRONIX e90a52a5e1 Await auth token validation calls
Make authenticateRequest and requireAuth async and add await before authService.validateAccessToken across multiple routes (e.g. /api/ab, /api/audit, /api/users, /api/peers, /api/currentUser). Also await authService.revokeClientTokens during logout. These changes ensure promised-based token validation is awaited to avoid race conditions and incorrect auth behavior.
2026-03-14 18:31:22 +01:00
UNITRONIX 6785063faa Serialize TOTP recovery codes before saving
Convert recovery code arrays to JSON strings before storing in the database to ensure consistent storage across adapters. Updates enableTotp and useRecoveryCode in both SQLite and Postgres adapters (web-nodejs/services/dbAdapter.js) to stringify arrays while leaving existing strings untouched.
2026-03-14 12:20:18 +01:00
UNITRONIX 556fad94bf Validate SQL identifiers and safer CPU parsing
Add safeIdentifier checks to SQLite code paths to validate table/column names (letters, digits, underscores, max 64 chars) and guard PRAGMA queries in betterdesk-server/db/sqlite.go and tools/migrate/main.go to reduce injection/invalid identifier risks. Replace a complex CPU regex in web-nodejs/routes/rustdesk-api.routes.js with a comma-split parsing approach to avoid ReDoS/backtracking and more robustly extract name, GHz and core counts. Also add clarifying comments in the Dockerfile about supervisord running services as non-root 'betterdesk' user.
2026-03-14 02:26:45 +01:00
UNITRONIX ccc12145cf Detect IPv6-only relay and prefer IPv4
Add IPv6-only relay detection to the installers (betterdesk.sh and betterdesk.ps1). If the public IP is IPv6, the scripts attempt to resolve an IPv4 address and prefer it for relay compatibility, emitting warnings if no IPv4 is found. Also add a Troubleshooting doc section explaining the "Relay Connection Failed (IPv6)" issue, how to check and fix RELAY_SERVERS, and note the auto-detection behavior as of v2.4.0.
2026-03-13 23:31:29 +01:00