Commit Graph

64 Commits

Author SHA1 Message Date
darroyo cb39df63bc fix: deploy keys StdinPipe order and add structured logging
- sshmanager/deploy.go: StdinPipe() must be called BEFORE Start(),
  not after. Reordered the calls to fix "ssh: StdinPipe after
  process started" error.
- Return DeployResult instead of nil error on SSH dial failure
  so the frontend always gets a parseable response.
- Add slog.Debug for key upload, slog.Warn for ssh-keyscan and
  authorized_keys failures, slog.Info for final result summary.
2026-07-09 20:45:32 -04:00
darroyo be2d2d1a8d Bump version to 1.0.31 2026-07-09 20:38:45 -04:00
darroyo 179b2d8fbd fix: deploy keys modal crash on null/undefined arrays
- sshmanager/deploy.go: initialize DeployResult with empty slices
  instead of nil to prevent null serialization in JSON
- Machines.tsx: use ?? [] fallback for messages and errors arrays
  in deploy keys modal to handle null/undefined gracefully
2026-07-09 20:38:41 -04:00
darroyo c0bf16f132 Bump version to 1.0.30 2026-07-09 20:33:43 -04:00
darroyo ee5372c9fd Bump version to 1.0.29 2026-07-09 20:33:19 -04:00
darroyo dbf998703f feat: add Deploy Keys function to Machines UI
- sshmanager/deploy.go: new DeployKeysToMachine function that uploads
  private keys, populates known_hosts via ssh-keyscan, and adds server
  pub key to authorized_keys on remote machines
- handlers_machines.go: new DeployKeys handler with auto-detection of
  keys needed per sync pair (source->dest uploads dest key, dest->source
  uploads source key)
- router.go: POST /machines/{id}/deploy-keys route
- client.ts: deployKeys() API method
- Machines.tsx: Deploy Keys button + modal with result display
2026-07-09 20:33:04 -04:00
darroyo 5d708e1d7b fix: RunRemote SSH-to-source with pre-installed dest key, eliminating base64 round-trip
- Regenerate qnap.key and baby-nas.key to OpenSSH native format (387 bytes vs 119 PKCS8)
- Pre-install qnap.key on Baby NAS at /var/lib/syncserver/ssh/keys/
- Pre-populate Baby NAS known_hosts with Qnap host keys
- Simplify RunRemote: LXC SSH to Baby NAS, Baby NAS runs rsync with local qnap.key
- Remove wrapper script approach (rsync rejects remote-to-remote)
2026-07-09 20:03:00 -04:00
darroyo 727d8676a6 Bump version to 1.0.27 2026-07-09 18:41:13 -04:00
darroyo f76cdaf140 Bump version to 1.0.26 2026-07-09 18:40:30 -04:00
darroyo afe399d3a9 fix: use git add -f to bypass spurious ignore on cmd/server 2026-07-09 18:40:15 -04:00
darroyo 83cc48e70f Bump version to 1.0.25 2026-07-09 18:30:24 -04:00
darroyo 63e82c502c Bump version to 1.0.24 2026-07-09 18:28:03 -04:00
darroyo cc1519810b chore: stop tracking build artifacts in internal/webui/dist (regenerated by build) 2026-07-09 18:27:46 -04:00
darroyo 3ad22c3dcb fix: show fingerprint approve button even on connection success 2026-07-09 18:27:03 -04:00
darroyo 88cc7e88e6 Bump version to 1.0.23 2026-07-09 17:33:04 -04:00
darroyo be7d47c0e1 Bump version to 1.0.22 2026-07-09 16:54:38 -04:00
darroyo 6c48031dd7 Bump version to 1.0.21 2026-07-09 15:18:05 -04:00
darroyo acd50ec9c0 Bump version to 1.0.20 2026-07-09 15:13:35 -04:00
darroyo 7a70355b6d Bump version to 1.0.19 2026-07-09 15:00:40 -04:00
darroyo 73cad44769 Bump version to 1.0.18 2026-07-09 12:43:13 -04:00
darroyo f92b03c0ce Bump version to 1.0.17 2026-07-09 10:40:23 -04:00
darroyo d7e6d64967 fix: reject + handle remote-to-remote sync pairs
Option A (validation):
- handlers_syncpairs.go: reject create/update when both SourceMachineID
  and DestMachineID are set; clear error message explains the constraint
- engine.go: detect 'both remote' rsync error at runtime and surface it
  as error_code=remote_to_remote_unsupported with a human-readable message

Option B (remote-to-remote support):
- rsync_runner.go: add RunRemote() method that SSHs to the source machine
  and runs rsync locally there (src=local path, dst=user@host:/path),
  streaming output back through the onLine callback
- engine.go: when both srcMachine and dstMachine are non-nil, use
  RunRemote() instead of Run(), SSHing to srcMachine and running rsync
  from there. Also wake dstMachine via WoL when both sides are remote.
2026-07-09 10:40:12 -04:00
darroyo ba4c6aa732 Bump version to 1.0.16 2026-07-09 00:04:56 -04:00
darroyo 7a024cec3b fix: use context.Background() in TriggerRun so job outlives HTTP request
r.Context() is cancelled when the HTTP handler returns (after 201 is sent),
causing the job to be immediately marked as cancelled_shutdown before WoL
even runs. Use context.Background() so the job goroutine runs independently
of the HTTP request lifecycle.
2026-07-09 00:04:44 -04:00
darroyo 48d8fff5df Bump version to 1.0.15 2026-07-08 23:56:05 -04:00
darroyo 1734167f83 fix: SQLite WAL mode + log all swallowed 500 errors
- internal/db/db.go: Use _pragma syntax so modernc.org/sqlite actually
  applies busy_timeout(5000) and journal_mode(WAL). Eliminates SQLITE_BUSY
  500s when concurrent reads hit a writer holding the DELETE-mode lock.
- internal/api/handlers_*.go: Add slog.Error before every writeError with
  StatusInternalServerError so real errors appear in logs (30+ sites across
  handlers_jobs, handlers_machines, handlers_syncpairs, handlers_sshkeys).
2026-07-08 23:55:55 -04:00
darroyo d0fd0e994f Bump version to 1.0.13 2026-07-08 23:36:24 -04:00
darroyo c015a47440 Bump version to 1.0.12 2026-07-08 22:39:08 -04:00
darroyo 58e7f51ba7 fix: EventBus panic on SSE disconnect + JWT secret persistence + recover() guards
- eventbus.go: Fix send-on-closed-channel panic in SubscribeGlobal by
  using a done channel; add recover() in fan-out goroutine; track active
  global subs for proper cleanup on unsubscribe
- config.go: Persist JWT secret to $DATA_DIR/.jwt_secret instead of
  regenerating a random one on every restart (which invalidated all sessions)
- handlers_ws.go: Replace time.After with time.Ticker to fix timer leak in
  SSE keepalive loop
- handlers_jobs.go: Add recover() in fire-and-forget job goroutine; fix nil
  pointer deref when GetByID fails after job creation
- handlers_machines.go: Add recover() in ProbeAllMachines goroutine
- scheduler.go: Add recover() in scheduled job run goroutine
- engine.go: Add recover() in per-machine probe goroutines
2026-07-08 22:38:56 -04:00
darroyo 1798fc6804 Bump version to 1.0.11
Machine status probe on page load:
- POST /api/machines/refresh probes all machines in parallel (max 20 concurrent, 1.5s timeout)
- Updates DB status and broadcasts via SSE to all connected browser tabs
- Server-side throttle: ignores refresh requests within 10s
- Machines.tsx and Dashboard.tsx fire probe on mount
- Visual "Checking machine status..." indicator in Machines table
- MachineHandler now accepts *Engine for ProbeAllMachines access
2026-07-08 21:44:50 -04:00
darroyo a77f84ad34 Bump version to 1.0.10
Smart WoL: TCP pre-check before sending magic packet (3s timeout).
Machine status updates via SSE: online/offline tracked in DB and
broadcast to all connected browser tabs in real-time.
- Pre-check: if machine already reachable, skip WoL and mark online
- WoL path: send 3 magic packets, wait for SSH, mark online/offline
- Backend: setMachineStatus() helper + machine_status SSE event
- Frontend: subscribeMachineStatus() SSE helper for Machines + Dashboard
- IsReachable() helper in wol package for TCP reachability checks
2026-07-08 19:56:08 -04:00
darroyo ad3e879c42 Document build artifacts in AGENTS.md 2026-07-08 19:26:16 -04:00
darroyo fb7b41ddd7 Untrack prebuilt binaries and build artifacts
bin/, server: removed from git tracking (--cached), files remain on disk.
Expanded .gitignore to cover bin/, server, syncserver, .data/.
Build artifacts are regenerated by make clean && make build-all.
2026-07-08 19:25:49 -04:00
darroyo 5d5b6c99a7 Bump version to 1.0.9
Fix Wake-on-LAN: set SO_BROADCAST on UDP socket, send 3 magic packets,
expose broadcast_addr and wake timeout fields in UI, add Test Wake endpoint,
surface send errors in job status, bump default wake timeout to 180s.
2026-07-08 19:19:50 -04:00
darroyo 25a31af64c Make ExecStartPre chown non-fatal to prevent service start failures 2026-07-08 17:42:28 -04:00
darroyo 69c4898a56 Add cancellation reason tracking with user/system codes and UI 2026-07-08 17:31:22 -04:00
darroyo 3c1bbce9e7 Add .tmp/ to gitignore and remove tracked screenshots 2026-07-08 14:33:34 -04:00
darroyo 0c43372e3e Visual fixes: base href, dashboard pair names, edit button 2026-07-08 14:31:41 -04:00
darroyo 9d32ef7fd6 Add job error persistence and friendly error UI
Backend:
- Migration 0003_job_error: adds error_message and error_code columns to jobs table
- models/job.go: add ErrorMessage, ErrorCode fields to Job struct; SetError method; update all SELECT queries
- models/job_log.go: GetAllFiltered also reads error_message and error_code (via Job embed)
- syncengine/engine.go: setJobError() helper; capture errors at Wol timeout (wol_timeout), rsync error (rsync_error), and exit_code failure points
- api/dto.go: add ErrorMessage and ErrorCode to JobResponse
- api/handlers_jobs.go: jobToResp propagates error fields

Frontend:
- api/client.ts: add error_message? and error_code? to Job interface
- lib/status.ts: add ERROR_CODES map with friendly titles/hints; getErrorCodeInfo()
- components/ErrorDetailsModal.tsx: new modal showing error title, hint, full message, job metadata, and stderr log; copy-all and download-log buttons
- pages/JobDetail.tsx: error banner for failed jobs with title/hint; View error button opens ErrorDetailsModal; SSE updates error_message in real-time
2026-07-08 09:04:47 -04:00
darroyo e0e94bd518 Fix: defensive frontend + panic recovery logging middleware
Frontend:
- JobDetail loadLogs: fallback to [] when API returns null
- JobDetail loadJob: pairs ?? [] guard on /api/sync-pairs 500
- JobHistory: Array.isArray guard on job list response
- api client: return undefined for null body instead of throwing

Backend:
- handlers_jobs GetLog: return [] instead of null when no log rows
- router: custom recoverer middleware that logs panics to slog
  with full stack trace, method, and path
2026-07-08 01:28:12 -04:00
darroyo 6d16797c4f Fix known_hosts format: use ssh.MarshalAuthorizedKey
Bug: AddKnownHost wrote raw SSH wire-protocol bytes directly to
known_hosts instead of the OpenSSH authorized-key one-line format.
This produced garbage entries that would break SSH verification
for newly added machines.

Fix: ssh.ParsePublicKey(keyData) + ssh.MarshalAuthorizedKey() to
produce canonical hostkey lines: hostname ssh-ed25519 AAAAB3...xn3c=
2026-07-08 00:44:01 -04:00
darroyo 8d0117399c Fix SSH public key format: use ssh.MarshalAuthorizedKey
Bug: raw ed25519.PublicKey bytes were stored directly instead of
OpenSSH authorized-key format (ssh-ed25519 AAAA... label).

Fixes:
- internal/sshmanager/fingerprint.go: GenerateKeyPair now uses
  ssh.NewPublicKey + ssh.MarshalAuthorizedKey
- internal/sshmanager/keys.go: EnsureServerKey uses same fix; also
  regenerates .pub file from private key if stored value is corrupt
- internal/sshmanager/fingerprint.go: add MarshalED25519PublicKey,
  PublicKeyFromPrivateKeyFile, RegeneratePublicKeyFromPrivateKeyFile
- internal/models/sshkey.go: add UpdatePublicKey
- internal/api/handlers_sshkeys.go: List+Get recover existing DB
  records with corrupt public keys by regenerating from private key
  file and updating the DB

Also adds golang.org/x/crypto/ssh dependency via go mod tidy.
2026-07-08 00:30:57 -04:00
darroyo e322299dc3 Add deploy script with dry-run, retry, rollback and health checks 2026-07-08 00:21:17 -04:00
darroyo b185686d2b Bump version to 1.0.7 2026-07-08 00:05:37 -04:00
darroyo acdb1e3303 fix(Select): remove Icon asChild from Trigger to avoid Slot error
- Radix SelectTrigger composes its children via Slot internally
- Having both {children} and <Icon asChild> caused "Slot failed to slot onto its children"
- Use Radix default Icon instead (rendered automatically)
2026-07-08 00:03:44 -04:00
darroyo 3812b831c9 fix(Button): asChild slot children error
- Separate render paths: asChild uses Slot directly, normal uses button
- Fixes "Slot failed to slot onto its children" runtime error
- Slot now always receives exactly one child (the Link element)
2026-07-08 00:00:01 -04:00
darroyo f5f3b2263e fix(postinst): robust service restart on upgrade
- Always enable service (not conditional on is-enabled)
- try-restart: reinicia si ya estaba corriendo
- start fallback: arranca si quedó inactive después del try-restart
- Covers: fresh install, running disabled, stopped manual, failed
- Like baby-nas but handles the "running-but-not-enabled" edge case
2026-07-07 23:54:08 -04:00
darroyo 1e516cb746 simplify postinst: use try-restart like baby-nas
- Replace if/restart/else/enable with is-enabled && enable; try-restart
- Consistent with baby-nas approach
- Handles failed services gracefully (no auto-recover)
2026-07-07 23:49:52 -04:00
darroyo a79bb29699 fix: service restart on upgrade and no-cache headers for SPA assets
- postinst: restart instead of start if service already enabled (upgrade case)
- embed.go: no-cache/no-store on index.html, immutable cache on hashed assets
- Fixes web not refreshing after dpkg upgrade
2026-07-07 23:41:16 -04:00
darroyo 9cef7173cb Visual redesign: design system, refined ops console aesthetic
- Full component library (Button, Input, Label, Select, Modal, Table, Badge, Card, etc.)
- Tailwind design tokens: IBM Plex Sans + JetBrains Mono, teal accent, semantic status colors
- NavBar with logo, responsive hamburger menu, real logout
- All pages redesigned: Login, Dashboard (KPI cards), Machines, SyncPairs, JobHistory, JobDetail, SSHKeys, Settings
- Fixed: hover:bg-gray-750 dead class, window.location.href navigation bug
- Replaced alert()/confirm() with sonner toasts and accessible modals
- Added ErrorBoundary, skip link, accessible modal dialogs (Radix)
- Icons: lucide-react throughout, copy/download buttons
- 1.0.5 → 1.0.6
2026-07-07 23:12:34 -04:00