# Sculkworm documentation

Sculkworm routes Minecraft Java Edition TCP connections by the hostname inside the initial Handshake packet. These pages cover running, configuring, operating, securing, and contributing to Sculkworm.

## Pages

- [Getting started](https://docs.sculk.network/nightly/sculkworm/getting-started.md): build the container, configure routes, ping two hostnames, reload with `SIGHUP`, and shut down end to end.
- [Configuration](https://docs.sculk.network/nightly/sculkworm/configuration.md): every `SCULKWORM_*` environment variable, the `routes.json` file format, and every validation error.
- [HTTP admin API](https://docs.sculk.network/nightly/sculkworm/api.md): bearer-key tenancy, open and closed route endpoints, agent tokens, revocations, public HTTPS login/ticket endpoints, limits, and error codes. The machine-readable schema is [openapi.yaml](https://docs.sculk.network/nightly/sculkworm/openapi.md).
- [TypeScript SDK](https://docs.sculk.network/nightly/sculkworm/sdk/js.md): zero-dependency `sculkworm` client for Node.js 18+, Deno, Bun, and Cloudflare Workers.
- [Deploying](https://docs.sculk.network/nightly/sculkworm/deploy.md): Docker, Docker Compose, closed mode (TLS ALPN split, secrets file, `sculkworm-agent`, `sculkworm-connect`, systemd units, state v2 upgrade note), `SIGHUP` reloads, graceful shutdown, proxy limitations, and structured log events.
- [Security model](https://docs.sculk.network/nightly/sculkworm/security.md): threat model, unauthenticated hostnames, open-relay and closed-mode trust boundaries, log sanitization, resource caps, and player IP visibility.
- [Minecraft protocol](https://docs.sculk.network/nightly/sculkworm/protocol.md): Handshake wire format, closed-route answers on port 25565, the Minecraft 26.4 host query grammar, normalization rules, size limits, and rejection reasons.
- [Closed routes (specification)](https://docs.sculk.network/nightly/sculkworm/tunnel.md): the agent and connect tunnel contract, its wire protocol with test vectors, browser and device login flows, authorizers, admin API additions, state version 2, and threat model.
- [sculk.network as an authorizer](https://docs.sculk.network/nightly/sculkworm/sculk-authorizer.md): admitting players who hold `server.play` on a sculk.network server using sculk.network's OIDC provider.
- [Real-client verification](https://docs.sculk.network/nightly/sculkworm/verification.md): automated `minecraft-protocol` offline/encrypted/26.4/`servers.dat`/closed-mode e2e checks and the manual checklist for real Discord, browser, Java sync-jar, and Prism Launcher runs.
- [Contributing](https://docs.sculk.network/nightly/sculkworm/contributing.md): building from source, running Rust tests and live checks, code layout, conventions, and release status.
- [Releases](https://github.com/YellowUmbrellaDev/sculk.network/releases): changes by release, under the `sculkworm-v` tags.

## Glossary

- **Relay**: the Sculkworm TCP server that accepts incoming Minecraft connections on one port, reads the Handshake packet, and splices each connection to a backend.
- **Route**: a single entry in `routes.json` mapping one normalized domain name to one backend target.
- **Route table**: the in-memory `HashMap<Domain, Target>` (`RouteTable` in `src/routes.rs`) loaded from `SCULKWORM_ROUTES_FILE` and swapped atomically on `SIGHUP`.
- **Target**: a validated destination backend address in `host:port` or `[ipv6]:port` format (`Target` in `src/routes.rs`) that receives the replayed Handshake bytes and the spliced TCP stream.
- **Handshake**: the first serverbound packet (`0x00`) of every modern Minecraft Java Edition TCP connection, carrying protocol version, Server Address, port, and intent (`status`, `login`, or `transfer`).
- **Host field**: the UTF-8 Server Address string inside the Handshake packet, parsed by `HostField::parse` (`src/domain.rs`) to strip Forge `\0` suffixes, decode 26.4 query parameters, and derive the lookup domain.
- **Origin**: the original domain (and optional port) carried in the `_o` query parameter of the Handshake host field, defined for Minecraft 26.4 clients that connect through an `SRV` record.
- **Static route**: a route declared in the JSON file at `SCULKWORM_ROUTES_FILE`. Read-only through the API, and it wins over a dynamic route for the same hostname.
- **Dynamic route**: a route created through the admin API, persisted in `SCULKWORM_STATE_FILE` and kept across restarts and `SIGHUP` reloads.
- **Tenant**: a service that uses the shared relay, defined in `SCULKWORM_TENANTS_FILE` with a bearer key, one or more domain scopes, a `max_routes` cap, and optional `allowed_targets`. A tenant can only see and change dynamic routes inside its own scopes.
- **Domain scope**: a domain a tenant owns. It covers the domain itself and every subdomain of it, and no two tenants may overlap.
- **Closed route**: a dynamic route (`mode: "closed"`) with no backend `target`. Only players admitted by its authorizer reach it, through `sculkworm-connect` and the route's `sculkworm-agent`. See [Closed routes](https://docs.sculk.network/nightly/sculkworm/tunnel.md).
- **Agent**: `sculkworm-agent` (or `sculkworm agent`). Runs next to a Minecraft server that listens on `127.0.0.1` only, dials out to the relay over TLS with the route's agent token, and serves player streams to the local server.
- **Connect**: `sculkworm-connect` (or `sculkworm connect`), the player CLI. Logs the player in through the browser (or RFC 8628 device flow), opens a local listener for Minecraft, optionally updates `servers.dat` (`--add-server`), and carries each connection to the relay with a ticket.
- **Authorizer**: the per-route rule of a closed route that decides which identities may play: `fixed-list`, `oidc` (including `allow.sculk_server` for [sculk.network](https://docs.sculk.network/nightly/sculkworm/sculk-authorizer.md)), or `oauth2` (with a Discord preset).
- **Ticket**: a 30-second, single-use `swt_` credential the relay mints after re-checking the player's permission with the identity provider. It opens one connect session on one route.
