- security headers on every response (strict CSP, nosniff, frame DENY, no-referrer, HSTS behind TLS proxy) and no x-powered-by; hero image set through the CSSOM so the CSP needs no inline styles - error handler: 400 without stack trace for malformed URLs/JSON and multer errors, 500 logged in full - image uploads: type detected from the file signature (PNG/JPEG/WebP), not the client MIME type; multer part limits - storage: atomic JSON writes (tmp + rename) with mode 600, dirs 700; refuse to start when groups.json is corrupted instead of recreating admin; initial admin password written to a 600 file instead of the logs - status file read asynchronously in the background and cached, one read at a time with a 3 s timeout, so a hung NFS mount never blocks requests; cleanup refused when the status is stale or empty - launches: 10 min cooldown after a successful start (status lags behind), ssh BatchMode/ConnectTimeout/IdentitiesOnly, remote stdout/stderr kept in the server log instead of the API response Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.3 KiB
Markdown
68 lines
2.3 KiB
Markdown
# gameservers-control
|
|
|
|
Interface web locale pour consulter et lancer des serveurs de jeux.
|
|
|
|
## Demarrage
|
|
|
|
```bash
|
|
npm install
|
|
cp .env.example .env
|
|
npm run dev
|
|
```
|
|
|
|
Variables utiles:
|
|
|
|
- `PORT`: port HTTP, defaut `3000`.
|
|
- `GAMESERVERS_STATUS_FILE`: chemin du JSON de statut monte en NFS.
|
|
- `STORAGE_DIR`: dossier de stockage local, defaut `storage`.
|
|
- `SESSION_TTL_HOURS`: duree des sessions, defaut `12`.
|
|
- `TRUSTED_PROXIES`: reverse proxys de confiance (ex: `loopback,192.168.0.104`), vide par defaut.
|
|
- `LOGIN_MAX_ATTEMPTS` / `LOGIN_WINDOW_MINUTES`: tentatives de connexion par IP, defaut `5` par `15` minutes.
|
|
- `STATUS_REFRESH_SECONDS`: relecture du fichier de statut en tache de fond, defaut `15`.
|
|
- `LAUNCH_COOLDOWN_MINUTES`: delai sans nouveau lancement apres un lancement reussi, defaut `10`.
|
|
- `*_SSH_TARGET`: cible SSH du profil de lancement, alias SSH ou `user@host`.
|
|
- `*_SSH_PORT`: port SSH optionnel. Vide par defaut.
|
|
- `*_SSH_KEY_FILE`: chemin optionnel vers une cle SSH privee.
|
|
- `*_START_COMMAND`: commande distante executee sur la cible SSH.
|
|
|
|
Pour changer le port, modifier `.env`:
|
|
|
|
```env
|
|
PORT=8080
|
|
```
|
|
|
|
Exemple de lancement distant via SSH:
|
|
|
|
```env
|
|
GAME_1_SSH_TARGET=user@192.0.2.10
|
|
GAME_1_SSH_PORT=2222
|
|
GAME_1_SSH_KEY_FILE=/home/app/.ssh/game-server-key
|
|
GAME_1_START_COMMAND="bash /opt/game-server-1/start.sh"
|
|
```
|
|
|
|
Le serveur local doit reference ce profil dans `storage/servers.json`:
|
|
|
|
```json
|
|
{
|
|
"id": "game-1",
|
|
"startProfile": "GAME_1"
|
|
}
|
|
```
|
|
|
|
Au premier demarrage, si aucun groupe n'existe, un groupe `admin` est cree et son mot de passe temporaire est ecrit dans `STORAGE_DIR/initial-admin-password.txt` (droits `600`, a supprimer apres lecture).
|
|
|
|
## Stockage
|
|
|
|
- `storage/servers.json`: configuration locale des serveurs, profils de lancement, secrets.
|
|
- `storage/groups.json`: groupes et permissions.
|
|
- `storage/launch-logs.json`: lancements conserves 7 jours.
|
|
- `mocked/dev-gameservers-status.json`: statut mock de developpement.
|
|
|
|
Le dossier `storage/` n'est pas versionne: il est cree au premier demarrage avec des valeurs
|
|
par defaut. En production, `STORAGE_DIR` pointe hors du depot (droits `700`).
|
|
|
|
## Deploiement
|
|
|
|
Chaque push lance les tests et `npm audit` (`.forgejo/workflows/deploy.yml`). Un push sur `main`
|
|
dont les controles passent deploie le commit en production. Mise en place cote serveur:
|
|
voir [ops/README.md](ops/README.md).
|