straywild-discovery-server/README.md

105 lines
4.2 KiB
Markdown
Raw Normal View History

2026-08-25 17:14:33 -04:00
# straywild Discovery Server
2026-08-10 10:19:57 -04:00
2026-08-25 17:14:33 -04:00
An ephemeral public-room directory for straywild. It complements the game's existing direct ENet
2026-08-10 10:19:57 -04:00
transport: hosts advertise a room through HTTPS, browsers retrieve compatible rooms, and joining
still uses the authoritative host's UDP endpoint.
2026-08-10 19:49:47 -04:00
The service also runs a small UDP rendezvous. It observes packets sent from the exact ENet sockets
used by hosts and joiners, then lets an authenticated room host retrieve pending endpoints and send
hole-punch packets. Gameplay remains direct and never passes through this service.
2026-08-10 10:19:57 -04:00
Friend presence and live room invitations use the same service as short-lived capability channels.
There are no discovery accounts, durable friend records, or offline messages; friendship state
stays on each player's device.
2026-08-10 10:19:57 -04:00
## Requirements
- Python 3.11 or newer
- A TLS reverse proxy for public deployment
There are no runtime Python package dependencies.
## Run locally
```bash
2026-08-25 17:14:33 -04:00
python3 -m straywild_discovery
2026-08-10 10:19:57 -04:00
```
The default listener is `127.0.0.1:7770`.
```bash
curl http://127.0.0.1:7770/health
```
2026-08-25 17:14:33 -04:00
Set `straywild_DISCOVERY_BUILD_REVISION` to the deployed Git commit. The health response reports
2026-08-11 10:37:03 -04:00
both the package version and that build revision, which makes production/source drift visible.
2026-08-10 10:19:57 -04:00
Run the focused tests with:
```bash
python3 -m unittest discover -v
```
## Configuration
Environment variables are documented in
2026-08-25 17:14:33 -04:00
[`deploy/straywild-discovery.env.example`](deploy/straywild-discovery.env.example).
2026-08-10 10:19:57 -04:00
The intended public topology is:
```text
2026-08-25 17:14:33 -04:00
straywild client -> HTTPS reverse proxy -> 127.0.0.1:7770 discovery service
straywild client -----------------------> public UDP rendezvous:7771
straywild client -----------------------> advertised ENet/UDP host:port
2026-08-10 10:19:57 -04:00
```
Configure the Godot client with the reverse proxy's HTTPS origin through
`network/discovery/base_url` in `project.godot`. For local development, the
same value can be overridden without modifying the project by setting
2026-08-25 17:14:33 -04:00
`straywild_DISCOVERY_URL` before launching the game.
2026-08-10 10:19:57 -04:00
The reverse proxy must preserve the client address in `X-Forwarded-For`, and
2026-08-25 17:14:33 -04:00
its own address must be listed in `straywild_DISCOVERY_TRUSTED_PROXY_CIDRS`.
2026-08-10 10:19:57 -04:00
Apply ordinary request-rate limits to the write endpoints at the proxy. Do not
expose the Python listener directly to the public Internet.
2026-08-25 17:14:33 -04:00
Use the sample systemd unit in [`deploy/straywild-discovery.service`](deploy/straywild-discovery.service)
2026-08-10 10:19:57 -04:00
as a deployment starting point. The service keeps only active leases in memory, so it requires no
database, backups, or schema migrations.
## Connectivity boundary
2026-08-10 19:49:47 -04:00
The game first requests UPnP forwarding, then uses same-socket UDP rendezvous and hole punching.
This covers common home NAT configurations without changing ENet gameplay authority. Symmetric
NAT and some carrier-grade networks can still require a future ENet-compatible relay fallback.
Expose the configured traversal port over UDP in both the host firewall and provider firewall.
2026-08-11 10:37:03 -04:00
The rendezvous listener intentionally processes its small, bounded packets serially so arbitrary
datagrams cannot create unbounded worker threads. Apply conservative edge rate limits as an
additional deployment control.
2026-08-10 10:19:57 -04:00
## API
See [`docs/API.md`](docs/API.md) for the versioned HTTP contract.
## Repository relationship
2026-08-11 20:31:02 -04:00
This is deliberately a separate repository from the Godot game so the service can deploy and roll
2026-08-25 17:14:33 -04:00
back independently. Production tags follow the coordinated straywild release train: a
2026-08-11 20:31:02 -04:00
`vX.Y.Z-alpha` tag identifies the discovery snapshot tested for the same game and dedicated-server
2026-08-25 17:14:33 -04:00
release. The versioned HTTP contract remains independent from straywild's save schema and gameplay
2026-08-11 20:31:02 -04:00
network protocol. Each tagged deployment accepts room advertisements only from its matching game
release so incompatible rooms are never presented as publicly available.
2026-08-12 10:11:20 -04:00
## Licensing
Project-owned source code is licensed under the GNU General Public License,
version 3 or, at your option, any later version
([GPL-3.0-or-later](LICENSE)).
2026-08-25 17:14:33 -04:00
straywild and Woofmeow branding is not granted under the GPL; see
[`TRADEMARKS.md`](TRADEMARKS.md). Unsolicited contributions are not accepted;
see [`CONTRIBUTING.md`](CONTRIBUTING.md). Historical and expressly invited
work is governed by [`CONTRIBUTOR-TERMS.md`](CONTRIBUTOR-TERMS.md).
2026-08-12 10:11:20 -04:00
Copyright © 2026 Woofmeow.