Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,28 @@ Behind a reverse proxy every request comes from the proxy's address. To log the
- Recommended: keep `X-Forwarded-For`, let the proxy pass it on (Traefik: `forwardedHeaders.trustedIPs` with [Cloudflare's ranges](https://www.cloudflare.com/ips/)) and list both the proxy and Cloudflare's ranges in `trustedProxies`. Every hop appends its peer to the chain, so a client that bypasses Cloudflare ends up as the first untrusted entry and is logged as itself.
- Simpler: `"remoteIPHeaders": ["CF-Connecting-IP"]` with only the proxy in `trustedProxies`. This header holds a single address that the proxy passes on unchecked, so let only Cloudflare reach the proxy (firewall), otherwise a client that bypasses Cloudflare can set it itself.

## Recording List and Player Profiles

The recording list is paged on the server. `GET /api/v1/operations` takes these optional query parameters, and its `X-Total-Count` header carries the number of matches across all pages. Without `limit` it returns every match in id order, as before. A full page also carries `X-Next-Cursor`: passed back as `after`, it continues right behind that page's last recording, so recordings added or deleted in between neither repeat one nor skip one.

| Parameter | Description |
|-----------|-------------|
| `limit`, `after` | Page size (at most 500) and the `X-Next-Cursor` of the page before |
| `offset` | Matches to skip, counted when the request runs |
| `sort`, `dir` | `date` (by the instant, offsets of RFC3339 dates included), `name` or `duration`; `asc` (default) or `desc` |
| `q` | Mission name, world name or installed world display name contains, in any case of any script |
| `world` | Recorded on one of these worlds; repeat or comma-separate |
| `player` | Recordings a player of this in-game name took part in |
| `playerUid` | Recordings the player with this Steam UID took part in |
| `tagExact` | Tag equals, in the same case, as a tag chip in the UI selects |
| `name`, `tag`, `newer`, `older` | Mission name contains, tag contains, date range |

`GET /api/v1/operations/summary` returns the totals and filter options of every recording. World names are stored in lower case, so each world it offers selects its recordings.

Players are indexed per recording by Steam UID when the recording has one and by in-game name otherwise, so a player keeps one profile under every name they play as, including several names in one recording, which still counts once. The UID and every name come from the player's units, connections and Zeus slots, though a connection alone does not count as taking part. A unit recorded without a UID takes the one its name was seen with in the same recording. A player recorded without any UID has a separate profile by name. Converted recordings are indexed from their JSON source, because the v1 protobuf has no UIDs. The index is built when a recording is converted, streamed or uploaded, and recordings stored before it existed are indexed once at startup.

`GET /api/v1/players?q=` searches players by any name they used or by exact Steam UID. `GET /api/v1/players/profile?uid=` returns one player's missions, kills, deaths, sides and other names across recordings; `?name=` finds a player recorded without a UID. The **Players** page in the UI, reached from the header or from player matches under the recording search, shows the same data.

## Large Recording Support

### Overview
Expand Down
10 changes: 10 additions & 0 deletions cmd/ocap-webserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ func runApp(d appDeps) error {
},
)

// Streamed recordings reach player search through the indexer; uploads
// through conversion or the stats computer below.
handlerOpts = append(handlerOpts, server.WithPlayerIndexer(worker))

if setting.Conversion.Enabled {
// Pass worker to handler for event-driven conversion on upload
handlerOpts = append(handlerOpts, server.WithConversionTrigger(worker))
Expand Down Expand Up @@ -235,6 +239,12 @@ func runApp(d appDeps) error {
handlerOpts = append(handlerOpts, server.WithMapTool(jm, tools, setting.Maps))
}

// Recordings stored before chat was masked are masked before they are
// served, and swept once in the background.
chatRedactor := server.NewChatRedactor(operation, setting.Data)
handlerOpts = append(handlerOpts, server.WithChatRedactor(chatRedactor))
go chatRedactor.Backfill(ctx)

server.NewHandler(s, operation, marker, ammo, setting, handlerOpts...)

// Handle graceful shutdown
Expand Down
32 changes: 32 additions & 0 deletions docs/streaming-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,38 @@ timeline. Older clients that omit the declaration keep their zero-based frames,
legacy marker end sentinel and projectile trajectory field name. Unknown future
message types are logged and skipped.

A chat message that starts with `#login`, in any case, carries the server admin
password. The addon masks it before sending, and the web masks it again on
receipt for older addons: the command is kept and everything after it becomes
`********`, a fixed mask that does not reveal the password's length. Both skip
the same leading whitespace: Unicode White_Space and U+FEFF. Files stored
before this rule are masked in place before the server first serves any of
them, and swept once at startup: the v2 manifest and each precompressed sidecar
that differs from it, since a sidecar can be requested by name, and the v1 JSON
under both `.json.gz` and `.json`. JSON chat is matched as decoded, since a
writer may spell letters as `\u` escapes, and the JSON is read as a stream:
only one event is held at a time, so a long position history costs no memory.
The manifest with its sidecars, the `.json.gz` and the `.json` are each checked
and served on their own: a part the server cannot vouch for is not served, and
keeps only itself from being served, so a damaged copy in one format leaves the
other playable. That covers a JSON it cannot read, a manifest of no schema it
writes, and a sidecar left without its manifest, as a partial restore can leave
one. `chat_redaction_revision` marks a recording once all three are clean. No
file that can hold chat is served if it belongs to no recording or no check
reads it: a `manifest.*` file other than the manifest and its sidecars, or a
file under the temporary name it was written under, which a crash from before
masking may have left. Only the manifest's own sidecars stand in for a file
that is asked for. A sidecar is removed before its artifact is replaced, so a
failure part way leaves none of the old bytes. An upload is staged in a directory of its own under
`.upload-staging/`, which `/data/` never serves and no recording may be named
after, and masked there before it is published by a rename, because a replaced
recording keeps its mark until the new row is written. An upload that is not a
JSON object is refused. `/data/` serves a file only by the name it is stored
under: no backslash, and on Windows no other case, trailing dot or space, 8.3
short name or stream suffix. Conversion carries chat into v1 protobuf as JSON
in the event message, masked too, and playback masks again. The v1 JSON chat entry is `[frame, "chat",
message, fromName, channel]`; copies written earlier end at the message.

Each accepted mission gets one unique storage key, used for its database row,
v2 directory and v1 `.json.gz` copy. At mission end the web writes:

Expand Down
4 changes: 2 additions & 2 deletions docs/testkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ For a diagnostic goroutine-leak profile after three synthetic reconnect-and-disc
| `route-access` | Prefixed viewer access to stored JSON and v2-generated downloads, protected admin mutations, and producer credential rejection |
| `steam-boundary` | Fake OpenID verifier and loopback profile API, denied allowlist access and provider errors |
| `stream-recovery` | Loopback reconnect, repeated starts, partial replacement, durable end, repeated discard, and fake-clock tests for reservation timeouts and a failed keepalive write |
| `conversion-recovery` | Temporary conversion artifacts, status failures and admin retry |
| `playback-delivery` | Synthetic artifact serving and decoding, v2 to v1 export, lazy sidecar replay and Gear exports, event-time factions, and bounded chunk traversal |
| `conversion-recovery` | Temporary conversion artifacts, status failures, admin retry, and player index jobs that finish after their recording was deleted or replaced |
| `playback-delivery` | Synthetic artifact serving and decoding, v2 to v1 export, lazy sidecar replay and Gear exports, event-time factions, bounded chunk traversal, converted chat, and #login passwords masked in stored files, their sidecars and uploads before any is served, with a large recording checked in bounded memory, each format checked and served on its own, and no staged upload, orphaned sidecar, leftover temporary copy or other name of a file served |
| `map-boundary` | Synthetic ZIP and job lifecycle, authenticated SSE, stubbed CDN fallback |
| `startup` | Fake dependencies for startup, failure and shutdown wiring |

Expand Down
Loading
Loading