From e3af2de05108dd5e0e1c50d4f8b90db130a67800 Mon Sep 17 00:00:00 2001 From: Schluffe Date: Mon, 19 Oct 2026 21:03:45 +0200 Subject: [PATCH] Add self-hosted WebTorrent tracker container and reconnect plan Build a WebSocket-only tracker from the official Node image and a locked bittorrent-tracker 11.2.3, run via compose.tracker.yaml and the tracker:up/tracker:down/test:tracker scripts. A small wrapper disables scrape and stats and bounds input: frame validation, per-IP connection and message limits (IPv6 grouped per /64), origin checks, a fixed peer ID and at most four swarms per socket (tracked synchronously, so pipelined frames cannot bypass it), swarm and peer caps, idle-socket timeout and explicit expiry of stale swarm memberships. Forwarded addresses are taken from the rightmost X-Forwarded-For entry and only from trusted proxies. Integration tests use only Node built-ins. Document the planned tracker reconnect design; the app still uses manual connection codes. Co-Authored-By: Claude Opus 5.5 --- README.md | 17 + compose.tracker.yaml | 28 + docs/ux-roadmap.md | 9 +- docs/webtorrent-reconnect.md | 271 +++++++++ package.json | 3 + tracker/.dockerignore | 6 + tracker/Dockerfile | 24 + tracker/README.md | 125 ++++ tracker/healthcheck.mjs | 4 + tracker/package-lock.json | 1055 ++++++++++++++++++++++++++++++++++ tracker/package.json | 12 + tracker/server.mjs | 167 ++++++ tracker/test.mjs | 284 +++++++++ 13 files changed, 2003 insertions(+), 2 deletions(-) create mode 100644 compose.tracker.yaml create mode 100644 docs/webtorrent-reconnect.md create mode 100644 tracker/.dockerignore create mode 100644 tracker/Dockerfile create mode 100644 tracker/README.md create mode 100644 tracker/healthcheck.mjs create mode 100644 tracker/package-lock.json create mode 100644 tracker/package.json create mode 100644 tracker/server.mjs create mode 100644 tracker/test.mjs diff --git a/README.md b/README.md index d5bc815..ca7ae17 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,23 @@ run `bun run preview` and open the printed localhost URL. ## Development +### Local WebTorrent tracker + +The repository includes [our tracker Dockerfile](tracker/Dockerfile) and a +separate [Compose service](compose.tracker.yaml), built from the official Node +image and a locked upstream `bittorrent-tracker` release. With Docker running: + +```sh +bun run tracker:up # build and start ws://127.0.0.1:8000 +bun run test:tracker # integration checks inside the test image +bun run tracker:down +``` + +See [tracker setup and deployment](tracker/README.md) for configuration and VPS +use. The tracker container is ready for development; automatic reconnect in +the browser is still [planned](docs/webtorrent-reconnect.md). Current app +connections continue to use manual codes. + ### Local STUN/TURN environment (Linux) Keep Vite on the host for hot reload; only coturn runs in Docker. Both bind to diff --git a/compose.tracker.yaml b/compose.tracker.yaml new file mode 100644 index 0000000..c658951 --- /dev/null +++ b/compose.tracker.yaml @@ -0,0 +1,28 @@ +# Our tracker image, built from the official Node base and pinned upstream npm package. +# Independent of coturn and its development secrets; usable alone on the VPS. +name: hellcon-tracker +services: + tracker: + build: + context: ./tracker + target: runtime + image: hellcon-tracker:local + init: true + restart: "no" + ports: + - "127.0.0.1:${TRACKER_PORT:-8000}:8000" + environment: + ANNOUNCE_INTERVAL_SECONDS: "5" + ALLOWED_ORIGINS: "${TRACKER_ALLOWED_ORIGINS:-}" + TRUSTED_PROXY_IPS: "${TRACKER_TRUSTED_PROXY_IPS:-}" + read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + mem_limit: 256m + cpus: 0.5 + pids_limit: 64 + logging: + driver: json-file + options: + max-size: "5m" + max-file: "2" diff --git a/docs/ux-roadmap.md b/docs/ux-roadmap.md index 524e454..c26f86d 100644 --- a/docs/ux-roadmap.md +++ b/docs/ux-roadmap.md @@ -1,7 +1,12 @@ # Serverless UX roadmap -The app runs over HTTPS or on localhost. No signaling backend, peer presence -service, automatic offline-peer reconnection, or silent TURN fallback is in scope. +The app runs over HTTPS or on localhost. The current build uses manual signaling. +The next planned addition is [WebTorrent tracker reconnect](webtorrent-reconnect.md): +a configurable default or custom tracker exchanges encrypted connection codes for +paired devices, without a Trystero dependency. This replaces the custom rendezvous +proposal and the earlier blanket exclusion of a signaling backend. Peer presence, +offline wake-up and silent TURN fallback remain outside scope. The reconnect +feature is planned, not implemented; the sections below describe current behavior. ## Connection workspace — implemented diff --git a/docs/webtorrent-reconnect.md b/docs/webtorrent-reconnect.md new file mode 100644 index 0000000..a1f8a6f --- /dev/null +++ b/docs/webtorrent-reconnect.md @@ -0,0 +1,271 @@ +# WebTorrent tracker reconnect (planned, not implemented) + +This replaces the custom rendezvous server proposal. HellCon will exchange fresh +connection codes through a configurable WebTorrent-compatible WebSocket tracker, +using a small client adapter built on native browser APIs. Deploy an existing +tracker implementation; do not add Trystero or the WebTorrent file-transfer +client to HellCon. Nostr is outside this plan. + +The [repository-owned tracker container](../tracker/README.md) now provides the +development/deployment foundation, using an official Node base and a locked +upstream package. Browser pairing, settings and automatic reconnect remain planned. + +Client independence takes priority: anyone can clone, fork, self-host or modify +HellCon and choose their own tracker. The client must work with any compatible +tracker and must not depend on a particular operator or on HellCon-specific +server extensions. Vue remains the only runtime dependency. + +## User experience and scope + +A paired connection gets a **Reconnect** button. Both people open that connection +and press Reconnect; the app negotiates a new WebRTC connection and authenticates +the remembered device. Both pages must be open. Files still require acceptance. +Manual code exchange remains available for initial pairing and recovery. + +Network settings gain an independent **Connection discovery** section: + +- **Manual codes**, **Default tracker**, or **Custom tracker**. +- Custom tracker: one `wss://` URL, including any required path. +- The default URL comes from `VITE_TRACKER_URL`; if unset, offer Manual and Custom. +- Show the selected host and explain that it can observe which clients meet. +- Leave STUN selection and explicit TURN consent as separate controls. +- The selection applies to new pairings; existing pairings keep their stored + trackers. + +There is no public peer directory, background presence, offline wake-up, file +storage, torrent file generation, DHT, or BitTorrent piece transfer. The tracker +only handles discovery and signaling. Reconnecting establishes a new session; +it does not resume an interrupted file transfer. + +The first release contacts one agreed tracker per pairing, but pairings store +and negotiate an ordered tracker list so fallback trackers can be added later +without a storage migration or pairing protocol change. Contacting several +trackers and automatic fallback between operators are deferred. Selecting an +endpoint is not authorization to contact additional public trackers. + +## Pairing and persistence + +After mutual device verification on a manual connection, both users can enable +**Reconnect using this tracker**. This opt-in is separate from remembering a +device and starts unticked. The manual session's offerer proposes the selected +tracker URL; the recipient sees and confirms it before the app stores or +contacts it. + +Add a versioned pairing exchange to the authenticated data channel. Both peers +contribute 32 random bytes. Derive a shared HKDF-SHA-256 base key from the ordered +contributions and a context binding both device keys and connection fingerprints. +Use an unambiguous, versioned encoding and separate derivation labels for each +purpose. Store the base key as a non-extractable CryptoKey. + +The connection record stores the paired key, the local identity public key used +for pairing, the shared key, the agreed ordered list of concrete tracker URLs (one +entry in the first release), and the reconnect +protocol version. Resolve Default to a concrete URL at pairing time: changing a +build default must not silently move existing pairings to another operator. + +Both peers acknowledge the pairing settings over the verified channel before +showing reconnect as configured. An interrupted exchange or storage failure can +leave only one peer configured; show the failure and allow manual setup to repair +the pairing. Do not claim atomic persistence across two browsers. + +Forget device, Remove connection, identity deletion/replacement, or replacement +of the paired device invalidates reconnect credentials. Re-read identity and +pairing state before each attempt and propagate local revocation across tabs. +Clearing browser storage loses pairing. A non-extractable key remains usable by +trusted application code; it does not protect against a compromised app host. + +Changing a pairing's tracker requires coordination. While connected, propose and +confirm the replacement over the authenticated channel. If the old tracker is +unavailable, exchange manual codes to agree on a replacement. A local edit alone +cannot inform an offline peer. + +## Client architecture + +Keep `src/lib/webrtc.ts`, device proofs, and the existing file session as the +transport and authentication foundation. Separate setup lifecycle code from +`TransferPanel.vue` so manual and tracker setup can feed the same session without +duplicating verification, cancellation, TURN consent, or transfer behavior. + +Introduce focused modules for pairing storage/derivation, encrypted signaling, +and the WebSocket tracker adapter. The adapter handles tracker announcements, +offer routing, answers, retries, and cleanup. It never receives file contents. + +Use native `WebSocket`, `RTCPeerConnection`, and Web Crypto. Basic WebTorrent +tracker signaling requires no Nostr-style Schnorr signature library. Preserve +HellCon's P-256 identity proofs; tracker peer IDs are routing identifiers only. +Server-side dependencies are maintained separately from the browser bundle. + +## Discovery and encrypted signaling + +Derive a 20-byte discovery identifier from the pairing secret with a dedicated +HKDF label and UTC day. Use it as the tracker's `info_hash`; it identifies a +private pairing, not a file. Derive a separate AES-256-GCM signaling key with a +different label. Near UTC midnight, temporarily join adjacent day identifiers, +deduplicate attempts, and close the unused route. Estimate clock skew from the +`Date` header of a same-origin response where available, and report skew beyond +the expiry tolerance. + +Randomize the 20-byte tracker `peer_id` per reconnect attempt and keep it stable +only for that attempt. The peer that finds the other already registered sends +the offer: announce responses report swarm counts, so the second arrival can +gather a fresh offer immediately. If both offer at once, the offer from the +lower paired device public key wins and the other peer discards its own. Reject +equal identities for this automatic role scheme and leave manual setup available. + +Use the WebSocket tracker's normal `announce`, `offers`, `offer_id`, `answer`, +and `to_peer_id` fields. Encode 20-byte identifiers as the protocol's binary +strings inside JSON, not hex strings. Use constant placeholder transfer counters +where needed; never expose actual filenames or transferred byte counts. + +Carry a versioned encrypted HellCon envelope in the offer/answer `sdp` string, +following the opaque-payload approach used by Trystero. The decrypted envelope +contains the complete HellCon identity-enabled code. Only decrypted and validated +SDP reaches `setRemoteDescription`. This is a HellCon signaling convention over +a tracker protocol, not interoperability with ordinary torrent clients or with +Trystero rooms. + +Each envelope uses a fresh random 96-bit AES-GCM IV. Authenticate the protocol +version, discovery identifier, offer ID, message role, source peer ID, and answer +destination in unambiguously encoded associated data. Include attempt nonces and +an expiry inside the ciphertext; answers must bind the outstanding offer nonce. +Fix the allowed clock skew together with the encoding. +Freeze the exact encoding and publish test vectors before implementation ships. + +Track outstanding offers and bounded duplicate caches. Ignore exact retransmits, +reject mismatched answers, and never reuse an offer from a disposed peer +connection. Expiry and duplicate checks reduce replay; they do not guarantee +that a captured offer is undeliverable after browser reload. Fresh device proofs +bound to both session nonces and fingerprints remain mandatory before releasing +file metadata. Invalid or changed identity ends automatic reconnect; switching +to manual verification requires a deliberate new manual setup. + +## Connection lifecycle and failure handling + +Trackers forward offers only to peers already registered; registration alone +does not guarantee delivery. The first arrival registers without offers and +keeps its registration alive at the tracker interval; the second arrival offers. +If a tracker reports no usable counts, fall back to bounded periodic offers and +gather a fresh offer for each one: never resend an offer whose candidates may +have expired. Configure our tracker for interactive discovery. Respect custom +tracker pacing and show a waiting state rather than assuming immediate matching. + +Limit each slot to one reconnect attempt per browser profile with a Web Locks +(`navigator.locks`) lock; propagate revocation through the existing +`BroadcastChannel`. Bound in-flight negotiations, frame sizes, peer counts and +retry state. Multiple tabs or a third party must not cause unbounded peer +allocation. Do not assume the tracker enforces two clients per room. + +Trackers deliver each offer to a random registered peer, so a third peer in the +swarm can receive an offer meant for the paired device and stall the attempt. +Send at most one offer per counted peer, up to a small cap, and report this as +a failed attempt, not an authentication failure; it denies service but cannot +authenticate as the paired device. + +Use a five-minute total attempt deadline and retain the existing ICE gathering +limit. Validate incoming frames before decrypting or creating peers. Handle +tracker rejection, malformed data, socket loss, an absent peer, stale answers, +and authentication failure with specific errors and a manual-code recovery path. + +After mutual authentication, stop announcing, send a best-effort stopped event, +and close the tracker socket. Cancel, timeout and Reset also dispose timers, +sockets and pending WebRTC peers. Tracker loss after setup does not interrupt +an established transfer. A later reconnect creates fresh signaling state. + +## Compatibility and rollout + +Plan signaling v5 for identity-enabled sessions to negotiate the pairing exchange +and bind that version into device proofs. Temporary manual v3 sessions remain +available. Existing paired v4 slots retain their trusted device key but require +one new manual session on compatible builds to enable tracker reconnect. + +Use an IndexedDB schema migration without dropping names, history or trust. +Clearing reconnect settings must not delete unrelated connection history. +Document version mismatch errors and make the tracker mode's capabilities +explicit; an older HellCon client must not silently skip authentication. + +## Self-hosting and custom endpoints + +Run a pinned release of `webtorrent/bittorrent-tracker` with WebSocket support in +a dedicated container behind the existing HTTPS reverse proxy. Expose a single +`wss://` endpoint; disable UDP/HTTP tracker APIs and public statistics. Keep the +backend port private. Build the image from a pinned package version and +lockfile; the tracker never enters HellCon's `package.json`. Run it from Compose +for local development, as with coturn, and set explicit CPU/memory, connection, +frame-size and request-rate limits in the deployment configuration. + +The reverse proxy alone provides no rate limiting. Where the pinned release lacks +per-IP limits, swarm caps or origin checks, the container runs a small start +script around the tracker library that adds them and trusts forwarded client +addresses only from the proxy. These are operator protections: the client must +not depend on them, and custom trackers without them must still work. + +Configure short announcement intervals and cleanup of stale peers and empty +swarms. Bound the total number of swarms as well as peers per swarm. Disable +payload/debug logging and identifying access logs on the tracker path. Health +checks and aggregate metrics must not expose pairing identifiers or IPs. +Origin checks can restrict normal browser use but cannot authenticate arbitrary +clients or prevent deliberate abuse. + +For Custom, require a valid `wss://` URL without embedded credentials or a fragment; +allow `ws://` loopback only in local development. Do not implement arbitrary +tracker-specific login schemes in the first release. Unsupported authentication +or payload policies produce a clear error. + +To support arbitrary user-selected secure WebSocket endpoints, the hosted build +will need `connect-src 'self' wss:` in place of its current self-only policy. +This deliberately trades a narrower exfiltration boundary for client +independence; document the broader network permission. Self-hosters may retain +an explicit +host allowlist; the UI must explain when their CSP blocks a custom endpoint. + +Public tracker compatibility is a release gate, not a blanket promise. Verify +encrypted offer forwarding, identifier encoding, payload limits, announcement +timing and usage policy against the selected implementation. Record the tested +server version and configuration. No public tracker is bundled without a policy +and availability review. + +## Privacy limits + +The tracker sees connecting IPs, Origin, discovery identifiers, temporary peer +IDs, routing fields, timing and ciphertext sizes. It can associate the clients +it matches. Other clients may also observe or probe discovery identifiers if a +tracker exposes them. An unguessable identifier helps against guessing; the +pairing secret and device proofs protect access even if that identifier leaks. + +Rotating identifiers removes a stable protocol label but does not prevent IP or +timing correlation. No-log configuration reduces retained data; it cannot stop +a malicious operator recording traffic. Self-hosting changes who observes this +metadata. Direct WebRTC traffic also exposes endpoints to network observers. +The feature provides convenient encrypted signaling, not anonymity. + +## Implementation steps and acceptance checks + +1. Prove interoperability with a pinned tracker: two native WebSocket clients + exchange bounded opaque offer/answer payloads in both arrival orders. Confirm + that announce responses count WebSocket peers and that a maximum-size code + fits the frame limit after encryption and encoding. Resolve tracker + restrictions before building the UI. +2. Add pairing negotiation, migration and revocation; test matching derivations, + domain separation, day boundaries, interrupted pairing and storage failures. +3. Add encrypted envelopes and the adapter; test tampering, replay, duplicate + routing, stale answers, third peers, retry bounds and complete cancellation. +4. Integrate discovery settings and Reconnect with the existing setup lifecycle. + Pair two browsers manually, reload both, reconnect without copying codes, + authenticate the saved peer and transfer exact bytes in both directions. +5. Verify Chromium/Firefox combinations, real separate-device networks, explicit + TURN use, tracker outage, endpoint changes, clock skew, cross-tab attempts, + forgotten devices and manual fallback. Local success alone is insufficient. +6. Validate the deployment's TLS, CSP, rate/resource limits, cleanup, log behavior + and upgrade procedure. Update user documentation only when the feature ships. + +Maintenance centers on the pinned tracker and its dependencies, browser/network +behavior, and the small HellCon adapter. Keep a reproducible local tracker fixture +so upgrades can run the same interoperability and reconnect checks. Supporting +additional discovery protocols would add independent maintenance and test paths. + +## References + +- [WebTorrent tracker server and client](https://github.com/webtorrent/bittorrent-tracker) +- [WebSocket request parsing](https://github.com/webtorrent/bittorrent-tracker/blob/master/lib/server/parse-websocket.js) +- [Trystero tracker adapter, for protocol reference](https://github.com/dmotz/trystero/blob/main/packages/torrent/src/index.ts) +- [Existing device authentication](device-identities.md) diff --git a/package.json b/package.json index 47a37fe..c507055 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,9 @@ "dev:setup": "node scripts/dev-setup.ts", "turn:up": "docker compose --env-file .env.development up -d", "turn:down": "docker compose --env-file .env.development down", + "tracker:up": "docker compose -f compose.tracker.yaml up -d --build --wait", + "tracker:down": "docker compose -f compose.tracker.yaml down", + "test:tracker": "docker build --target test -t hellcon-tracker:test tracker", "test:turn": "node scripts/browser-check.ts --turn", "build": "vue-tsc --noEmit && vite build", "preview": "vite preview", diff --git a/tracker/.dockerignore b/tracker/.dockerignore new file mode 100644 index 0000000..5b20b76 --- /dev/null +++ b/tracker/.dockerignore @@ -0,0 +1,6 @@ +* +!package.json +!package-lock.json +!server.mjs +!healthcheck.mjs +!test.mjs diff --git a/tracker/Dockerfile b/tracker/Dockerfile new file mode 100644 index 0000000..5b36c9b --- /dev/null +++ b/tracker/Dockerfile @@ -0,0 +1,24 @@ +# Official Node image; update the digest deliberately alongside tracker checks. +FROM node:24-bookworm-slim@sha256:a5f4366e834695d5f363b920c104953a535d3a9864d1bdf74566a0ebe01daee5 AS dependencies +WORKDIR /app +COPY package.json package-lock.json ./ +# Only the server entry point is used. Native client/optional accelerators and +# package lifecycle scripts are unnecessary for WebSocket tracker operation. +RUN npm ci --omit=dev --omit=optional --ignore-scripts --no-audit --no-fund \ + && npm cache clean --force + +FROM dependencies AS test +COPY server.mjs healthcheck.mjs test.mjs ./ +USER node +RUN node --test test.mjs + +FROM node:24-bookworm-slim@sha256:a5f4366e834695d5f363b920c104953a535d3a9864d1bdf74566a0ebe01daee5 AS runtime +ENV NODE_ENV=production PORT=8000 DEBUG="" +WORKDIR /app +COPY --from=dependencies /app/node_modules ./node_modules +COPY package.json server.mjs healthcheck.mjs ./ +USER node +EXPOSE 8000 +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD ["node", "healthcheck.mjs"] +CMD ["node", "server.mjs"] diff --git a/tracker/README.md b/tracker/README.md new file mode 100644 index 0000000..98506af --- /dev/null +++ b/tracker/README.md @@ -0,0 +1,125 @@ +# HellCon WebTorrent tracker container + +Our Dockerfile builds directly from the official Node image and the upstream +`bittorrent-tracker` npm package. The Node base is pinned by digest, the tracker +by version (11.2.3), and transitive dependencies by `package-lock.json`. There +is no third-party tracker image, Trystero dependency or browser package change. + +The tracker container is implemented. HellCon's automatic reconnect UI and +client adapter are still [planned](../docs/webtorrent-reconnect.md); starting +this service does not change the app's current manual-code connection flow. + +## Local development + +Start Docker, then run from the repository root: + +```sh +bun run tracker:up +bun run test:tracker +docker compose -f compose.tracker.yaml logs --tail=30 tracker +bun run tracker:down +``` + +The service listens at `ws://127.0.0.1:8000`. Choose a different host port with +`TRACKER_PORT=8001 bun run tracker:up`. Compose builds our Dockerfile and waits for +its health check; it does not start coturn or require `.env.development`. Vite +continues to run on the host. No service is enabled at boot and the development +container has no automatic restart policy. + +`test:tracker` builds the Dockerfile's test target and runs native Node WebSocket +clients against the actual tracker server. It tests both arrival orders, counts +in announce replies, a 64 KiB code after AES-GCM/base64 encoding, answer routing, +disconnect cleanup, graceful termination, disabled HTTP and WebSocket scrape, +malformed/oversized messages, swarm/rate limits, per-socket swarm and peer ID +limits (including pipelined frames), idle timeouts, origins, untrusted and +trusted forwarded IP headers and IPv6 prefix grouping. Tests do not depend on public trackers. They establish tracker +interoperability, not a complete browser reconnect or Internet NAT test. + +If you started Docker only for these checks, stop it afterward: + +```sh +sudo systemctl stop docker.service docker.socket containerd.service +``` + +## VPS deployment + +Use the same Dockerfile and `compose.tracker.yaml`. The service binds its host +port to loopback; an HTTPS reverse proxy on the host terminates TLS and forwards +WebSocket upgrades to port 8000. A Caddy example for a dedicated hostname: + +```caddyfile +tracker.example.com { + reverse_proxy 127.0.0.1:8000 +} +``` + +Clients then use `wss://tracker.example.com`. Keep access logging disabled for +this endpoint, including any logging configured elsewhere. If the proxy is +containerized, use a shared private Docker network and the service name instead +of the proxy container's loopback address. + +Set `TRACKER_ALLOWED_ORIGINS=https://your-app.example` for browser origin checks. +These checks are not client authentication. The wrapper rate-limits the socket's +source IP by default. For a proxy deployment, set `TRACKER_TRUSTED_PROXY_IPS` to +the exact source addresses the tracker sees from your proxy. The wrapper uses +the rightmost `X-Forwarded-For` entry, which must be the address your proxy saw; +proxies that replace the header (Caddy's default) or append to it both work. +Docker bridge addresses can differ from `127.0.0.1`. Without this configuration, all proxied +clients share the proxy IP's limits. Never expose the backend directly while +trusting arbitrary forwarded headers. + +Production restart behavior is an explicit operator choice. For example, add a +Compose override containing `services: {tracker: {restart: unless-stopped}}` and +pass it after `-f compose.tracker.yaml`. This does not change local development's +no-restart policy. This repository does not deploy DNS, TLS or the proxy for you. + +## Configuration + +Pass these environment variables to the container. The Compose file exposes +the origin/proxy settings through the `TRACKER_` variables above; use an override +file for the other container settings. + +| Variable | Default | Purpose | +| --- | --- | --- | +| `PORT` | `8000` | Internal HTTP/WebSocket port; keep Compose mapping in sync | +| `ANNOUNCE_INTERVAL_SECONDS` | `5` | Interval advertised to WebSocket clients | +| `MAX_PAYLOAD_BYTES` | `131072` | Maximum WebSocket message size | +| `MAX_CONNECTIONS` | `200` | Global WebSocket connection cap | +| `MAX_CONNECTIONS_PER_IP` | `8` | Connections per effective source IP; IPv6 per /64 | +| `MESSAGES_PER_MINUTE` | `120` | Handshake attempts and incoming messages per IP or /64 | +| `MAX_SWARMS` | `1000` | Discovery identifiers admitted at once | +| `MAX_PEERS_PER_SWARM` | `32` | Upstream LRU peer-cache bound; excess peers evict older entries | +| `PEER_TTL_SECONDS` | `300` | Idle socket timeout and peer cache lifetime | +| `ALLOWED_ORIGINS` | empty | Comma-separated browser origins; empty permits all | +| `TRUSTED_PROXY_IPS` | empty | Exact proxy source IPs allowed to supply forwarded addresses | + +The container runs as the unprivileged Node user. Compose applies a read-only +filesystem, drops capabilities, prevents privilege escalation and bounds CPU, +memory and process count. No persistent volume is required. Stale sockets, +expired swarm memberships, empty swarms and expired rate buckets are cleaned +periodically. `/healthz` returns 204; other ordinary HTTP routes return 404. +UDP and HTTP tracker APIs, +public statistics and WebSocket scrape requests are disabled. + +The wrapper emits a startup line and generic fatal server errors, not peer IDs, +IPs, payloads or upstream warning text. Leave `DEBUG` empty. The operator can +still observe connection metadata; this is not an anonymity service. + +## Updating + +Update `tracker/package.json` deliberately, regenerate the lockfile, and rerun +`bun run test:tracker` before rebuilding the runtime image. With npm available: + +```sh +npm install --package-lock-only --ignore-scripts --prefix tracker +``` + +Alternatively run npm inside the official Node image with this directory mounted +as its workdir. The image build uses `npm ci --omit=dev --omit=optional +--ignore-scripts`; native client components and optional accelerators are not +needed by the server entry point. The wrapper uses pinned upstream connection +hooks, so review those hooks when upgrading the tracker. Update the official +Node image digest in both Dockerfile stages for base-image security updates. + +Sources: [upstream tracker](https://github.com/webtorrent/bittorrent-tracker), +[official Node container](https://github.com/nodejs/docker-node). diff --git a/tracker/healthcheck.mjs b/tracker/healthcheck.mjs new file mode 100644 index 0000000..48215a5 --- /dev/null +++ b/tracker/healthcheck.mjs @@ -0,0 +1,4 @@ +try { + const response = await fetch(`http://127.0.0.1:${process.env.PORT || 8000}/healthz`, { signal: AbortSignal.timeout(2000) }); + process.exit(response.status === 204 ? 0 : 1); +} catch { process.exit(1); } diff --git a/tracker/package-lock.json b/tracker/package-lock.json new file mode 100644 index 0000000..82657ab --- /dev/null +++ b/tracker/package-lock.json @@ -0,0 +1,1055 @@ +{ + "name": "hellcon-tracker", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "hellcon-tracker", + "dependencies": { + "bittorrent-tracker": "11.2.3" + } + }, + "node_modules/@thaunknown/simple-peer": { + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/@thaunknown/simple-peer/-/simple-peer-10.1.2.tgz", + "integrity": "sha512-pcG35e815X43Crr/HVmOWlbsx9Jz3KD27HOhy/BwIjQkDlafzJFl0NKb8B+bf+bsnfQL/BB6Z44cMZPQaYHLYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "err-code": "^3.0.1", + "streamx": "^2.28.0", + "uint8-util": "^2.3.2", + "webrtc-polyfill": "^1.2.2" + } + }, + "node_modules/@thaunknown/simple-websocket": { + "version": "9.1.5", + "resolved": "https://registry.npmjs.org/@thaunknown/simple-websocket/-/simple-websocket-9.1.5.tgz", + "integrity": "sha512-FTrycAOMeJIHxHxH4iiq0EHMlmITvim04FGpwRcrytykg4jCFPaRYJqjo8wvBVx88TYfxrtQCaHhzaKLDKS71w==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "queue-microtask": "^1.2.3", + "streamx": "^2.28.0", + "uint8-util": "^2.3.2", + "ws": "^8.21.1" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/addr-to-ip-port": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/addr-to-ip-port/-/addr-to-ip-port-2.0.0.tgz", + "integrity": "sha512-9bYbtjamtdLHZSqVIUXhilOryNPiL+x+Q5J/Unpg4VY3ZIkK3fT52UoErj1NdUeVm3J1t2iBEAur4Ywbl/bahw==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/b4a": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.9.0.tgz", + "integrity": "sha512-dpfcF9fDNR6++cthXR67iyhgqWy9CBouAvIWhIntzBG6cvK/cnIPiZQjBwi/ZqjjBEDGfoNDtmB0kTjroOJ3pQ==", + "license": "Apache-2.0", + "peerDependencies": { + "react-native-b4a": "*" + }, + "peerDependenciesMeta": { + "react-native-b4a": { + "optional": true + } + } + }, + "node_modules/bare-events": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.9.2.tgz", + "integrity": "sha512-AIPKioV7/Y/8KfZ3AAhjPJxLLbY49S64Ym5DakZlUg75qQiTgUq9hEJoEwa4eUezPUlXRy/i5NpsKvo9jgKmoA==", + "license": "Apache-2.0", + "peerDependencies": { + "bare-abort-controller": "*" + }, + "peerDependenciesMeta": { + "bare-abort-controller": { + "optional": true + } + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/bencode": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bencode/-/bencode-4.0.1.tgz", + "integrity": "sha512-/bCR3FvgfB8AZk4LlowShU+nfaTNRM2vruJ9aejDa5LpgkCoRjFyEauFiZFxbpxVxQbBFapYCN42Er2dkE/Qgw==", + "license": "MIT", + "dependencies": { + "uint8-util": "^2.2.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/bittorrent-peerid": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/bittorrent-peerid/-/bittorrent-peerid-2.0.2.tgz", + "integrity": "sha512-V2iUvbtv31uLA8XFxbhB3f/fKTxWGaa6FI/3wSm93YAS/DS8IkeRWCyYGQ13Xbc9ajR40nsxNjGtVt7OHB3VOQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/bittorrent-tracker": { + "version": "11.2.3", + "resolved": "https://registry.npmjs.org/bittorrent-tracker/-/bittorrent-tracker-11.2.3.tgz", + "integrity": "sha512-i9pWOf1YAQWyTjDnpWwcTfEYDi5XwqD6f48pKmIHByb7x2XU86CqK+IsyMy1buKkDZ3rDKht2jIeKCZf1Dmd8g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "@thaunknown/simple-peer": "^10.0.8", + "@thaunknown/simple-websocket": "^9.1.3", + "bencode": "^4.0.0", + "bittorrent-peerid": "^2.0.0", + "chrome-dgram": "^3.0.6", + "compact2string": "^1.4.1", + "cross-fetch-ponyfill": "^1.0.3", + "debug": "^4.3.4", + "ip": "^2.0.1", + "lru": "^3.1.0", + "minimist": "^1.2.8", + "once": "^1.4.0", + "queue-microtask": "^1.2.3", + "random-iterate": "^1.0.1", + "run-parallel": "^1.2.0", + "run-series": "^1.1.9", + "socks": "^2.8.3", + "string2compact": "^2.0.1", + "uint8-util": "^2.2.5", + "unordered-array-remove": "^1.0.2", + "ws": "^8.17.0" + }, + "bin": { + "bittorrent-tracker": "bin/cmd.js" + }, + "engines": { + "node": ">=16.0.0" + }, + "optionalDependencies": { + "bufferutil": "^4.0.8", + "utf-8-validate": "^6.0.4" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "license": "MIT", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/bufferutil": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.1.0.tgz", + "integrity": "sha512-ZMANVnAixE6AWWnPzlW2KpUrxhm9woycYvPOo67jWHyFowASTEd9s+QN1EIMsSDtwhIxN4sWE1jotpuDUIgyIw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "license": "ISC" + }, + "node_modules/chrome-dgram": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/chrome-dgram/-/chrome-dgram-3.0.6.tgz", + "integrity": "sha512-bqBsUuaOiXiqxXt/zA/jukNJJ4oaOtc7ciwqJpZVEaaXwwxqgI2/ZdG02vXYWUhHGziDlvGMQWk0qObgJwVYKA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "inherits": "^2.0.4", + "run-series": "^1.1.9" + } + }, + "node_modules/compact2string": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/compact2string/-/compact2string-1.4.1.tgz", + "integrity": "sha512-3D+EY5nsRhqnOwDxveBv5T8wGo4DEvYxjDtPGmdOX+gfr5gE92c2RC0w2wa+xEefm07QuVqqcF3nZJUZ92l/og==", + "license": "BSD", + "dependencies": { + "ipaddr.js": ">= 0.1.5" + } + }, + "node_modules/cross-fetch-ponyfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cross-fetch-ponyfill/-/cross-fetch-ponyfill-1.0.3.tgz", + "integrity": "sha512-uOBkDhUAGAbx/FEzNKkOfx3w57H8xReBBXoZvUnOKTI0FW0Xvrj3GrYv2iZXUqlffC1LMGfQzhmBM/ke+6eTDA==", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "node-fetch": "^3.3.0" + } + }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "license": "MIT", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "license": "MIT", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==", + "license": "MIT" + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/events-universal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz", + "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==", + "license": "Apache-2.0", + "dependencies": { + "bare-events": "^2.7.0" + } + }, + "node_modules/expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "license": "(MIT OR WTFPL)", + "engines": { + "node": ">=6" + } + }, + "node_modules/fast-fifo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", + "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", + "license": "MIT" + }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "license": "MIT" + }, + "node_modules/github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", + "license": "MIT" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "license": "ISC" + }, + "node_modules/ip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", + "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==", + "license": "MIT" + }, + "node_modules/ip-address": { + "version": "10.7.4", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.4.tgz", + "integrity": "sha512-DWBMKyeM25D70nrIiTkgQth59/G+naKOTep6huF9j+GmeK3DMD60Zvxg5d5qQnz+38AHgou6ean2LECX+lrKDg==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/ipaddr.js": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.5.0.tgz", + "integrity": "sha512-aq+t5NAc+cS6rZQQVWC2x98CPqGtKKTMDd4Gaodv0wShnItdKg/51djkGJ1hqH+Oy0ivDftCbSLCQob8zso01w==", + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/lru": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lru/-/lru-3.1.0.tgz", + "integrity": "sha512-5OUtoiVIGU4VXBOshidmtOsvBIvcQR6FD/RzWSvaeHyxCGB+PCUCu+52lqMfdc0h/2CLvHhZS4TwUmMQrrMbBQ==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/napi-build-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz", + "integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==", + "license": "MIT" + }, + "node_modules/node-abi": { + "version": "3.99.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.99.0.tgz", + "integrity": "sha512-lLdwkeg2XUVPTHqWjPltTxH81zbQNbUWC+AEb9ni50KjxkUzAAx1HGtMT21sbntzfUGfIphhcklvs3imJeqDXw==", + "license": "MIT", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-datachannel": { + "version": "0.32.3", + "resolved": "https://registry.npmjs.org/node-datachannel/-/node-datachannel-0.32.3.tgz", + "integrity": "sha512-Aok1ZhLsll472lRefgWYuWJ0070jh0ecHravTdRyZEmoESumebMEQV8Y+poBwSW2ZbEwAokAOGsK5Cu8pDDT2g==", + "hasInstallScript": true, + "license": "MPL 2.0", + "dependencies": { + "prebuild-install": "^7.1.3" + }, + "engines": { + "node": ">=18.20.0" + } + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "deprecated": "Use your platform's native DOMException instead", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "license": "MIT", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/node-gyp-build": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz", + "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==", + "license": "MIT", + "optional": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/prebuild-install": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz", + "integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==", + "deprecated": "No longer maintained. Please contact the author of the relevant native addon; alternatives are available.", + "license": "MIT", + "dependencies": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^2.0.0", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/pump": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", + "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/random-iterate": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/random-iterate/-/random-iterate-1.0.1.tgz", + "integrity": "sha512-Jdsdnezu913Ot8qgKgSgs63XkAjEsnMcS1z+cC6D6TNXsUXsMxy0RpclF2pzGZTEiTXL9BiArdGTEexcv4nqcA==", + "license": "MIT" + }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "license": "(BSD-2-Clause OR MIT OR Apache-2.0)", + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/run-series": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/run-series/-/run-series-1.1.9.tgz", + "integrity": "sha512-Arc4hUN896vjkqCYrUXquBFtRZdv1PfLbTYP71efP6butxyQ0kWpiNJyAgsxscmQg1cqvHY32/UCBzXedTpU2g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks": { + "version": "2.8.10", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.10.tgz", + "integrity": "sha512-e0VyvkVTwVYViNovRkZ9aodhxVlyoMn7eJhVUPxZ+eK9P/7CBkxvvsBOHqFPEH416726W8tLXXXjKwqgTErrCQ==", + "license": "MIT", + "dependencies": { + "ip-address": "^10.1.1", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/streamx": { + "version": "2.28.1", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.28.1.tgz", + "integrity": "sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==", + "license": "MIT", + "dependencies": { + "events-universal": "^1.0.0", + "fast-fifo": "^1.3.2", + "text-decoder": "^1.1.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string2compact": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/string2compact/-/string2compact-2.0.2.tgz", + "integrity": "sha512-ZUUIyrS+sSj84gR6fFoz/boiqCptyw37/hMxIehReuf6ekpJOlwSXhTfEasqc5t3QucBXi2ghwLlHOSC8hjEaw==", + "license": "MIT", + "dependencies": { + "addr-to-ip-port": "^2.0.0", + "ipaddr.js": "2.0.1" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/string2compact/node_modules/ipaddr.js": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.0.1.tgz", + "integrity": "sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng==", + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tar-fs": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.5.tgz", + "integrity": "sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw==", + "license": "MIT", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "license": "MIT", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/text-decoder": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz", + "integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==", + "license": "Apache-2.0", + "dependencies": { + "b4a": "^1.6.4" + } + }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, + "node_modules/uint8-util": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/uint8-util/-/uint8-util-2.3.2.tgz", + "integrity": "sha512-u1c0/eiT1IW+c5+ogbmE2Fu2hmtJQPkuzDmXD/4crMU4FPMjkTkFnjJ2NN/9AsZ9YWcc7yE869uc3WB8wIZEEA==", + "license": "MIT" + }, + "node_modules/unordered-array-remove": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unordered-array-remove/-/unordered-array-remove-1.0.2.tgz", + "integrity": "sha512-45YsfD6svkgaCBNyvD+dFHm4qFX9g3wRSIVgWVPtm2OCnphvPxzJoe20ATsiNpNJrmzHifnxm+BN5F7gFT/4gw==", + "license": "MIT" + }, + "node_modules/utf-8-validate": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-6.0.6.tgz", + "integrity": "sha512-q3l3P9UtEEiAHcsgsqTgf9PPjctrDWoIXW3NpOHFdRDbLvu4DLIcxHangJ4RLrWkBcKjmcs/6NkerI8T/rE4LA==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/webrtc-polyfill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/webrtc-polyfill/-/webrtc-polyfill-1.2.2.tgz", + "integrity": "sha512-t/H2OySa7lZSq2f5j4whmr+IWCl5TqF4daGotE8VhPP7U+E4x5x8MK1wqOkqlb4xxRlag4kBB9enU4oxNk//+g==", + "license": "MIT", + "dependencies": { + "node-datachannel": "^0.32.3" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, + "node_modules/ws": { + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", + "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/tracker/package.json b/tracker/package.json new file mode 100644 index 0000000..baa9e88 --- /dev/null +++ b/tracker/package.json @@ -0,0 +1,12 @@ +{ + "name": "hellcon-tracker", + "private": true, + "type": "module", + "scripts": { + "start": "node server.mjs", + "test": "node --test test.mjs" + }, + "dependencies": { + "bittorrent-tracker": "11.2.3" + } +} diff --git a/tracker/server.mjs b/tracker/server.mjs new file mode 100644 index 0000000..1b5576f --- /dev/null +++ b/tracker/server.mjs @@ -0,0 +1,167 @@ +import { isIP } from 'node:net'; +import Server from 'bittorrent-tracker/server'; + +function integer(name, fallback, max = 1_000_000) { + const value = Number(process.env[name] ?? fallback); + if (!Number.isSafeInteger(value) || value < 1 || value > max) throw new Error(`Invalid ${name}`); + return value; +} +const port = integer('PORT', 8000, 65535); +const interval = integer('ANNOUNCE_INTERVAL_SECONDS', 5, 600); +const maxPayload = integer('MAX_PAYLOAD_BYTES', 128 * 1024); +const maxConnections = integer('MAX_CONNECTIONS', 200); +const maxPerIp = integer('MAX_CONNECTIONS_PER_IP', 8); +const maxMessages = integer('MESSAGES_PER_MINUTE', 120); +const maxSwarms = integer('MAX_SWARMS', 1000); +const maxPeers = integer('MAX_PEERS_PER_SWARM', 32); +const peerAge = integer('PEER_TTL_SECONDS', 300); +const list = name => (process.env[name] || '').split(',').map(item => item.trim()).filter(Boolean); +const normalizeIp = ip => ip?.replace(/^::ffff:/, '') || ''; +const origins = new Set(list('ALLOWED_ORIGINS')); +const proxies = new Set(list('TRUSTED_PROXY_IPS').map(normalizeIp)); +const clientsPerIp = new Map(); +const rates = new Map(); +const admittedSwarms = new Set(); + +function allowRequest(ip) { + const now = Date.now(); + let bucket = rates.get(ip); + if (!bucket || now >= bucket.until) { + bucket = { count: 0, until: now + 60_000 }; + rates.set(ip, bucket); + } + return ++bucket.count <= maxMessages; +} +function clientIp(req) { + const remote = normalizeIp(req.socket.remoteAddress); + const forwarded = req.headers['x-forwarded-for']; + if (proxies.has(remote) && typeof forwarded === 'string') { + // The trusted proxy's observed address is last; earlier entries are client-supplied. + const last = forwarded.split(',').at(-1).trim(); + if (isIP(last)) return normalizeIp(last); + } + return remote; +} +// IPv6 hosts commonly control a whole /64, so limits apply per prefix. +function limitKey(ip) { + if (isIP(ip) !== 6) return ip; + const [head, tail] = ip.replace(/%.*$/, '').split('::'); + // An embedded IPv4 suffix fills the last two groups, never the prefix. + const groups = part => part ? part.split(':').flatMap(group => group.includes('.') ? ['0', '0'] : [group]) : []; + const start = groups(head), end = groups(tail); + const all = tail === undefined ? start : [...start, ...Array(8 - start.length - end.length).fill('0'), ...end]; + return all.slice(0, 4).map(group => parseInt(group, 16).toString(16)).join(':') + '::/64'; +} +const binaryId = value => typeof value === 'string' && value.length === 20 && !/[^\x00-\xff]/.test(value); +const description = (value, type) => value && value.type === type && typeof value.sdp === 'string' && value.sdp.length <= maxPayload; + +// These hooks are tied to the pinned upstream release. Keep the integration +// tests when upgrading: upstream owns routing, this wrapper bounds its input. +class Tracker extends Server { + onWebSocketConnection(socket, opts) { + const ip = socket.upgradeReq.hellconIp; + socket.hellconIp = ip; + socket.hellconSeen = Date.now(); + // Upstream records joined swarms only after async routing, so pipelined + // frames would all pass a check against socket.infoHashes. + socket.hellconHashes = new Set(); + clientsPerIp.set(ip, (clientsPerIp.get(ip) || 0) + 1); + socket.once('close', () => { + const remaining = (clientsPerIp.get(ip) || 1) - 1; + if (remaining) clientsPerIp.set(ip, remaining); + else clientsPerIp.delete(ip); + }); + super.onWebSocketConnection(socket, opts); + } + + _onWebSocketRequest(socket, opts, raw) { + if (!allowRequest(socket.hellconIp)) { socket.close(1008, 'Rate limit'); return; } + let data; + try { data = JSON.parse(raw); } catch { socket.close(1008, 'Invalid JSON'); return; } + // Scraping can enumerate private discovery identifiers. No scrape API is + // exposed, including over WebSocket when HTTP statistics are disabled. + if (!data || data.action !== 'announce' || !binaryId(data.info_hash) || !binaryId(data.peer_id) || + (data.event && !['started', 'stopped', 'completed', 'update', 'paused'].includes(data.event)) || + (data.offers !== undefined && (!Array.isArray(data.offers) || data.offers.length > 8 || + data.offers.some(item => !item || !binaryId(item.offer_id) || !description(item.offer, 'offer')))) || + (data.answer !== undefined && (!description(data.answer, 'answer') || !binaryId(data.offer_id) || !binaryId(data.to_peer_id)))) { + socket.close(1008, 'Invalid announce'); return; + } + if (socket.peerId && socket.peerId !== Buffer.from(data.peer_id, 'latin1').toString('hex')) { + socket.close(1008, 'Peer ID changed'); return; + } + const hash = Buffer.from(data.info_hash, 'latin1').toString('hex'); + if (!socket.hellconHashes.has(hash)) { + if (socket.hellconHashes.size >= 4) { socket.close(1008, 'Too many swarms'); return; } + socket.hellconHashes.add(hash); + } + socket.hellconSeen = Date.now(); + super._onWebSocketRequest(socket, opts, raw); + } +} + +const server = new Tracker({ + http: false, udp: false, stats: false, trustProxy: false, + // Upstream divides the configured interval by five for WebSocket responses. + interval: interval * 5000, + peersCacheLength: maxPeers, + peersCacheTtl: peerAge * 1000, + ws: { + clientTracking: true, + maxPayload, + verifyClient({ req, origin }) { + const ip = limitKey(clientIp(req)); + req.hellconIp = ip; + return (!origins.size || origins.has(origin)) && + server.ws.clients.size < maxConnections && (clientsPerIp.get(ip) || 0) < maxPerIp && allowRequest(ip); + }, + }, + filter(hash, params, done) { + if (!admittedSwarms.has(hash) && admittedSwarms.size >= maxSwarms) { + done(new Error('Tracker capacity reached')); return; + } + admittedSwarms.add(hash); + done(null); + }, +}); + +server.http.on('request', (req, res) => { + if (req.method === 'GET' && req.url === '/healthz') { + res.writeHead(204, { 'Cache-Control': 'no-store' }); res.end(); + } +}); +// Never log raw upstream errors: they can contain attacker-controlled fields. +server.on('warning', () => {}); +server.on('error', () => { console.error('Tracker server error'); shutdown(1); }); + +const cleanup = setInterval(() => { + const now = Date.now(); + for (const socket of server.ws.clients) { + if (now - socket.hellconSeen > peerAge * 1000) socket.terminate(); + } + for (const hash of admittedSwarms) { + const swarm = server.torrents[hash]; + // Upstream's LRU expires peers only when read; peeking evicts stale entries + // through its synthetic 'stopped' handling before the emptiness check. + swarm?.peers.keys.forEach(key => swarm.peers.peek(key)); + if (!swarm || !swarm.peers.keys.length) { + delete server.torrents[hash]; admittedSwarms.delete(hash); + } + } + for (const [ip, bucket] of rates) if (now >= bucket.until) rates.delete(ip); +}, Math.min(10_000, peerAge * 1000)); +cleanup.unref(); + +let stopping = false; +function shutdown(code = 0) { + if (stopping) return; + stopping = true; + clearInterval(cleanup); + const deadline = setTimeout(() => process.exit(code), 3000); + deadline.unref(); + for (const socket of server.ws.clients) socket.terminate(); + server.close(() => process.exit(code)); +} +process.on('SIGTERM', () => shutdown()); +process.on('SIGINT', () => shutdown()); +server.listen(port, '0.0.0.0', () => console.log(`WebSocket tracker listening on port ${port}`)); diff --git a/tracker/test.mjs b/tracker/test.mjs new file mode 100644 index 0000000..c6dc792 --- /dev/null +++ b/tracker/test.mjs @@ -0,0 +1,284 @@ +import assert from 'node:assert/strict'; +import { spawn } from 'node:child_process'; +import { randomBytes, webcrypto } from 'node:crypto'; +import { createConnection, createServer } from 'node:net'; +import { setTimeout as delay } from 'node:timers/promises'; +import { test } from 'node:test'; + +const id = () => randomBytes(20).toString('latin1'); + +async function start(t, env = {}) { + const reservation = createServer(); + await new Promise(resolve => reservation.listen(0, '127.0.0.1', resolve)); + const port = reservation.address().port; + await new Promise(resolve => reservation.close(resolve)); + const child = spawn(process.execPath, ['server.mjs'], { + cwd: import.meta.dirname, + env: { ...process.env, PORT: String(port), ...env }, + stdio: ['ignore', 'pipe', 'pipe'], + }); + let output = ''; + child.stdout.on('data', data => { output += data; }); + child.stderr.on('data', data => { output += data; }); + const exited = new Promise(resolve => child.once('exit', (code, signal) => resolve({ code, signal }))); + t.after(async () => { + child.kill('SIGTERM'); + const timer = setTimeout(() => child.kill('SIGKILL'), 5000); + const result = await exited; + clearTimeout(timer); + assert.deepEqual(result, { code: 0, signal: null }, output); + assert.match(output, /^WebSocket tracker listening on port \d+\n$/); + }); + const http = `http://127.0.0.1:${port}`; + for (let n = 0; n < 100; n++) { + if (child.exitCode !== null) throw new Error(output); + try { + if ((await fetch(http + '/healthz')).status === 204) return { http, ws: `ws://127.0.0.1:${port}` }; + } catch { /* startup */ } + await delay(25); + } + throw new Error('Tracker did not become healthy: ' + output); +} + +async function connect(t, url) { + const socket = new WebSocket(url); + const frames = []; + socket.addEventListener('message', event => frames.push(JSON.parse(event.data))); + const closed = new Promise(resolve => socket.addEventListener('close', resolve, { once: true })); + t.after(async () => { socket.close(); await closed; }); + await new Promise((resolve, reject) => { + socket.addEventListener('open', resolve, { once: true }); + socket.addEventListener('error', () => reject(new Error('WebSocket connection failed')), { once: true }); + }); + return { + socket, closed, + send(data) { socket.send(JSON.stringify(data)); }, + async next(predicate) { + for (let n = 0; n < 200; n++) { + const index = frames.findIndex(predicate); + if (index >= 0) return frames.splice(index, 1)[0]; + if (socket.readyState === WebSocket.CLOSED) throw new Error('Socket closed before expected frame'); + await delay(10); + } + throw new Error('Expected tracker frame did not arrive'); + }, + }; +} +const announce = (peer, hash, extra = {}) => ({ + action: 'announce', info_hash: hash, peer_id: peer, uploaded: 0, downloaded: 0, + left: 1, numwant: 0, offers: [], ...extra, +}); + +for (const offererFirst of [false, true]) { + test(`encrypted signaling survives tracker routing, offerer arrives ${offererFirst ? 'first' : 'second'}`, { timeout: 15000 }, async t => { + const endpoint = await start(t); + const first = await connect(t, endpoint.ws); + const second = await connect(t, endpoint.ws); + const hash = id(), offerId = id(), sender = id(), receiver = id(); + const key = await webcrypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']); + // A maximum-size connection code plus envelope metadata must fit after + // encryption/base64, even though its sdp field is deliberately opaque. + const plaintext = JSON.stringify({ version: 1, code: 'a'.repeat(64 * 1024), nonce: randomBytes(32).toString('hex') }); + const iv = randomBytes(12); + const cipher = await webcrypto.subtle.encrypt({ name: 'AES-GCM', iv }, key, Buffer.from(plaintext)); + const encrypted = Buffer.concat([iv, Buffer.from(cipher)]).toString('base64url'); + const offered = { type: 'offer', sdp: encrypted }; + const offerFrame = announce(sender, hash, { offers: [{ offer_id: offerId, offer: offered }], numwant: 1 }); + if (offererFirst) { + first.send(offerFrame); + const alone = await first.next(frame => frame.interval); + assert.equal(alone.complete + alone.incomplete, 1); + } + second.send(announce(receiver, hash)); + await second.next(frame => frame.interval); + first.send(offerFrame); + const offer = await second.next(frame => frame.offer); + assert.deepEqual(offer.offer, offered); + assert.equal(offer.peer_id, sender); + assert.equal(offer.info_hash, hash); + assert.equal(offer.offer_id, offerId); + const wire = Buffer.from(offer.offer.sdp, 'base64url'); + const decrypted = await webcrypto.subtle.decrypt({ name: 'AES-GCM', iv: wire.subarray(0, 12) }, key, wire.subarray(12)); + assert.equal(Buffer.from(decrypted).toString(), plaintext); + const answer = { type: 'answer', sdp: encrypted }; + second.send(announce(receiver, hash, { answer, offer_id: offerId, to_peer_id: sender })); + const response = await first.next(frame => frame.answer); + assert.deepEqual(response.answer, answer); + assert.equal(response.peer_id, receiver); + const counts = await first.next(frame => frame.interval); + assert.equal(counts.interval, 5); + assert.equal(counts.complete + counts.incomplete, 2); + second.socket.close(); + await second.closed; + first.send(announce(sender, hash)); + const afterClose = await first.next(frame => frame.interval); + assert.equal(afterClose.complete + afterClose.incomplete, 1); + }); +} + +test('health is public; HTTP APIs, WebSocket scrape and malformed frames are disabled', { timeout: 15000 }, async t => { + const endpoint = await start(t); + for (const path of ['/stats', '/stats.json', '/announce', '/scrape']) { + assert.equal((await fetch(endpoint.http + path)).status, 404); + } + for (const payload of [{ action: 'scrape' }, { action: 'announce', info_hash: 'bad' }, null]) { + const client = await connect(t, endpoint.ws); + client.send(payload); + assert.equal((await client.closed).code, 1008); + } + const badJson = await connect(t, endpoint.ws); + badJson.socket.send('{'); + assert.equal((await badJson.closed).code, 1008); + const oversized = await connect(t, endpoint.ws); + oversized.socket.send('x'.repeat(128 * 1024 + 1)); + assert.equal((await oversized.closed).code, 1009); + assert.equal((await fetch(endpoint.http + '/healthz')).status, 204); +}); + +test('swarm capacity and message rate are bounded', { timeout: 15000 }, async t => { + const endpoint = await start(t, { MAX_SWARMS: '1', MESSAGES_PER_MINUTE: '4' }); + const client = await connect(t, endpoint.ws); + const peer = id(), hash = id(); + client.send(announce(peer, hash)); + await client.next(frame => frame.interval); + client.send(announce(peer, id())); + assert.equal((await client.next(frame => frame['failure reason']))['failure reason'], 'Tracker capacity reached'); + client.send(announce(peer, hash)); + await client.next(frame => frame.interval); + client.send(announce(peer, hash)); + assert.equal((await client.closed).code, 1008); +}); + +// Node's WebSocket accepts non-standard headers, which browsers cannot set. +const attempt = (t, url, origin, forwarded) => new Promise(resolve => { + const headers = {}; + if (origin) headers.Origin = origin; + if (forwarded) headers['X-Forwarded-For'] = forwarded; + const socket = new WebSocket(url, { headers }); + socket.addEventListener('open', () => resolve(socket), { once: true }); + socket.addEventListener('error', () => resolve(null), { once: true }); + t.after(() => socket.close()); +}); +const closeOf = socket => new Promise(resolve => socket.addEventListener('close', ({ code, reason }) => resolve({ code, reason }), { once: true })); + +// WebSocket clients cannot force several frames into one TCP write, so this +// speaks just enough RFC 6455 to pipeline masked text frames. +function pipeline(t, url, messages) { + const { hostname, port } = new URL(url); + const socket = createConnection(Number(port), hostname); + t.after(() => socket.destroy()); + const frame = text => { + const payload = Buffer.from(text); + const length = payload.length < 126 ? [payload.length] : [126, payload.length >> 8, payload.length & 0xff]; + // A zero masking key leaves the payload unchanged. + return Buffer.concat([Buffer.from([0x81, 0x80 | length[0], ...length.slice(1)]), Buffer.alloc(4), payload]); + }; + socket.write(`GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n` + + `Sec-WebSocket-Key: ${randomBytes(16).toString('base64')}\r\nSec-WebSocket-Version: 13\r\n\r\n`); + return new Promise((resolve, reject) => { + let buffer = Buffer.alloc(0), upgraded = false; + socket.on('error', reject); + socket.on('close', () => reject(new Error('Socket closed without a close frame'))); + socket.on('data', data => { + buffer = Buffer.concat([buffer, data]); + if (!upgraded) { + const end = buffer.indexOf('\r\n\r\n'); + if (end < 0) return; + if (!buffer.toString('latin1', 0, end).startsWith('HTTP/1.1 101')) { reject(new Error('Upgrade refused')); return; } + upgraded = true; + buffer = buffer.subarray(end + 4); + socket.write(Buffer.concat(messages.map(message => frame(JSON.stringify(message))))); + } + // Server frames are unmasked; tracker replies stay below 64 KiB. + while (buffer.length >= 2) { + let length = buffer[1] & 0x7f, start = 2; + if (length === 126) { + if (buffer.length < 4) return; + length = buffer.readUInt16BE(2); start = 4; + } + if (buffer.length < start + length) return; + if ((buffer[0] & 0x0f) === 8) { + resolve({ code: buffer.readUInt16BE(start), reason: buffer.toString('utf8', start + 2, start + length) }); + socket.destroy(); return; + } + buffer = buffer.subarray(start + length); + } + }); + }); +} + +test('origin and per-IP connection checks apply; untrusted forwarded IPs cannot bypass the limit', { timeout: 15000 }, async t => { + const endpoint = await start(t, { ALLOWED_ORIGINS: 'https://other.example , https://hellcon.example', MAX_CONNECTIONS_PER_IP: '1' }); + assert.equal(await attempt(t, endpoint.ws, 'https://evil.example', '192.0.2.1'), null); + const accepted = await attempt(t, endpoint.ws, 'https://hellcon.example', '192.0.2.1'); + assert.ok(accepted); + assert.equal(await attempt(t, endpoint.ws, 'https://hellcon.example', '192.0.2.2'), null); +}); + +test('trusted proxies supply the rightmost forwarded IP; IPv6 limits apply per /64', { timeout: 15000 }, async t => { + const endpoint = await start(t, { TRUSTED_PROXY_IPS: ' ::ffff:127.0.0.1 ', MAX_CONNECTIONS_PER_IP: '1' }); + const connect = forwarded => attempt(t, endpoint.ws, undefined, forwarded); + assert.ok(await connect('198.51.100.7, 192.0.2.1')); + // Spoofed leftmost entries do not create a fresh limit bucket. + assert.equal(await connect('198.51.100.8, 192.0.2.1'), null); + assert.ok(await connect('192.0.2.2')); + assert.ok(await connect('2001:db8::1')); + assert.equal(await connect('2001:db8:0:0:ffff::2'), null); + assert.equal(await connect('2001:DB8:0000::1.2.3.4'), null); + assert.ok(await connect('2001:db8:0:1::1')); +}); + +test('a socket keeps one peer ID and joins at most four swarms, even with pipelined frames', { timeout: 15000 }, async t => { + const endpoint = await start(t); + const sequential = await attempt(t, endpoint.ws); + const replies = []; + sequential.addEventListener('message', event => replies.push(JSON.parse(event.data))); + const peer = id(), hashes = [id(), id(), id(), id()]; + for (const hash of [...hashes, hashes[0]]) sequential.send(JSON.stringify(announce(peer, hash))); + for (let n = 0; replies.filter(frame => frame.interval).length < 5; n++) { + assert.ok(n < 200, 'Expected five announce replies'); + await delay(10); + } + const fifth = closeOf(sequential); + sequential.send(JSON.stringify(announce(peer, id()))); + assert.deepEqual(await fifth, { code: 1008, reason: 'Too many swarms' }); + + const batchPeer = id(); + const batch = Array.from({ length: 8 }, () => announce(batchPeer, id())); + assert.deepEqual(await pipeline(t, endpoint.ws, batch), { code: 1008, reason: 'Too many swarms' }); + + const changing = await attempt(t, endpoint.ws); + const changed = closeOf(changing); + const hash = id(); + changing.send(JSON.stringify(announce(id(), hash))); + changing.send(JSON.stringify(announce(id(), hash))); + assert.deepEqual(await changed, { code: 1008, reason: 'Peer ID changed' }); +}); + +test('memberships a live socket stops refreshing expire after the peer TTL', { timeout: 15000 }, async t => { + const endpoint = await start(t, { PEER_TTL_SECONDS: '1' }); + const active = await connect(t, endpoint.ws); + const peer = id(), kept = id(), abandoned = id(); + active.send(announce(peer, kept)); + active.send(announce(peer, abandoned)); + await active.next(frame => frame.interval); + await active.next(frame => frame.interval); + const keepAlive = setInterval(() => active.send(announce(peer, kept)), 250); + t.after(() => clearInterval(keepAlive)); + await delay(2500); + const late = await connect(t, endpoint.ws); + late.send(announce(id(), abandoned)); + const counts = await late.next(frame => frame.interval); + assert.equal(counts.complete + counts.incomplete, 1); + assert.equal(active.socket.readyState, WebSocket.OPEN); +}); + +test('idle sockets are terminated after the peer TTL', { timeout: 15000 }, async t => { + const endpoint = await start(t, { PEER_TTL_SECONDS: '1' }); + const client = await connect(t, endpoint.ws); + client.send(announce(id(), id())); + await client.next(frame => frame.interval); + const started = Date.now(); + assert.equal((await client.closed).code, 1006); + assert.ok(Date.now() - started < 3000); +});