Phone UI and touch precision overhaul, proxy fixes, Orbital Uplink, four new maps
Phone panels (reviewed + QA'd, matrix of 22 layouts with real taps/bounding boxes): - selected-tower action bar over the board (Upgrade/Sell/Target/close), info panel updated in place so taps are never lost, scrollable palette for 7+ towers, overlays with pinned footers (Help "Got it", Play solo, Join always visible), tappable room chip to invite, reduced-motion/contrast/forced-colors fixes, paused state, partner cursor labels, bigger level pips and owner flags - touch input rewritten around "pointerdown commits nothing": pinch never builds, 10px tap slop, palm-proof pinch, long-press pings with any tool armed, nudge arrows for precise placement, hotkey repeat guard, proportional wheel zoom - new e2e: select/sell, info-panel stability, UI states, touch precision; camera unit tests Proxy/server (reproduced against real nginx 1.26 with NPM v2.16 config): - Origin check works when the proxy drops a non-default port, TRUSTED_PROXIES for proxies on global IPv6/CGNAT addresses, service worker no longer serves nginx's 502 page, DEPLOY.md corrected (NPM default read timeout is 90 s, Advanced-tab limits, path-prefix, cookie size, per-IP cap behaviour) Content: - Orbital Uplink: 4-level endgame tower (450 + 500/800/1200 credits): piercing armour-ignoring beam, blast and lingering slow, ground+air, range 11-14; glyph, beam effect, sound, help text, unit tests - Maps: The Canyon, Archipelago, Fortress, Pinwheel (7 maps total) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
parent
dad0382e10
commit
a5bd09d505
22 changed files with 2423 additions and 405 deletions
|
|
@ -15,11 +15,13 @@ Transport: one WebSocket per player at `ws(s)://<host>/ws`, JSON text frames, on
|
|||
```
|
||||
createServer({ port = 8080, host = '::', publicDir = <repo>/public,
|
||||
graceMs = 60000, snapshotHz = 20, maxRooms = 50,
|
||||
trustProxy = 'auto', allowedOrigins = [], maxConnPerIp = 40, pingMs = 25000, log = console.log })
|
||||
trustProxy = 'auto', trustedProxies = null, allowedOrigins = [], maxConnPerIp = 40, pingMs = 25000,
|
||||
log = console.log })
|
||||
-> Promise<{ port, addresses: string[], close(): Promise<void>, rooms: Map }>
|
||||
```
|
||||
Env when run directly: `PORT` (8080), `HOST` (`::`), `TRUST_PROXY` (`auto`|`1`|`0`), `ALLOWED_ORIGINS`
|
||||
(comma separated, e.g. `https://game.example.com`), `MAX_CONN_PER_IP`, `GRACE_MS`.
|
||||
Env when run directly: `PORT` (8080), `HOST` (`::`), `TRUST_PROXY` (`auto`|`1`|`0`), `TRUSTED_PROXIES` (comma separated
|
||||
IPs / CIDRs added to the private ranges that `auto` trusts; a bad entry stops the start-up), `ALLOWED_ORIGINS`
|
||||
(comma separated, e.g. `https://game.example.com`; include `:port` when it is not 80/443), `MAX_CONN_PER_IP`, `GRACE_MS`.
|
||||
Prints `http://localhost:PORT/` and every non-internal LAN URL from `os.networkInterfaces()` (IPv4 as
|
||||
`http://a.b.c.d:PORT/`, IPv6 as `http://[addr]:PORT/`, skip link-local `fe80::`).
|
||||
Handles SIGINT/SIGTERM by closing sockets and exiting 0.
|
||||
|
|
@ -33,17 +35,20 @@ IPv6** (IPv4 arrives as `::ffff:a.b.c.d`; normalise it for logs). If binding `::
|
|||
### Behind a reverse proxy (nginx Proxy Manager, nginx, Caddy, Traefik)
|
||||
The server is meant to sit behind TLS-terminating proxies with "Websockets Support" enabled and must work both
|
||||
at a domain root and under a path prefix the proxy strips.
|
||||
* **Keep-alive.** Proxies drop idle connections (nginx `proxy_read_timeout` defaults to 60 s). Every `pingMs`
|
||||
the server sends a WebSocket *protocol* ping to each socket and terminates sockets that did not pong since the
|
||||
previous round (so a dead mobile client is noticed within ~2 rounds and goes into the grace period).
|
||||
* **Keep-alive.** Every `pingMs` the server sends a WebSocket *protocol* ping to each socket and terminates sockets
|
||||
that did not pong since the previous round (so a dead mobile client is noticed within ~2 rounds and goes into the
|
||||
grace period). The pings are for dead-peer detection: a joined socket gets ~20 snapshots/s anyway, which is what
|
||||
keeps a proxy's idle timer (nginx `proxy_read_timeout`; 60 s by default, 90 s in nginx Proxy Manager) quiet.
|
||||
* **Real client IP** is used only for logging and the per-IP socket cap `maxConnPerIp`. `trustProxy:'auto'`
|
||||
means: if the TCP peer is loopback / RFC1918 / `fc00::/7` / link-local, take the client IP from
|
||||
means: if the TCP peer is loopback / RFC1918 / `fc00::/7` / link-local (or listed in `trustedProxies`), take the client IP from
|
||||
`X-Forwarded-For` (else `X-Real-IP`): the *rightmost* entry that is not a private address (proxies append, so
|
||||
entries further left are the client's own forgeable claim); otherwise use the TCP peer and ignore those headers.
|
||||
`true`/`false` force it. `maxConnPerIp: 0` disables the cap. Reject extra sockets with HTTP `429` on upgrade.
|
||||
* **Origin check** (see below) accepts: Origin host == `Host` header; or == `X-Forwarded-Host` when the proxy is
|
||||
trusted; or the Origin is listed in `allowedOrigins`. Compare scheme-less `host[:port]`, treat default ports
|
||||
(80/443) as equal to "no port", case-insensitive.
|
||||
trusted; or, when the proxy is trusted and `Host` has **no port**, the same host name on any port (nginx's
|
||||
`Host $host`, which nginx Proxy Manager uses, drops the port of `https://game.example.com:8443`); or the Origin is
|
||||
listed in `allowedOrigins`. Compare scheme-less `host[:port]`, treat default ports (80/443) as equal to "no port",
|
||||
case-insensitive.
|
||||
* **No absolute URLs, no hard-coded port** anywhere in served content; the client builds the socket URL relative
|
||||
to the page (`new URL('ws', location.href)` with `http->ws`, `https->wss`), so `https://x.example/netwall/`
|
||||
proxied to `/` works. The server therefore accepts the upgrade on path `/ws` only (the proxy strips any prefix).
|
||||
|
|
@ -61,8 +66,9 @@ at a domain root and under a path prefix the proxy strips.
|
|||
`Content-Security-Policy: default-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data:; style-src 'self' 'unsafe-inline'; media-src 'self' data:; base-uri 'none'; frame-ancestors 'none'`.
|
||||
|
||||
### WebSocket upgrade
|
||||
* Only on path `/ws`. If the request has an `Origin` header, its host must equal the `Host` header,
|
||||
else `403` (stops random web pages from driving a LAN server). No `Origin` (non-browser clients/tests) is fine.
|
||||
* Only on path `/ws`. If the request has an `Origin` header, its host must equal the `Host` header (or one of the
|
||||
trusted-proxy / `allowedOrigins` cases above), else `403` (stops random web pages from driving a LAN server). No
|
||||
`Origin` (non-browser clients/tests) is fine.
|
||||
* A socket that has not sent a valid `join` within **10 s** is closed (4408).
|
||||
* Per-socket rate limit: token bucket 60 msg/s, burst 120; beyond that close with 4429.
|
||||
* More than 20 malformed/unknown messages on a socket -> close 4400.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue