152 lines
3.6 KiB
Markdown
152 lines
3.6 KiB
Markdown
# GameDig Server Status API
|
||
|
||
Ein Node.js-Dienst für Pterodactyl Panel, der Gameserver (DayZ, CS2, Rust, ARK u.v.m.) per [GameDig](https://github.com/gamedig/node-gamedig) abfragt und die Ergebnisse als JSON-REST-API bereitstellt.
|
||
|
||
## Funktionen
|
||
|
||
- Unterstützt über 320 Spieltypen via GameDig v4
|
||
- Konfigurierbares Abfrage-Intervall
|
||
- Optionaler API-Key-Schutz
|
||
- CORS-Header für Webintegration
|
||
- Einfache Konfiguration per `config.json`
|
||
|
||
---
|
||
|
||
## Dateien
|
||
|
||
| Datei | Beschreibung |
|
||
|---|---|
|
||
| `server.js` | Hauptskript – GameDig-Abfragen + HTTP-Server |
|
||
| `entrypoint.sh` | Startskript für Pterodactyl |
|
||
| `package.json` | npm-Abhängigkeiten |
|
||
| `config.json` | Serverliste (muss angepasst werden) |
|
||
| `egg-gameserver-status-api.json` | Pterodactyl Egg |
|
||
|
||
---
|
||
|
||
## Installation in Pterodactyl
|
||
|
||
1. Egg importieren: Admin → Nests → Import Egg → `egg-gameserver-status-api.json`
|
||
2. Neuen Server erstellen, Egg auswählen, Port zuweisen
|
||
3. Server installieren lassen
|
||
4. `config.json` im Dateimanager anpassen (siehe unten)
|
||
5. Server starten
|
||
|
||
---
|
||
|
||
## Konfiguration
|
||
|
||
### config.json
|
||
|
||
```json
|
||
{
|
||
"servers": [
|
||
{
|
||
"label": "DayZ Main Server",
|
||
"type": "dayz",
|
||
"host": "192.168.1.10",
|
||
"port": 2302,
|
||
"queryPort": 2303,
|
||
"image": "https://example.com/images/dayz.jpg"
|
||
},
|
||
{
|
||
"label": "CS2 Server",
|
||
"type": "cs2",
|
||
"host": "192.168.1.10",
|
||
"port": 27015,
|
||
"image": "https://example.com/images/cs2.jpg"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
**Felder:**
|
||
|
||
| Feld | Pflicht | Beschreibung |
|
||
|---|---|---|
|
||
| `label` | ✓ | Anzeigename des Servers |
|
||
| `type` | ✓ | GameDig-Spieltyp (z.B. `dayz`, `cs2`, `rust`, `arkse`) |
|
||
| `host` | ✓ | IP-Adresse oder Hostname |
|
||
| `port` | ✓ | Spielport |
|
||
| `queryPort` | – | Optionaler Query-Port (wenn abweichend vom Spielport) |
|
||
| `image` | – | URL zum Spielbild für das Widget |
|
||
|
||
**Hinweis zu DayZ:** Der Query-Port ist standardmässig `Spielport + 1` (z.B. 2302 → 2303). Falls manuell geändert, `queryPort` explizit setzen.
|
||
|
||
**Spieltypen:** Vollständige Liste unter [GAMES_LIST.md](https://github.com/gamedig/node-gamedig/blob/master/GAMES_LIST.md)
|
||
|
||
### Umgebungsvariablen (Pterodactyl)
|
||
|
||
| Variable | Standard | Beschreibung |
|
||
|---|---|---|
|
||
| `QUERY_INTERVAL` | `60` | Abfrage-Intervall in Sekunden (Minimum: 10) |
|
||
| `API_KEY` | *(leer)* | API-Key zum Schutz der Endpunkte. Leer = kein Schutz |
|
||
|
||
---
|
||
|
||
## API-Endpunkte
|
||
|
||
### GET /api/servers
|
||
|
||
Gibt den Status aller konfigurierten Server zurück.
|
||
|
||
**Ohne API-Key:**
|
||
```
|
||
GET http://<host>:<port>/api/servers
|
||
```
|
||
|
||
**Mit API-Key:**
|
||
```
|
||
GET http://<host>:<port>/api/servers?key=DEINKEY
|
||
# oder
|
||
GET http://<host>:<port>/api/servers
|
||
X-API-Key: DEINKEY
|
||
```
|
||
|
||
**Antwort:**
|
||
```json
|
||
{
|
||
"updated": "2026-02-26T12:00:00.000Z",
|
||
"interval_seconds": 60,
|
||
"servers": [
|
||
{
|
||
"label": "CS2 Server",
|
||
"type": "cs2",
|
||
"address": "192.168.1.10:27015",
|
||
"image": "https://example.com/images/cs2.jpg",
|
||
"status": "online",
|
||
"players": 8,
|
||
"maxPlayers": 16,
|
||
"map": "de_dust2",
|
||
"ping": 4
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
### GET /health
|
||
|
||
Statuscheck ohne Authentifizierung.
|
||
|
||
```json
|
||
{
|
||
"status": "ok",
|
||
"uptime": 3600.5
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## Wichtiger Hinweis: NAT / Docker-Netzwerk
|
||
|
||
GameDig verwendet UDP. Wenn der Pterodactyl-Server und die abzufragenden Gameserver auf **demselben Host** laufen, kann ein Hairpin-NAT-Problem auftreten. In diesem Fall die **interne IP** statt der öffentlichen IP in `config.json` verwenden.
|
||
|
||
---
|
||
|
||
## Technische Details
|
||
|
||
- **Runtime:** Node.js 20 (Alpine)
|
||
- **Docker Image:** `ghcr.io/pterodactyl/yolks:nodejs_20`
|
||
- **Modul-System:** ESM (`"type": "module"` in package.json)
|
||
- **GameDig:** v4.x (CommonJS, via Default-Import)
|