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:
Claude 2026-10-10 18:03:24 +00:00
parent dad0382e10
commit a5bd09d505
22 changed files with 2423 additions and 405 deletions

View file

@ -6,7 +6,7 @@
* const { createServer } = require('./server');
* const srv = await createServer({ port: 8080 }); // srv.port, srv.addresses, srv.close(), srv.rooms
*
* Run directly: PORT=8080 HOST=:: TRUST_PROXY=auto ALLOWED_ORIGINS=https://game.example.com node server/index.js
* Run directly: PORT=8080 HOST=:: TRUST_PROXY=auto TRUSTED_PROXIES=100.64.0.0/10 ALLOWED_ORIGINS=https://game.example.com node server/index.js
*/
const http = require('http');
const path = require('path');
@ -14,7 +14,7 @@ const { WebSocketServer } = require('ws');
const TD = require('../public/js/sim.js');
const { RoomManager } = require('./room');
const { createStaticHandler, applySecurityHeaders, CSP } = require('./static');
const { parseTrustProxy, clientIp, originAllowed, TokenBucket, listenDual, listUrls } = require('./net');
const { parseTrustProxy, parseTrustedProxies, isTrustedPeer, clientIp, originAllowed, TokenBucket, listenDual, listUrls } = require('./net');
const MAX_PAYLOAD = 2048; // bytes per client frame
const RATE_PER_SEC = 60, RATE_BURST = 120;
@ -40,11 +40,12 @@ async function createServer(userOpts) {
const o = {
port: 8080, host: '::', publicDir: path.join(__dirname, '..', 'public'),
graceMs: 60000, snapshotHz: 20, maxRooms: 50,
trustProxy: 'auto', allowedOrigins: [], maxConnPerIp: 40, pingMs: 25000, log: defaultLog,
trustProxy: 'auto', trustedProxies: null, allowedOrigins: [], maxConnPerIp: 40, pingMs: 25000, log: defaultLog,
joinTimeoutMs: 10000, // not in the protocol's option list: lets tests shorten the 10 s join window
};
for (const k of Object.keys(userOpts || {})) if (userOpts[k] !== undefined) o[k] = userOpts[k];
o.trustProxy = parseTrustProxy(o.trustProxy);
o.trustedProxies = parseTrustedProxies(o.trustedProxies); // null, or { list, has(ip) }: extra proxy addresses for 'auto'
o.allowedOrigins = (o.allowedOrigins || []).map(String).filter(Boolean);
o.snapshotHz = Math.min(60, Math.max(1, Number(o.snapshotHz) || 20));
const log = typeof o.log === 'function' ? o.log : noop;
@ -96,11 +97,13 @@ async function createServer(userOpts) {
if (closing) return refuse(socket, 503, 'Service Unavailable');
if ((req.url || '').split('?')[0] !== '/ws') return refuse(socket, 404, 'Not Found');
if (!originAllowed(req, o)) {
log('refused websocket from ' + clientIp(req, o.trustProxy) + ': Origin ' + JSON.stringify(req.headers.origin) +
' does not match Host ' + JSON.stringify(req.headers.host) + ' (see ALLOWED_ORIGINS)');
log('refused websocket from ' + clientIp(req, o.trustProxy, o.trustedProxies) + ': Origin ' + JSON.stringify(req.headers.origin) +
' does not match Host ' + JSON.stringify(req.headers.host) + (isTrustedPeer(req, o.trustProxy, o.trustedProxies)
? ' (see ALLOWED_ORIGINS)'
: ' (this connection is not from a trusted proxy: see TRUST_PROXY, TRUSTED_PROXIES and ALLOWED_ORIGINS)'));
return refuse(socket, 403, 'Forbidden');
}
const ip = clientIp(req, o.trustProxy);
const ip = clientIp(req, o.trustProxy, o.trustedProxies);
if (o.maxConnPerIp > 0 && (ipCount.get(ip) || 0) >= o.maxConnPerIp) {
log('refused websocket from ' + ip + ': too many connections');
return refuse(socket, 429, 'Too Many Requests');
@ -280,6 +283,7 @@ async function main() {
port: envInt('PORT', 8080),
host: process.env.HOST || '::',
trustProxy: process.env.TRUST_PROXY || 'auto',
trustedProxies: process.env.TRUSTED_PROXIES || '',
allowedOrigins: (process.env.ALLOWED_ORIGINS || '').split(',').map((s) => s.trim()).filter(Boolean),
};
if (process.env.MAX_CONN_PER_IP) opts.maxConnPerIp = envInt('MAX_CONN_PER_IP', 40);
@ -288,7 +292,9 @@ async function main() {
const shownProxy = parseTrustProxy(opts.trustProxy);
console.log('Netwall is listening on ' + (srv.host.includes(':') ? '[' + srv.host + ']' : srv.host) + ':' + srv.port +
(srv.host === '::' ? ' (dual stack: IPv4 + IPv6)' : srv.host === '0.0.0.0' ? ' (IPv4 only)' : ''));
console.log(' trust proxy: ' + shownProxy + ', extra allowed origins: ' + (opts.allowedOrigins.join(', ') || '(none)'));
console.log(' trust proxy: ' + shownProxy + (srv.options.trustedProxies && shownProxy === 'auto'
? ' + ' + srv.options.trustedProxies.list.join(', ') : '') +
', extra allowed origins: ' + (opts.allowedOrigins.join(', ') || '(none)'));
console.log('Open:');
for (const u of listUrls(srv.host, srv.port)) console.log(' ' + u);