Skip to content

c0mpute edge: https for Moshpit names pointed at c0mpute sites - #31

Merged
ralyodio merged 1 commit into
mainfrom
feat/c0mpute-edge
Nov 9, 2026
Merged

ralyodio merged 1 commit into
mainfrom
feat/c0mpute-edge

Conversation

@ralyodio

@ralyodio ralyodio commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

What

bin/moshpit-c0mpute-edge.ts (+ lib/c0mpute-edge.ts, systemd/moshpit-c0mpute-edge.service): the TLS terminator for Moshpit names whose holders ran moshcode name c0mpute <name> <site_id> (registry side: moshcoder/moshcode#600).

browser --TLS (Moshpit CA leaf)--> edge --HTTP--> any healthy c0mpute gateway --libp2p--> hosting nodes

Why an edge and not DNS straight at gateways: gateways serve plain HTTP on :7777 with no Moshpit certificate, so https://<name> cannot work against them in a real browser. The edge is the only hop that needs a cert; nothing on the c0mpute side changes and no c0mpute server is on the path (any gateway serves any site).

  • Certs: on the first handshake for a name the edge asks the registry which site it is; only then does it make a P-256 key + CSR (openssl) and POST to /api/moshpit/tlds/:tld/certs with its own API key. The registry signs for the edge account only while the holder has the name on c0mpute. One issuance in flight per name; leaves cached on disk (key 0600, written by rename) and renewed in the background inside their last 10 days. An SNI that is not a c0mpute name never reaches the CA.
  • Gateways: C0MPUTE_GATEWAYS seeds + discovery from C0MPUTE_NODES_URL (default c0mpute.com/api/nodes, gateway field: profullstack/c0mpute PR adds it). /healthz every minute; fastest first, rotating among equals; a failing gateway backs off 10 s doubling to 5 min; last good list kept when discovery fails.
  • Serving: https://<name>/path -> /s/<site_id>/path, failover on refused/timeout/5xx, GET/HEAD only, only static-site headers passed back (no Set-Cookie), 421 when Host != SNI, 502 when no gateway answers. Plain http serves the same sites (no redirect, like moshpit-origin.conf).
  • README "c0mpute edge" section with the env table.

Tests

tests/c0mpute-edge.test.ts, real sockets: fake registry that signs CSRs with an openssl CA, a broken (503) and a working gateway, https client trusting only that CA. Covers serving + path mapping, header filtering, issue-once then disk/memory, no cert (and no CA call) for non-c0mpute names, 421, http GET/HEAD/405/404/400/502, pool discovery/ordering/rotation/back-off, site lookup caching and outage behaviour.

Full suite: node --test tests/*.test.ts 107/107. tsc --noEmit: no errors in new files (2 pre-existing errors in tests/reconcile-ca-trigger.test.ts and tests/trust.test.ts, unchanged).

Not deployed; it needs its own box/address with 80/443 free (see README).

🤖 Generated with Claude Code

bin/moshpit-c0mpute-edge.ts terminates TLS for names whose holders ran
`moshcode name c0mpute <name> <site_id>`, with a leaf the Moshpit CA signs
for the edge account on first use (key + CSR by openssl, kept on disk,
renewed inside the last ten days), and maps https://<name>/path to
/s/<site_id>/path on the fastest healthy c0mpute gateway, failing over on
refused connections, timeouts and 5xx. Gateways come from C0MPUTE_GATEWAYS
seeds and the public node list (`gateway` field), health-checked every
minute; the last good list survives a failed discovery. An SNI that is not
a c0mpute name never reaches the CA, and a Host that disagrees with the SNI
gets 421. Plain http serves the same sites.

Tests run real sockets: a fake registry signing with an openssl CA, a
broken and a working gateway, and an https client trusting only that CA.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

ralyodio added a commit to profullstack/c0mpute that referenced this pull request Nov 9, 2026
#151)

A gateway whose operator set gateway.announce now puts its public origin
in its capability ad (`gateway`), and the node board publishes it as
`gateway` on /nodes and /api/nodes. Opt-in (nothing without the setting,
never in private mode, only with the gateway role), re-validated by the
aggregator to a bare http(s) origin with no credentials.

This is how a client that is not a libp2p peer (the Moshpit c0mpute edge,
profullstack/moshpit-proxy#31) finds gateways to fetch /s/<site>/ from,
without a central list.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@ralyodio
ralyodio merged commit e5e76d6 into main Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant