# DayZ — panel-native module

Panel-native DayZ dedicated server, native-Linux (no Wine). Steam app 223350.

## The Steam-login gotcha

**DayZ is paid content.** SteamCMD refuses `+login anonymous` with `No subscription`. The manifest sets `requires_steam_login: true` on the update provider, which tells the controller to gate install/update behind the Steam-login modal. Flow:

1. Create a DayZ instance in the panel. Auto-update is intentionally skipped (agent sees `requires_steam_login` on the provider and doesn't kick off the first Update).
2. Click **Update** on the instance.
3. Panel returns `{steam_login_required: true}` and the browser pops a login modal.
4. Enter your Steam username + password. If Steam Guard is enabled on your account, also enter the 5-char code from your email / Steam Mobile app.
5. Panel runs a one-shot `docker run steamcmd/steamcmd +login <user> <pass>` to verify, stores the password encrypted (AES-GCM, key HKDF-derived from the panel's CA private key), and caches the SSFN sentry file in a panel-wide volume (`panel-steamcmd-auth`) so future updates skip Steam Guard.
6. Retry Update — panel injects creds into the SteamCMD sidecar and downloads ~5 GB of DayZ server files.

Your Steam account must own the DayZ base game (app 221100). The dedicated-server app itself (223350) is a free tool; ownership of the base game is what grants download rights.

## Image + runtime

- `panel-dayz:latest` — debian:12-slim, 32-bit runtime libs (`libc6:i386`, `lib32gcc-s1`, `lib32stdc++6`) for `steamclient.so`, plus `libcurl4`/`libxml2`. No Wine.
- Binary: `/game/DayZServer` (ELF64, native).
- Config: `/game-saves/serverDZ.cfg` (symlinked to `/game/serverDZ.cfg`).
- Profiles (logs, bans, RPTs): `/game-saves/profiles/` (symlinked to `/game/profiles`).
- BattlEye config: `/game/battleye/beserver_x64.cfg` (port + password written on first boot from `BE_PASSWORD` env var).

## RCON — BattlEye protocol

DayZ uses BattlEye's proprietary UDP RCON, not Source RCON. The panel's `be_rcon` adapter handles:

- Login handshake (password auth → single-byte success/fail)
- Sequenced commands with per-seq ack tracking
- Multi-part response reassembly for long outputs (`players` on busy servers)
- Server-pushed events (chat/join/leave) ack'd automatically
- 30-second keep-alive ping (BE disconnects idle clients after ~45s)

Commands wired:

- `list` → `players`
- `broadcast {msg}` → `say -1 {msg}`
- `kick {player}` → `kick {player}`
- `ban {player}` → `ban {player}`
- `shutdown` → `#shutdown`

## Ports

| Port | Proto | Purpose |
|------|-------|---------|
| 2302 | UDP | Game + Steam query (same port — Bohemia convention) |
| 2303 | UDP | Additional instance offset (+1) |
| 2304 | UDP | Additional instance offset (+2) |
| 2305 | UDP | Additional instance offset (+3) |
| 2310 | UDP | BattlEye RCON (internal) |

## Environment vars

| Var | Default | Notes |
|-----|---------|-------|
| `SERVER_NAME` | `panel DayZ` | Shown in the DayZ server browser |
| `SERVER_PORT` | `2302` | Game + Steam-query UDP port |
| `SERVER_PASSWORD` | *(empty)* | Optional client join password |
| `BE_PASSWORD` | `panel_be` | BattlEye RCON admin password (edit before exposing) |
| `CPU_COUNT` | `2` | `-cpuCount=` arg to the server binary |

## Log events

- **Join:** `Player "<name>" is connected`
- **Leave:** `Player "<name>" disconnected`
- **Chat:** `Chat("<name>"): <msg>`

## Known gotchas

- **Steam credentials are a one-time ceremony per panel.** Once stored, the cached SSFN blob means subsequent updates don't re-prompt. If Steam invalidates your session (machine change, long inactivity), the modal will pop again with `{need_guard: true}` — enter a fresh code.
- **BattlEye RCON port collides by convention.** 2310 is our default; if you run multiple DayZ instances on the same host, bump via the panel's Network Ports editor.
- **Modded servers need `@<ModName>` in the launch command.** The entrypoint doesn't wire this yet — drop mod pbos into `/game/` and add `-mod=@<ModName>` via a manual launcher edit (or wait for a follow-up that exposes `EXTRA_ARGS` as an env var).
- **`steamQueryPort` must equal the game port** in `serverDZ.cfg` or DayZ refuses to register with Steam's master server. Our seeded config follows this.
- **BattlEye can kick you for "kick #0 CreateVehicle Restriction..."** type messages on vanilla — these are server-side integrity checks. Tune `verifySignatures` and the `battleye/bans.txt` / `permissions.txt` files via the Files tab.

## References

- [Bohemia Interactive: Hosting a Linux Server (DayZ)](https://community.bistudio.com/wiki/DayZ:Hosting_a_Linux_Server)
- [BattlEye RCON Protocol](https://www.battleye.com/downloads/BERConProtocol.txt)
- [Steam — DayZ Server (app 223350)](https://steamdb.info/app/223350/)
