Commit Graph
15 Commits
Author SHA1 Message Date
MrFastwind 4d6f162b8f fix: code quality, memory safety, and install improvements
Critical fixes:
- Fix Dockerfile: reorder stages so frontend assets embed into Go binary
- Fix Go version 1.25 (nonexistent) to 1.24 across Dockerfile, go.mod, CI
- Add graceful game server shutdown on SIGTERM/SIGINT
- Order startup tasks: updates complete before auto-start
- Fix TOCTOU race in UpdateSettings with atomic Update() method

Security:
- Add optional AUTH_TOKEN bearer auth middleware on API/WS routes
- Fix path traversal in DeleteMod using filepath.Rel instead of HasPrefix
- Add input validation for IPPort, ServerParameters, ScheduledUpdate

Memory safety:
- Cap RPT buffer allocation to 64KB to prevent OOM on large logs
- Cap GetLog file read to 10MB
- Fix context cancel leak in SteamCmdManager.run()
- Remove data-raced cancel field in steamcmd.go
- Atomic file writes (write-temp-then-rename) across all managers

Reliability:
- Log save errors in ProcessManager.Stop()
- Atomic file writes prevent corruption on crash

Tests:
- Add mod_manager_test.go (12 tests: ListWorkshopMods, ListLocalMods,
  BuildUsageMap, RemoveMod, dirSize)
- Add scheduler_test.go (6 tests: Start/Stop, Refresh with empty,
  invalid, valid, and replaced cron expressions)
- Add TestRestart to server_process_test.go

CI/Docs:
- Add -race flag to go test in CI and Makefile
- Add npm lint step to CI
- Add Go/npm module caching to CI
- Update README: prerequisites, AUTH_TOKEN/GIN_MODE/SERVERS_DIR docs,
  fix manual quickstart to use make build
2026-07-25 02:47:04 +02:00
MrFastwind 8bf163a931 fix(backend): fix memory leaks and resource issues in logs system
CI / build (push) Successful in 1m18s
- Fix Subscribe overwriting channel without closing old one (goroutine leak)
- Add context.Context to Stream() for cancellation support
- Add WebSocket read pump to detect dead clients (StreamLogs, StreamSteamCMDLogs, StreamRPTLogs)
- Use defer f.Close() pattern in StreamRPTLogs file handling
- Fix findLatestRPT nil dereference on failed os.Stat
- Optimize findLatestRPT to collect stat results before sorting
- Apply gofmt formatting to modlists.go, settings.go
2026-07-24 16:25:09 +02:00
MrFastwind 6f3175ac9a feat: add Wine Z: path prefix for Windows platform on Linux host
CI / build (push) Successful in 1m44s
- Add winePath helper that prepends Z: when platform is windows on Linux
- Thread platform through buildModPath, buildAutoArgs, and Start()
- Apply Z: prefix to -config=, -mod=, -profiles=, and %command% binary paths
- Add tests for winePath, buildAutoArgs, and buildModPath with platform param
- Fix formatting across services package with gofmt
- Include all prior bug fixes from this branch
2026-07-24 03:57:51 +02:00
MrFastwind 930b6cbca6 test(backend): add RPT log output to server stub
- Stub now parses -profiles= arg and writes RPT entries to
  profilesDir/arma3server_x64_<timestamp>.rpt
- RPT includes header (exe timestamp, computer name, OS) and periodic
  entries (MissionEditor, World, Server: Player) on each heartbeat cycle
- New test TestStart_StubWritesRPTLog verifies RPT file creation and
  content via the profiles directory
2026-07-23 21:20:53 +02:00
MrFastwind 04882b3c80 test(backend): enhance stubs with logging, heartbeat, timed exit, and fake downloads
arma3server_x64 stub:
- Logs binary path and all arguments ([STUB] binary=... args=...)
- Prints heartbeat every 5 seconds
- Accepts -t N flag to exit after N seconds (for auto-exit tests)

steamcmd stub:
- Parses +force_install_dir and +workshop_download_item args
- Creates fake mod directories at the expected workshop content path
- Prints fake download progress and success logs

New tests:
- TestStart_StubLogsArgsAndPath: verifies arg logging via log streamer
- TestStart_StubLogsBinaryPath: verifies binary path logging
- TestStart_StubHeartbeatLogs: verifies heartbeat lines appear within timeout
- TestStart_StubAutoExit: verifies -t flag causes server to auto-exit
- TestDownloadMods_StubCreatesModDirs: verifies single mod dir creation
- TestDownloadMods_StubCreatesMultipleModDirs: verifies multi-mod dir creation
- TestDownloadMods_StubLogsAppear: verifies fake download logs on channel
- TestDownloadMods_StubSteamcmdArgsLogged: verifies install_dir logging
2026-07-23 21:07:49 +02:00
MrFastwind 234116e6a1 test(backend): add tests for SERVER_BINARY, SERVER_PARAMS, STEAMCMD_PATH env vars
- TestStartWithServerBinaryEnv: custom binary name via env
- TestStartWithServerParamsEnv: overridden params via env
- TestServerParamsEnvOverridesSettings: env takes precedence over settings
- TestSteamCmdManager_SteampathEnv: custom steamcmd path via env
2026-07-23 20:39:24 +02:00
MrFastwind 03c3d7bae2 feat: add SERVER_BINARY, SERVER_PARAMS, STEAMCMD_PATH env vars
- ProcessManager.Start() reads SERVER_BINARY and SERVER_PARAMS from env
  with platform-based defaults as fallback
- SteamCmdManager.run() reads STEAMCMD_PATH from env, defaults to
  'steamcmd'
- Makefile: add SERVER_BINARY/SERVER_PARAMS/STEAMCMD_PATH variables,
  copy stubs to dev-deploy in 'make dev', pass env vars to backend
- .gitignore: add bin/
2026-07-23 20:31:38 +02:00
MrFastwind bc23ad7daa test(backend): add process manager and steamcmd tests with stub scripts
- server_process_test.go: 16 tests covering splitArgs, hasArgPrefix,
  buildAutoArgs (config/port/profiles), buildArgs, resolveModPath (name/
  ID/empty), buildModPath, WriteUserconfigFiles, Start/Stop lifecycle,
  percent-command substitution
- steamcmd_test.go: 9 tests covering CheckWorkshopMod (directory/file/
  empty), SteamCmdManager state machine, DownloadMods/UpdateGame
- testdata/: stub arma3server_x64 and steamcmd scripts for safe process
  testing without real binaries
2026-07-23 20:23:31 +02:00
MrFastwind 6e628a0bba fix(backend): replace mutex with atomic state machine in ProcessManager and SteamCmdManager
- ProcessManager: atomic.Int32 state enum (idle/starting/running/stopping)
  eliminates race between IsRunning check and Start/Stop
- SteamCmdManager: atomic.Bool with CompareAndSwap for same protection
- Restart() now propagates Stop() errors instead of swallowing them
2026-07-23 20:15:11 +02:00
MrFastwind d55200886b docs: rewrite PLAN.md and update CODEBASE.md, README.md
- Full rewrite of PLAN.md to reflect current architecture (27 REST + 3 WS endpoints,
  embedded frontend, automation, scheduler, health check, GoReleaser CI)
- Added health.go, mods.go, scheduler.go, robfig/cron dep to CODEBASE.md
- Added Gitea Actions CI/CD section to CODEBASE.md
- Added conventional commits to code style section
- Added missing API routes and embed/ to README.md
2026-07-23 20:14:56 +02:00
MrFastwind 6f782af913 refactor(modlist): replace html/template with text/template and clean up deps
CI / build (push) Failing after 3s
2026-07-09 14:13:09 +02:00
MrFastwind 6774397885 feat: add modlist export to Arma 3 Launcher HTML format
- RenderModlistHTML: generates compatible preset HTML from a modlist
- GET /api/modlists/:id/export: returns downloadable .html file
- Export button on ModlistEditor page
- Skips local mods (no workshop ID), includes only Steam workshop mods
2026-07-06 18:33:24 +02:00
MrFastwind 26cc812e73 feat(backend): add mod manager service for scanning workshop/local mods 2026-07-06 16:10:24 +02:00
MrFastwind 149a60c6fb feat: add automation features (auto-update, auto-start, scheduled updates) 2026-07-06 16:10:17 +02:00
MrFastwind b853aead8c Initial commit 2026-07-06 14:14:58 +02:00