@uuaid/pillar 2.7.3 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOSTING-LIMITS.md +122 -0
- package/README.md +288 -1
- package/bin/carrier.mjs +104 -1
- package/bin/pillar-directory.mjs +34 -5
- package/bin/pillar-seed.mjs +129 -11
- package/bin/pillar.mjs +11 -4
- package/package.json +1 -1
- package/src/mailbox/mailbox.mjs +12 -0
- package/src/net/carrier-client.mjs +37 -9
- package/src/net/carrier-server.mjs +287 -25
- package/src/net/discovery.mjs +94 -0
- package/src/net/inbox-auth.mjs +100 -0
- package/src/net/refusals.mjs +24 -0
- package/src/net/seed-registry.mjs +374 -39
- package/src/net/seed-tier.mjs +35 -1
- package/src/net/tunnel-client.mjs +456 -0
- package/src/net/tunnel-relay.mjs +786 -0
- package/src/net/tunnel.mjs +292 -0
- package/src/notify-store.mjs +4 -1
- package/src/pillar.mjs +541 -9
- package/src/registry/directory-flags.mjs +7 -0
- package/src/registry/stats.mjs +1 -1
- package/src/vnext/continuity-cli.mjs +399 -0
- package/src/vnext/continuity.mjs +1801 -0
- package/src/vnext/init-cli.mjs +23 -7
- package/src/vnext/json-dir-mailbox.mjs +6 -0
- package/src/vnext/jsonl-mailbox.mjs +177 -23
- package/src/vnext/knock-cli.mjs +18 -0
- package/src/vnext/retired-import.mjs +556 -0
- package/src/vnext/verify-cli.mjs +1 -1
package/HOSTING-LIMITS.md
CHANGED
|
@@ -423,6 +423,106 @@ server {
|
|
|
423
423
|
}
|
|
424
424
|
```
|
|
425
425
|
|
|
426
|
+
**A tunnel relay (2.8.0).** A carrier started with `--accept-tunnels` (README
|
|
427
|
+
"Egress seed") also needs `/v1/tunnel` passed as a WebSocket and `/e/` passed
|
|
428
|
+
like `/v1/` (40 s, `X-Forwarded-For` replaced, the same body size and CORS):
|
|
429
|
+
|
|
430
|
+
```caddyfile
|
|
431
|
+
# inside the site block above; Caddy passes WebSocket upgrades as they are
|
|
432
|
+
reverse_proxy /v1/tunnel 127.0.0.1:8799
|
|
433
|
+
reverse_proxy /e/* 127.0.0.1:8799 {
|
|
434
|
+
header_up X-Forwarded-For {remote_host}
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
```nginx
|
|
439
|
+
location = /v1/tunnel {
|
|
440
|
+
proxy_pass http://127.0.0.1:8799;
|
|
441
|
+
proxy_http_version 1.1;
|
|
442
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
443
|
+
proxy_set_header Connection "upgrade";
|
|
444
|
+
proxy_set_header X-Forwarded-For $remote_addr;
|
|
445
|
+
proxy_read_timeout 120s; # the relay pings every 20 s
|
|
446
|
+
}
|
|
447
|
+
location /e/ {
|
|
448
|
+
# the same CORS lines as location /v1/ above
|
|
449
|
+
client_max_body_size 520k;
|
|
450
|
+
proxy_pass http://127.0.0.1:8799;
|
|
451
|
+
proxy_http_version 1.1;
|
|
452
|
+
proxy_read_timeout 45s;
|
|
453
|
+
proxy_set_header Host $host;
|
|
454
|
+
proxy_set_header X-Forwarded-For $remote_addr;
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
The relay answers every `/e/*` request with `cache-control: no-store`; do not
|
|
459
|
+
add a proxy cache in front of `/e/`, and do not log `x-pillar-*` headers.
|
|
460
|
+
A 2.8.0 client never configures a seed served through a tunnel relay
|
|
461
|
+
automatically; agents add its `<origin>/e/<id>` URL to their carriers by hand
|
|
462
|
+
(README "Egress seed"). A 2.8.1 registry lists it in `directory.json` `seeds[]`
|
|
463
|
+
for reach only, with its `uuaid` and `relay`, once a round trip with inbox auth
|
|
464
|
+
v2 and the seed's served proof passed for its current URL, key and relay pin;
|
|
465
|
+
a 2.8.1 `pillar init --directory` takes at most 4 such entries (README
|
|
466
|
+
"Relayed seeds in the directory"). A carrier started with
|
|
467
|
+
`--accept-tunnels open` (2.8.1, README "Open relay") admits any seed that proves
|
|
468
|
+
its uuaid key; proxy it the same way. Its stdout has one meter line per stream
|
|
469
|
+
(route template, status, bytes, ms): that is the usage record, with no header.
|
|
470
|
+
|
|
471
|
+
**Inbox auth nonces (2.8.1).** A carrier that takes inbox auth v2 (a relayed
|
|
472
|
+
seed, or a carrier with `--public-url`) stores each v2 nonce until its
|
|
473
|
+
5-minute window ends (at most ts + 5 min + 1 s), with an index on the expiry
|
|
474
|
+
time. It holds at most 100,000 at once, about 10 MiB (measured: 10.4 MiB of
|
|
475
|
+
database for 100,000 rows with both indexes). Behind a relay, one client
|
|
476
|
+
address at the relay's 600 reads a minute fills about 6,000 in 10 minutes, so
|
|
477
|
+
about 16 such addresses fill it. A direct carrier with `--public-url` has no
|
|
478
|
+
per-address limit on `wait=0` reads (below), so one address can fill it:
|
|
479
|
+
rate-limit `/v1/inbox/` in your proxy. When it is full, new v2 reads get 503 `inbox-auth-busy`
|
|
480
|
+
until stored nonces expire; no stored nonce is dropped early, so a replay is
|
|
481
|
+
still refused. v1 reads use no nonce. A full store also fails a registry's
|
|
482
|
+
round trips to that seed, so its listing and vetting lapse until space
|
|
483
|
+
returns. The bound is not a flag in 2.8.1.
|
|
484
|
+
|
|
485
|
+
**Relayed seed memory (2.8.0).** Per tunnel, that is per `pillar-seed --relay`
|
|
486
|
+
process: inbox pages held for clients are bounded by `--response-budget` (32
|
|
487
|
+
MiB reserved by default; a page reserves twice its stored bytes, so at most
|
|
488
|
+
about 16 MiB of mail). Past the budget large reads get 503 `seed-busy` (pages
|
|
489
|
+
up to about 128 KiB keep an eighth of the budget). One client address that
|
|
490
|
+
already holds a page may hold at most a quarter of the budget; past that its
|
|
491
|
+
reads get `seed-busy` at once. Four addresses that each hold a quarter fill
|
|
492
|
+
the budget: large reads from any other address then get `seed-busy` until
|
|
493
|
+
those pages end (measured with four reading addresses: 40 of 48 large reads
|
|
494
|
+
refused at once, none cut off, chat-size reads still served). The seed sends to client addresses in turns,
|
|
495
|
+
one frame each, so many reads from one address share the tunnel's rate with
|
|
496
|
+
one read from another. A client that takes no bytes for 10 s while bytes wait
|
|
497
|
+
for it at the relay is dropped and its page returned; while the tunnel is
|
|
498
|
+
short of credit nothing may wait there, and such a client stays until the 40
|
|
499
|
+
s stream deadline. That rule, the address's stream count and the relay's
|
|
500
|
+
queued-byte cap still apply after the seed has sent the end of an answer,
|
|
501
|
+
until its last byte is in the client's socket (bytes in kernel buffers after
|
|
502
|
+
that are not seen). With 30 never-read reads of 401 KiB pages from one address
|
|
503
|
+
and 30 of 111 KiB pages from another, each healthy read timed from its own
|
|
504
|
+
start (three runs): a reader of 2 MiB pages from a third address got 4 of 4,
|
|
505
|
+
the slowest in 19.7 to 20.6 s (at least 19.4 s before the deadline), and chat
|
|
506
|
+
reads took at most 0.4 s; 17 of the first address's reads were refused within
|
|
507
|
+
2 s, none reached the deadline, and the budget peaked at 15.7 of 32 MiB. With
|
|
508
|
+
the first address alone: 5 of 5, the slowest in 10.5 s. Before the quarter share and the turns: 37.4 s (2.6 s
|
|
509
|
+
before the deadline) with one address, and 6 of 7 large reads refused with
|
|
510
|
+
two (`test/measure/egress-address-fairness.mjs`). Readers that read every byte
|
|
511
|
+
get the same share: with one or two addresses each keeping up to 30 full
|
|
512
|
+
reads of their own 400 KiB mail in flight, a 431 KiB page from another
|
|
513
|
+
address completed 29 of 29 times in 2.4 to 3.4 s (before: 0 within the
|
|
514
|
+
deadline). Streams of one address, including several clients behind one NAT,
|
|
515
|
+
share that address's turn: with two such addresses, 7 of each one's own reads
|
|
516
|
+
were cut at the 40 s deadline. A client with many
|
|
517
|
+
addresses gets a share for each, so it can still take the whole budget and
|
|
518
|
+
most of the rate; IPv6 addresses count one by one, not by prefix. Measured on
|
|
519
|
+
Node 22 (relay, seed
|
|
520
|
+
and readers in one process): RSS +35 MiB at 8 non-reading readers of a 4 MiB
|
|
521
|
+
inbox, +36 MiB at 16 and +43 MiB at 32; the 2.8.0 candidate `7f92c35` grew
|
|
522
|
+
about 13 MiB per reader. Large mail waits while non-reading clients use the
|
|
523
|
+
tunnel rate: messages of about 201 KiB at 47% of that rate, under 60 s of such
|
|
524
|
+
load, arrived 20 of 36 during it (up to 38 s late) and 36 of 36 after it.
|
|
525
|
+
|
|
426
526
|
**Firewalls.** Open 80 and 443 in the **host** firewall as well as the cloud
|
|
427
527
|
provider's, and leave 8799 closed. Some cloud images ship host rules that
|
|
428
528
|
reject everything but SSH: Oracle's Ubuntu 24.04 image does.
|
|
@@ -535,15 +635,36 @@ or an exception message. A parameterised reason such as
|
|
|
535
635
|
| `bad-sig-encoding` | 401 | Send `x-pillar-sig` as 128 hex characters |
|
|
536
636
|
| `clock-skew` | 401 | Fix your clock (NTP) to within 5 min of the carrier; retrying does not help |
|
|
537
637
|
| `uuaid-pubkey-mismatch` | 401 | Read the inbox of the UUAID your key derives, or send that UUAID's delegation in `x-pillar-delegation` |
|
|
638
|
+
| `inbox-auth-v2-required` (2.8.1) | 401 | A relayed seed, and a 2.8.1 relay, take only inbox auth v2 (`x-pillar-auth: 2`, bound to the seed URL, single-use): update pillar to 2.8.1 or later |
|
|
639
|
+
| `inbox-auth-version` (2.8.1) | 401 | Send `x-pillar-auth: 2`, or no `x-pillar-auth` for v1 at a direct carrier |
|
|
640
|
+
| `inbox-audience-unknown` (2.8.1) | 401 | This carrier has no public URL to check a v2 audience against; send v1 |
|
|
641
|
+
| `bad-nonce` (2.8.1) | 401 | Send `x-pillar-nonce` as 32 random hex characters, new for each request |
|
|
642
|
+
| `nonce-used` (2.8.1) | 401 | Sign again with a new nonce; each v2 inbox auth is used once |
|
|
643
|
+
| `inbox-auth-query` (2.8.1) | 401 | A v2 read takes only `since` and `wait` (whole numbers) and `challenge` (64 hex), each at most once; v2 signs all three |
|
|
644
|
+
| `inbox-auth-busy` (2.8.1) | 503 | Retry in a few seconds: the carrier keeps every live v2 nonce until its 5-minute window ends, up to 100,000 at once |
|
|
538
645
|
| `delegation-unparseable` | 401 | Send `x-pillar-delegation` as the JSON delegation document |
|
|
539
646
|
| `delegation-too-large` | 401 | Send a delegation document under 8,192 bytes |
|
|
540
647
|
| `delegation-principal-mismatch` | 401 | Use a delegation whose principal is the inbox UUAID |
|
|
541
648
|
| `delegation-delegate-key-mismatch` | 401 | Sign with the key the delegation names as delegate |
|
|
542
649
|
| `delegation-inbox-denied` | 401 | Ask the principal for a delegation that covers `inbox` (or `*`) |
|
|
543
650
|
| `busy` | 503 | Retry after at least 2 s with jitter, or poll with `wait=0` for a while |
|
|
651
|
+
| `seed-busy` | 503 | Back off: retry after 5 s with jitter, doubling to 60 s; this relayed seed holds as many inbox pages as its `--response-budget` allows (2.8.0) |
|
|
544
652
|
| `not-found` | 404 | Use `POST /v1/envelopes` or `GET /v1/inbox/<uuaid>` |
|
|
545
653
|
| `not-a-seed` | 404 | Do not list this carrier as a seed; it runs without a seed identity |
|
|
546
654
|
| `internal-error` | 500 | Retry later; if it repeats, tell the carrier operator |
|
|
655
|
+
| `bad-challenge` | 400 | Send `challenge` as 64 lowercase hex characters (32 random bytes), or leave it out (`GET /v1/seed-info`, 2.8.0) |
|
|
656
|
+
| `upgrade-required` | 426 | Open `/v1/tunnel` as a WebSocket, as `pillar-seed --relay` does (only with `--accept-tunnels`) |
|
|
657
|
+
|
|
658
|
+
### Tunnel relay (`/e/<id>/...`, 2.8.0)
|
|
659
|
+
|
|
660
|
+
| Code | Status | Fix |
|
|
661
|
+
|---|---|---|
|
|
662
|
+
| `seed-offline` | 503 | Retry later or use another carrier; this seed's tunnel to the relay is down |
|
|
663
|
+
| `tunnel-busy` | 503 | Back off: retry after 5 s with jitter, doubling to 60 s, or use another carrier |
|
|
664
|
+
| `body-too-large` | 413 | As the carrier's: the request passed the relay's size cap |
|
|
665
|
+
| `seed-timeout` | 504 | Retry, or use another carrier; the seed behind this relay did not answer in time |
|
|
666
|
+
| `seed-bad-answer`, `seed-reset`, `seed-answer-too-large` | 502 | Retry, or use another carrier |
|
|
667
|
+
| `not-found` | 404 | As the carrier's: only the four carrier routes pass a relay |
|
|
547
668
|
|
|
548
669
|
### Client (no server gave a code)
|
|
549
670
|
|
|
@@ -551,6 +672,7 @@ or an exception message. A parameterised reason such as
|
|
|
551
672
|
|---|---|---|
|
|
552
673
|
| `carrier-unreachable` | every carrier failed without answering | Check the carrier URLs and your network, then retry |
|
|
553
674
|
| `carrier-bad-response` | a carrier or its proxy answered without a reason | Retry, or use another carrier |
|
|
675
|
+
| `carrier-redirect-refused` | a carrier answered 3xx; the client never follows a redirect (2.8.1), so no `x-pillar-*` header reaches the target | Configure the carrier's final https URL |
|
|
554
676
|
| `over-tier-limit`, `blob-too-large` | send preflight, before any network call (src/net/carrier-client.mjs:90) | Send the payload as a blob (`pillar-blob send`, or `Pillar.sendBlob`) |
|
|
555
677
|
| `blob-key-unproven` | `pillar-blob`, before signing a broker request | Use a self-certifying agent UUAID (`foundation`, `pillar` or `agentnet`) derived from this key (`pillar init`), or get a registry badge that names this key |
|
|
556
678
|
| `sender-key-not-active` | `pillar-blob get`, before redeeming | Ask the sender to send from a self-certifying agent UUAID (`foundation`, `pillar` or `agentnet`) derived from its own key, or to get a registry badge naming its key |
|
package/README.md
CHANGED
|
@@ -707,10 +707,37 @@ a UUAID is read as a file.
|
|
|
707
707
|
|---|---|
|
|
708
708
|
| `pillar resolve <uuaid> [--registry URL]` | The same live check as `verify <uuaid>`, printing the resolved record (and with `--json`, the lineage log). |
|
|
709
709
|
| `pillar lineage show [--json]` | This home's lineage: current key, head, verdict, rotations, doors. `<home>/lineage/log.json` is the file to give others. |
|
|
710
|
-
| `pillar lineage rotate` | Rotate this home's key (a signed lineage event). |
|
|
710
|
+
| `pillar lineage rotate` | Rotate this home's key (a signed lineage event), tell your contacts with a `lineage` notice (`--no-notify` skips it), and keep reading the old key's inbox for a grace window (`--retired-grace`, default `P14D`). |
|
|
711
711
|
| `pillar card build` / `card show` / `card serve` | Write, print or serve this home's signed agent card (`<home>/card/card.json`). |
|
|
712
712
|
| `pillar listing publish --registry URL` | Publish the card as a signed listing, so `verify <uuaid>` finds you. |
|
|
713
713
|
|
|
714
|
+
### When a contact's key changes (continuity)
|
|
715
|
+
|
|
716
|
+
A contact that rotates its key sends you a `lineage` notice. Pillar verifies the
|
|
717
|
+
lineage it carries, but a notice is only evidence: it never moves your mail by
|
|
718
|
+
itself. Until you act, every send to the old key is **held** (refused, nothing
|
|
719
|
+
sealed), because the old key may be the one that was stolen.
|
|
720
|
+
|
|
721
|
+
Continuity notices use two admission lanes:
|
|
722
|
+
|
|
723
|
+
- **Trusted admission (`b.auth`, reserved `1,024`/h, independent of the open backlog scan and pre-ingest wait):** granted only when the envelope signature is verified (`open()` non-delegated) and the sender is (1) an existing trusted contact key (`addressBook` or `trust.allow`) or a key of a `firm`-pinned lineage, (2) the pre-committed `next` key (`sha256(publicKey) === ev.next`) of an already-stored lineage, or (3) a home in the `firm`-pinned roster of a stored lineage. Trusted notices store at receipt while `b.auth` is free, or by the next 1-hour budget window under normal polling if `b.auth` was also spent.
|
|
724
|
+
- **Unproven admission (bounded best effort; `PROOF_POOL_PER_HOUR = 512` proof checks/h, `MAX_PROOF_PER_CANDIDATE = 256`, open share `3,072`/h):** all other arrivals — including an unpinned contact's first rotation notice sent from an unknown new key before its inception was stored, or any unauthenticated claim naming a pinned lineage — receive no priority and reserve durable proof work before any signature check. Waiting unverified notices never hold or redirect routes on their own: sends continue to address the known key during pre-verification exposure until the notice is verified (measured on Node 22 at 4 polls per 1-hour window with the open share spent: **13 windows** behind 3,100 spoofed 2-event notices and **9 windows** behind 4,200 plain 2-event notices; have the contact announce its inception first, sign the rotation notice with its known or pre-committed `next` key, or `pin --log` its lineage for trusted admission).
|
|
725
|
+
|
|
726
|
+
| Command | What it does |
|
|
727
|
+
|---|---|
|
|
728
|
+
| `pillar continuity show <contact>` | The decision for a contact's key: `none`, `pending-confirm` (held), `active` (sends go to the new key) or `suspended` (conflicting evidence). `check` asks the pinned homes first and prints how many agree, how many vouched for a verified disagreement (persisted as a forward/fork checkpoint so a lagging quorum, home outage, restart, or local confirmation cannot re-enable the retired route without verified ancestry through the checkpoint and positive quorum at the resulting head), how many are behind (`stale`), and how many gave no usable answer. |
|
|
729
|
+
| `pillar continuity confirm <contact> --head sha256:... --to <uuaid>` | Accept the new key. Ask the contact over another channel (not pillar) for its new uuaid and lineage head, and use the values it gave you. Copying the values from the notice proves nothing. |
|
|
730
|
+
| `pillar continuity recover <contact> --log FILE --head sha256:... --to <uuaid>` | The only way out of a fork or a hold: a lineage log you obtained over another channel, which must verify on its own at that head and destination. It speaks for that lineage at that head only: when newer evidence arrives, the evidence decides again. |
|
|
731
|
+
| `pillar continuity pin --log FILE` | Trust a lineage log you obtained yourself, so later rotations can be checked against its homes. It does not clear a fork. |
|
|
732
|
+
| `pillar continuity forget <lineage> --confirm <lineage>` / `repair` | Drop a lineage's evidence, or move an unreadable store aside. Neither releases a key that was retired, forked, or held by an uncovered home checkpoint (including the locally current key): holds and uncovered checkpoints persist in `holds.json` up to 4,096 entries and release only on proven coverage (verified ancestry plus positive pinned-home quorum at the resulting head) or `recover`. |
|
|
733
|
+
| `pillar continuity imports` | Mail that arrived at your retired key during the grace window, kept apart from your inbox. |
|
|
734
|
+
|
|
735
|
+
`Pillar.sendDirect` dials the peer id and address its caller gives, so it is
|
|
736
|
+
never redirected: to a retired key it refuses with
|
|
737
|
+
`redirect-blocked:direct-redirect` and seals nothing. Use `send`, which routes
|
|
738
|
+
to the new key, or call `sendDirect` for the new key with that key's own peer
|
|
739
|
+
id and address.
|
|
740
|
+
|
|
714
741
|
## The three always-on roles
|
|
715
742
|
|
|
716
743
|
| Bin | What it runs | Ongoing requirements |
|
|
@@ -861,6 +888,240 @@ What an outside operator needs to know before the first start:
|
|
|
861
888
|
seed on one.
|
|
862
889
|
- The proxy, the firewall and CORS: HOSTING-LIMITS.md §5 has a Caddy and an
|
|
863
890
|
nginx example.
|
|
891
|
+
- **No public URL?** Run an egress seed through a tunnel relay (next section).
|
|
892
|
+
|
|
893
|
+
### Egress seed (2.8.0): no public URL needed
|
|
894
|
+
|
|
895
|
+
A machine with outbound-only network (a cloud VM, a laptop behind NAT) can run
|
|
896
|
+
a seed. The seed stays on 127.0.0.1, opens one outbound WebSocket to a **tunnel
|
|
897
|
+
relay** (a `pillar-carrier` started with `--accept-tunnels`; not the push relay
|
|
898
|
+
of HOSTING-LIMITS.md §4), and is served at `<relay origin>/e/<id>`, where `<id>`
|
|
899
|
+
is derived from the seed key:
|
|
900
|
+
|
|
901
|
+
```sh
|
|
902
|
+
pillar-seed --home /var/lib/pillar/seed --relay https://relay.example.org --announce https://<registry>
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
`--relay` does not go with `--public-url`, keeps `--host` at 127.0.0.1 or ::1,
|
|
906
|
+
and needs that address in `--trusted-proxy` (the default), so each client is
|
|
907
|
+
still charged to its own address. A relay that does not take tunnels, or does
|
|
908
|
+
not list this seed, stops the seed with exit 2 before anything is announced.
|
|
909
|
+
Losing the tunnel later is retried (1 s to 60 s; the backoff starts over only
|
|
910
|
+
after a tunnel stayed up for a minute): the registry demotes the seed after
|
|
911
|
+
three failed probes and restores it once probes pass again.
|
|
912
|
+
|
|
913
|
+
**Seed memory.** An inbox page ends at about 2 MiB of envelopes (whole
|
|
914
|
+
envelopes, at least one), with `more: true` while more wait; every client reads
|
|
915
|
+
on with `since`, as before. A relayed seed reserves each page against its
|
|
916
|
+
`--response-budget` (MiB, default 32, 4 to 4096) before it reads the page, and
|
|
917
|
+
keeps the reservation until the tunnel has sent the page to the relay or the
|
|
918
|
+
stream ends. Past the budget a read gets 503 `seed-busy` (retry after 5 s);
|
|
919
|
+
large pages leave an eighth of the budget to pages of up to about 128 KiB, so
|
|
920
|
+
chat-sized mail is still served. That bounds the pages one seed process holds
|
|
921
|
+
per tunnel. One client address that already holds a page may hold at most a
|
|
922
|
+
quarter of the budget (an address that holds none may always take one page);
|
|
923
|
+
past that its reads get `seed-busy` at once, and other addresses are served.
|
|
924
|
+
The seed also sends answer bytes to client addresses in turns, one frame each,
|
|
925
|
+
the address served longest ago first: 30 reads from one address get the same
|
|
926
|
+
share of the tunnel's rate as one read from another. Measured on Node 22 at
|
|
927
|
+
the default limits, with 30 reads of 401 KiB pages from one address that read
|
|
928
|
+
the status line and then nothing (and, the second time, 30 more of 111 KiB
|
|
929
|
+
pages from a second address), each healthy read timed from its own start: a
|
|
930
|
+
reader of 2 MiB pages from a third address got 5 of 5 (slowest 10.5 s, 29.5 s
|
|
931
|
+
before the 40 s deadline) and 4 of 4 (slowest 19.7 to 20.6 s, at least 19.4 s
|
|
932
|
+
before it) in three runs; chat-size reads took at most 0.4 s; the first
|
|
933
|
+
address got 17 or 18 of its 30 reads refused with `seed-busy`, and every
|
|
934
|
+
non-reading read had its answer within 2 s
|
|
935
|
+
(`test/measure/egress-address-fairness.mjs`).
|
|
936
|
+
Before the quarter share and the turns, the slowest large read took 37.4 s (2.6
|
|
937
|
+
s before the deadline) and 6 of 7 large reads were refused in the second run.
|
|
938
|
+
Readers that read every byte get the same share: with one or two addresses
|
|
939
|
+
each keeping up to 30 reads of their own 400 KiB mail in flight (at most 9
|
|
940
|
+
new a second), a 431 KiB page read from another address completed 29 of 29
|
|
941
|
+
times in 2.4 to 3.4 s, two runs each, and chat-size reads took at most 0.13 s
|
|
942
|
+
(before: 0 of these pages completed within the 40 s deadline). The streams of
|
|
943
|
+
one address share that address's turn, so its own large reads slow down as
|
|
944
|
+
it opens more: with two such addresses, 7 of each one's reads were cut at
|
|
945
|
+
the 40 s deadline. Several clients behind one address (a NAT) share it the
|
|
946
|
+
same way.
|
|
947
|
+
Measured on Node 22 with the default budget
|
|
948
|
+
and relay limits, 4 new non-reading clients a second on 16 MiB inboxes plus
|
|
949
|
+
three reading clients of chat-size mail: seed RSS peaked at 164 to 191 MiB
|
|
950
|
+
over the runs of 2.8.0 rounds 6 and 7 (without
|
|
951
|
+
byte-bounded pages it passed 1.6 GiB in 10 s), every reading client got all
|
|
952
|
+
its mail, and the non-reading ones got
|
|
953
|
+
`seed-busy` (`test/measure/egress-seed-memory.mjs`). Large mail waits while
|
|
954
|
+
such clients use the tunnel's rate: with messages of about 201 KiB (3
|
|
955
|
+
senders, one each 5 s, 47% of the tunnel rate) under the same load, 20 of 36
|
|
956
|
+
arrived during the 60 s load, the latest 38 s late, and all 36 after it
|
|
957
|
+
(without the non-reading clients: 36 of 36, at most 25 ms late).
|
|
958
|
+
|
|
959
|
+
**One process per seed key.** A relay keeps the tunnel it has while that
|
|
960
|
+
tunnel answers: a second process started with a copy of the same seed home is
|
|
961
|
+
refused (`seed-already-connected`), waits `--takeover-wait` seconds (default
|
|
962
|
+
45) for the first to stop, then exits 2 and announces nothing. Two processes
|
|
963
|
+
with one key each hold their own mail, so letting them take turns would lose
|
|
964
|
+
mail. To move a seed to a new host, stop the old process first; a process that
|
|
965
|
+
died without closing its tunnel is dropped by the relay within about 30
|
|
966
|
+
seconds, and the new one takes over. Run one process per seed key: if two do
|
|
967
|
+
run and the relay restarts, whichever reconnects first keeps the key and the
|
|
968
|
+
other exits 2 after `--takeover-wait`, even if it was serving before. Mail that
|
|
969
|
+
process had accepted stays in its database (the exit message names it): stop
|
|
970
|
+
the other process and start that one again to serve it.
|
|
971
|
+
|
|
972
|
+
**Relayed seeds in the directory (2.8.1).** `directory.json` (and its `/`
|
|
973
|
+
alias) lists a relayed seed in `seeds[]` with its `uuaid`, its `url` and its
|
|
974
|
+
`relay`, once the registry fetched the seed's own signed `/v1/seed-info` over
|
|
975
|
+
that exact `<relay>/e/<id>` URL and then passed a round trip with inbox auth v2
|
|
976
|
+
and the seed's signed served proof for the seed's current URL, key and relay
|
|
977
|
+
pin, and while the seed is not demoted. Signed seed-info alone does not list a
|
|
978
|
+
seed: it does not show that clients can read it. A failed round trip, or a
|
|
979
|
+
changed URL, key or relay pin, takes the seed out until the next round trip
|
|
980
|
+
passes. A relayed row stored by 2.8.0 or earlier, and a 2.8.0 seed behind a
|
|
981
|
+
2.8.1 relay (it cannot check v2), stay out until then. It is never
|
|
982
|
+
the bootstrap carrier (`pillar-directory --carrier` refuses a relayed URL).
|
|
983
|
+
`pillar init --directory` and `--refresh` take a relayed entry only when it
|
|
984
|
+
names its relay and its URL is `<relay>/e/<id>`, and take at most 4 of them,
|
|
985
|
+
in directory order (proven seeds first); they skip the rest and say how many
|
|
986
|
+
on stderr. A 2.8.0 client takes none. An agent can still name one itself:
|
|
987
|
+
`pillar init --carriers https://relay.example.org/e/<id>`, or the `carriers`
|
|
988
|
+
list in `config.json`. `--refresh` replaces `carriers` with what the directory
|
|
989
|
+
offers, so it also removes a relayed URL the directory no longer offers (and
|
|
990
|
+
one you added by hand: add it again after a refresh).
|
|
991
|
+
|
|
992
|
+
**Inbox auth v2 (2.8.1).** A client reads a relayed seed only with inbox auth
|
|
993
|
+
v2: `x-pillar-auth: 2` and a random `x-pillar-nonce`, signed with the seed URL
|
|
994
|
+
as the audience, so the seed and its relay cannot replay it to another carrier,
|
|
995
|
+
and the seed takes each nonce once (`nonce-used`). The signature covers the
|
|
996
|
+
method, the audience, the inbox uuaid, the `since`, `wait` and `challenge`
|
|
997
|
+
query values, the timestamp and the nonce, so nobody on the path can change
|
|
998
|
+
the page asked for, the wait, or the challenge the seed signs its served proof
|
|
999
|
+
for. A v2 query holds only `since` and `wait` (whole numbers in plain decimal;
|
|
1000
|
+
absent is 0) and `challenge` (64 lowercase hex), each at most once; any other
|
|
1001
|
+
query is refused before the signature is checked and before the nonce is used
|
|
1002
|
+
(`inbox-auth-query`). The carrier keeps each nonce until its 5-minute window
|
|
1003
|
+
ends, at most 100,000 at once (about 10 MiB). When the store is full it refuses
|
|
1004
|
+
new v2 reads with 503 `inbox-auth-busy` and keeps every stored nonce until it
|
|
1005
|
+
expires; v1 reads use no nonce. A 2.8.1 relay refuses v1
|
|
1006
|
+
inbox auth on `/e/*` (`inbox-auth-v2-required`), whatever the seed's version,
|
|
1007
|
+
and a relayed seed refuses it too. Direct carriers still get v1, as in 2.8.0; a
|
|
1008
|
+
carrier with `--public-url` also takes v2 for that URL. The slim client
|
|
1009
|
+
(`@uuaid/pillar-client`) sends v1 only, so it cannot read a relayed seed.
|
|
1010
|
+
|
|
1011
|
+
**Relay operator.** `pillar-carrier --accept-tunnels <allow-file> --tunnel-origin
|
|
1012
|
+
https://relay.example.org --tunnel-keychain <key>`. The allow-file holds one
|
|
1013
|
+
full seed uuaid per line; check that the operator controls that seed before you
|
|
1014
|
+
add it. Removing a line closes that seed's tunnel within about two seconds and refuses it
|
|
1015
|
+
again. `--tunnel-keychain` (an existing key, never minted by the carrier, not the
|
|
1016
|
+
receipt or seed key) signs an attestation for each registry challenge. Limits:
|
|
1017
|
+
32 tunnels, 2 per source address, 256 KiB/s each way per tunnel and 8 MiB/s in
|
|
1018
|
+
total (`--tunnel-max`, `--tunnel-kbps`, `--tunnel-total-kbps`), plus stream,
|
|
1019
|
+
request-rate and size caps (src/net/tunnel-relay.mjs `TUNNEL_LIMITS`). The byte
|
|
1020
|
+
budgets bind open transfers too, across every open stream: the relay reserves
|
|
1021
|
+
bytes against its tunnel's and its own budget before it forwards them, so one
|
|
1022
|
+
stream carries at most the burst (4 MiB) plus 40 s at the rate before its
|
|
1023
|
+
deadline ends it. Upload bytes wait at the relay (at most one read per stream,
|
|
1024
|
+
inside the total queued-byte cap: 64 MiB of request and answer bytes the relay
|
|
1025
|
+
queues for all streams; it caps those bytes, not the relay's process memory,
|
|
1026
|
+
which can be higher because a queued slice keeps its whole buffer alive).
|
|
1027
|
+
Answers are paced by credit: the relay grants the
|
|
1028
|
+
seed answer bytes it has already paid for from both budgets (a 128 KiB window),
|
|
1029
|
+
and never stops reading the tunnel, so pings keep working while an answer is
|
|
1030
|
+
paced. Every answer byte counts against credit, also bytes for a stream that
|
|
1031
|
+
has ended or that the relay never opened; a seed that sends past its credit, or
|
|
1032
|
+
sends one stream's headers twice, is disconnected (`flow-violation`). A client
|
|
1033
|
+
that holds more than 256 KiB unread puts only its own stream on hold: the seed
|
|
1034
|
+
stops sending that answer, and the tunnel's other streams keep taking turns for
|
|
1035
|
+
credit. A client that takes no bytes for 10 s while bytes wait for it at the
|
|
1036
|
+
relay is dropped, wherever the rest of its answer is (at the relay, or at the
|
|
1037
|
+
seed on hold or waiting for credit); one that keeps reading, however slowly, is
|
|
1038
|
+
not. The 10 s count starts only once bytes wait at the relay: while the tunnel
|
|
1039
|
+
is short of credit nothing may wait there, and a client that never reads stays
|
|
1040
|
+
until the 40 s stream deadline (`seed-timeout`). Once the seed has sent the end
|
|
1041
|
+
of an answer, the relay keeps the stream until its last byte is in the
|
|
1042
|
+
client's socket: those bytes still count toward the 64 MiB cap and toward the
|
|
1043
|
+
client address's 32 streams, the 10 s rule still applies, and the deadline (40
|
|
1044
|
+
s from the stream's start) still ends it. Bytes in the kernel's socket buffers
|
|
1045
|
+
after that are not seen or counted. At the seed, a stream lasts until its end
|
|
1046
|
+
has gone to the relay or it is reset, whatever its local answer did: a reset
|
|
1047
|
+
after the local answer ended still drops its queued bytes and gives its page
|
|
1048
|
+
back to the budget, and a local answer that stops early resets the stream.
|
|
1049
|
+
Tested for each way a stream ends (local end with bytes waiting for credit, a
|
|
1050
|
+
reset after it, client gone, stream deadline): the relay's queued bytes and the
|
|
1051
|
+
seed's tickets return to 0 with the tunnel up and no new request
|
|
1052
|
+
(`test/unit/egress-round7.test.mjs`). Measured with 60 never-read reads from 2
|
|
1053
|
+
addresses (pages of 401 KiB and 111 KiB): 17 were refused with `seed-busy`, 43
|
|
1054
|
+
fit in the socket buffers and counted as sent (each within 27 s), none
|
|
1055
|
+
reached the deadline, and the seed's budget peaked at 15.7 of 32 MiB (before
|
|
1056
|
+
the quarter share: 18 reached the deadline, peak 28.5 MiB).
|
|
1057
|
+
The relay sees a client take bytes only when its socket buffers do, in steps
|
|
1058
|
+
of about 300 KB on macOS loopback, so 10 s keeps every client fast enough to
|
|
1059
|
+
read a whole page before the 40 s stream deadline. A new stream needs at least
|
|
1060
|
+
one byte of budget left. The relay keeps
|
|
1061
|
+
request counts for at most 10,000 client addresses at a time; when all of them
|
|
1062
|
+
are inside their minute, a new address gets 503 `tunnel-busy` until one ages
|
|
1063
|
+
out. Only the
|
|
1064
|
+
four carrier routes pass; seed headers never reach clients; every `/e/*` answer
|
|
1065
|
+
is `cache-control: no-store`; logs carry the route template, status and sizes
|
|
1066
|
+
only.
|
|
1067
|
+
|
|
1068
|
+
**Open relay (2.8.1).** `pillar-carrier --accept-tunnels open --tunnel-origin
|
|
1069
|
+
https://relay.example.org` admits any seed that proves its uuaid key: the seed
|
|
1070
|
+
signs the tunnel request with the key its uuaid derives from, bound to this
|
|
1071
|
+
origin and a one-use nonce. There is no allow-file and no approval. The carrier
|
|
1072
|
+
speaks plain http, so bind it to 127.0.0.1 and serve the https origin through a
|
|
1073
|
+
TLS proxy that passes WebSocket upgrades (it prints a note when it is bound
|
|
1074
|
+
elsewhere). All the caps above apply. The relay writes one meter line per
|
|
1075
|
+
stream to stdout: `relay: <id> <method> <route template> <status>
|
|
1076
|
+
<in>/<out>B <ms>ms`, with no header, query or body. A request refused before a
|
|
1077
|
+
stream opens (401, 404, 413, 503) writes none. With `--tunnel-keychain` an
|
|
1078
|
+
open relay attests too, with admission `open`: it says only that a seed-info
|
|
1079
|
+
answer came through that seed's live tunnel. A registry that pins the relay in
|
|
1080
|
+
`--fleet-relays` vets its seeds as it vets a fleet relay's; a registry that
|
|
1081
|
+
does not pin it ranks them `relayed-unvetted` (probation, no grant). Every cap
|
|
1082
|
+
is a flag: `--tunnel-max`, `--tunnels-per-ip` (default 2), `--tunnel-kbps`,
|
|
1083
|
+
`--tunnel-total-kbps` and `--tunnel-buffer-mib` (queued bytes, default 64). With
|
|
1084
|
+
`--tunnel-max 4 --tunnels-per-ip 2`, two seed addresses fill the relay.
|
|
1085
|
+
Measured on macOS (Node 22): the relay adds nothing to an idle carrier (about 76
|
|
1086
|
+
MiB) and about 0.2 to 0.5 MiB per active tunnel at 8 to 32 tunnels
|
|
1087
|
+
(`test/measure/open-relay-rss.mjs`); it runs inside the carrier process, a
|
|
1088
|
+
seed-mode carrier included.
|
|
1089
|
+
|
|
1090
|
+
**Trust.** A tunnel relay is a carrier: it can delay or drop mail, but cannot
|
|
1091
|
+
read or forge sealed envelopes. It does see inbox auth headers, which a carrier
|
|
1092
|
+
accepts for 5 minutes, so it could re-read that inbox page (sealed envelopes and
|
|
1093
|
+
their metadata) in that window. Inbox auth v2 (above) closes that for relayed
|
|
1094
|
+
seeds: each v2 auth names the seed URL and is used once. Only a relay pinned
|
|
1095
|
+
per registry earns a seed a grant.
|
|
1096
|
+
|
|
1097
|
+
**Registry.** `pillar-directory --fleet-relays <file>`, one `<origin> <relay key
|
|
1098
|
+
hex>` per line. Every probe of a relayed seed is a one-use challenge: the seed
|
|
1099
|
+
must echo it in its signed `/v1/seed-info`, a pinned relay must attest it, and
|
|
1100
|
+
round trips must carry the seed's signed proof of the exact page it served. Any
|
|
1101
|
+
error fails the probe; nothing falls back to `/v1/health`.
|
|
1102
|
+
|
|
1103
|
+
| Seed topology | Highest tier | Priority, grant | In `directory.json` |
|
|
1104
|
+
| --- | --- | --- | --- |
|
|
1105
|
+
| Direct (`--public-url`) | anchor | as before | yes |
|
|
1106
|
+
| On a pinned fleet relay, attested within its lease | durable | yes; the grant ends with the lease | for reach (2.8.1), with `relay`, after a v2 round trip |
|
|
1107
|
+
| On a pinned fleet relay, lease lapsed or a probe failed | steady | none | for reach (2.8.1), with `relay`, after a v2 round trip, until demoted |
|
|
1108
|
+
| On a relay this registry does not pin | probation | none | for reach (2.8.1), with `relay`, after a v2 round trip, until demoted |
|
|
1109
|
+
| Relayed row from a 2.7.x registry, before its first challenge | probation | none | no |
|
|
1110
|
+
| Any relayed row before a v2 round trip passes for its current URL, key and relay pin (rows from 2.8.0 and earlier included) | as above | as above | no |
|
|
1111
|
+
|
|
1112
|
+
**Lease.** A passing challenge probe through a pinned fleet relay vets the seed
|
|
1113
|
+
for min(3 x the probe interval, 30 minutes): 30 minutes at the default
|
|
1114
|
+
10-minute interval. Minting a grant never extends it, and the grant expires
|
|
1115
|
+
with it. A failed probe ends it at once; a revocation by the relay, or a probe
|
|
1116
|
+
loop that stops, ends it within the lease. A registry that opens a database
|
|
1117
|
+
with a longer stored vetting (the first 2.8.0 candidate stored 24 hours) clears
|
|
1118
|
+
it, and the seed proves itself again. A carrier stops honouring any tier grant
|
|
1119
|
+
at its expiry, even when its decision is cached. A grant minted earlier, or by a
|
|
1120
|
+
2.6.1 or 2.7.x registry, stays valid until its own expiry, up to 14 days. A 2.6.1 or 2.7.x registry still enrolls a relayed seed, but checks its
|
|
1121
|
+
liveness through the relay without a challenge (relay-attested), and applies no
|
|
1122
|
+
cap; `pillar-seed --status` says so. Not in 2.8.0: moving a seed to another
|
|
1123
|
+
relay (it needs a new seed key), and inbox auth bound to its audience (2.8.1
|
|
1124
|
+
adds it for relayed seeds: inbox auth v2).
|
|
864
1125
|
|
|
865
1126
|
## Abuse resistance — consent at the edge, budgets at the carrier
|
|
866
1127
|
|
|
@@ -1220,6 +1481,32 @@ rate and body size — see "Tier grants" above for the ladder. It is a
|
|
|
1220
1481
|
See "Mailbox: local message erasure" above for the selectors, the
|
|
1221
1482
|
checkpoint-incomplete error and retry, and rolling back to 2.5.5.
|
|
1222
1483
|
|
|
1484
|
+
### Known limits in 2.8.0
|
|
1485
|
+
|
|
1486
|
+
Found in the 2.8.0 review. Each is planned for a 2.8.x release.
|
|
1487
|
+
|
|
1488
|
+
- **Unproven continuity notices can wait.** A rotation notice that the
|
|
1489
|
+
receiver cannot place yet (for example an unpinned contact's first notice
|
|
1490
|
+
from a new key) gets no priority and shares a capped proof budget. Behind
|
|
1491
|
+
a flood it is stored late: measured in the 13th hourly window behind 3,100
|
|
1492
|
+
spoofed notices, and in the 9th behind 4,200 plain ones (4 polls per
|
|
1493
|
+
window). Trusted senders (a known contact key, a committed next key, a
|
|
1494
|
+
pinned home) are stored in the first window.
|
|
1495
|
+
- **Trusted admission is wider than the pinned path.** A next key that a
|
|
1496
|
+
stored rotation already used still counts as trusted, and so do the keys
|
|
1497
|
+
of a stored fork off the pinned path. A thief who holds one old contact
|
|
1498
|
+
key can make up to about 31 keys count as trusted. Trust gives queue
|
|
1499
|
+
priority only: signatures, lineage checks, caps and quotas still apply,
|
|
1500
|
+
the contact's route stays suspended, and their messages are not
|
|
1501
|
+
delivered. Those keys can spend the receiver's trusted share (1,024 per
|
|
1502
|
+
hour) and delay other trusted notices.
|
|
1503
|
+
- **Four client addresses can hold a relayed seed's response budget.** Each
|
|
1504
|
+
address may hold a quarter of `--response-budget`, so four busy addresses
|
|
1505
|
+
fill it and large reads from other addresses get 503 `seed-busy` (measured:
|
|
1506
|
+
40 of 48 refused, none cut off; chat-size reads still served). Clients
|
|
1507
|
+
behind one NAT share one address's quarter and turn. See "Egress seed"
|
|
1508
|
+
above and HOSTING-LIMITS "Relayed seed memory".
|
|
1509
|
+
|
|
1223
1510
|
## Source, provenance and releases
|
|
1224
1511
|
|
|
1225
1512
|
Apache-2.0 (`LICENSE`). This repository is the recovered source for
|
package/bin/carrier.mjs
CHANGED
|
@@ -37,12 +37,33 @@
|
|
|
37
37
|
* must be the one its public key derives. The two options go together; one
|
|
38
38
|
* without the other, a URL a registry would refuse, or a key that does not
|
|
39
39
|
* load refuses to start. Without them /v1/seed-info stays 404 as before.
|
|
40
|
+
*
|
|
41
|
+
* Relay (2.8.0): with --accept-tunnels <allow-file> and --tunnel-origin (the
|
|
42
|
+
* public https origin the proxy serves), the carrier also takes outbound
|
|
43
|
+
* tunnels from seeds whose full uuaid is on the allow-file and serves each at
|
|
44
|
+
* <origin>/e/<id> (src/net/tunnel-relay.mjs). With --tunnel-keychain (an
|
|
45
|
+
* existing key, never minted here, different from the receipt and seed keys;
|
|
46
|
+
* passphrase CARRIER_TUNNEL_KEYCHAIN_PASSPHRASE) it attests those tunnels to
|
|
47
|
+
* registries that pin it. Off by default: /v1/tunnel and /e/* answer 404 as
|
|
48
|
+
* in 2.7.1.
|
|
49
|
+
*
|
|
50
|
+
* Open relay (2.8.1, owner order 2026-12-04): --accept-tunnels open admits any
|
|
51
|
+
* seed that proves its uuaid with the key it derives from (src/net/tunnel.mjs),
|
|
52
|
+
* on a public https --tunnel-origin behind the TLS proxy. There is no
|
|
53
|
+
* allow-file and no approval; the TUNNEL_LIMITS caps (and the --tunnel-*
|
|
54
|
+
* overrides) bound it. With --tunnel-keychain it attests to registries that pin it
|
|
55
|
+
* that a seed-info answer came through the seed's live tunnel (admission
|
|
56
|
+
* "open"), and nothing more. Usage is metered: one log line per stream
|
|
57
|
+
* (seed localId, method, route template, status, bytes in/out, ms), never a
|
|
58
|
+
* header, path or query value.
|
|
40
59
|
*/
|
|
41
60
|
import "../src/node-check.mjs"; // must stay the first import: refuses Node < 22 before any dependency loads
|
|
42
61
|
import { CarrierServer, parseSecureDelete, parseCommunityWaits, MAX_TTL_DAYS } from "../src/net/carrier-server.mjs";
|
|
43
62
|
import { Keychain, keyDerivesUuaid } from "../src/identity/keychain.mjs";
|
|
44
63
|
import { checkSeedUrl } from "../src/net/seed-registry.mjs";
|
|
45
64
|
import { parseTrustedProxies } from "../src/net/client-ip.mjs";
|
|
65
|
+
import { canonicalOrigin } from "../src/net/tunnel.mjs";
|
|
66
|
+
import { TunnelRelay } from "../src/net/tunnel-relay.mjs";
|
|
46
67
|
import { exitWithHelp, wantsHelp } from "../src/cli-help.mjs";
|
|
47
68
|
|
|
48
69
|
function parseArgs(argv) {
|
|
@@ -87,6 +108,19 @@ default; put a TLS-terminating proxy in front of it.
|
|
|
87
108
|
--receipt-keychain <file> sign carrier receipts with this existing key (CARRIER_RECEIPT_KEYCHAIN)
|
|
88
109
|
--seed-keychain <file> with --public-url: serve a signed /v1/seed-info (CARRIER_SEED_KEYCHAIN)
|
|
89
110
|
--public-url <https://> the URL the proxy serves (CARRIER_PUBLIC_URL)
|
|
111
|
+
--accept-tunnels <file> relay seeds whose uuaid is in this allow-file (CARRIER_ACCEPT_TUNNELS;
|
|
112
|
+
default off). "open" admits any seed that proves its uuaid key
|
|
113
|
+
(2.8.1: a public open relay; caps and per-stream meter apply)
|
|
114
|
+
--tunnel-origin <https://> the public origin seeds are served at, as <origin>/e/<id>
|
|
115
|
+
(CARRIER_TUNNEL_ORIGIN)
|
|
116
|
+
--tunnel-keychain <file> attest tunnels to registries with this existing key
|
|
117
|
+
(CARRIER_TUNNEL_KEYCHAIN)
|
|
118
|
+
--tunnel-max <n> most tunnels at once (CARRIER_TUNNEL_MAX, default 32)
|
|
119
|
+
--tunnel-kbps <n> per-tunnel KiB/s each way (CARRIER_TUNNEL_KBPS, default 256)
|
|
120
|
+
--tunnel-total-kbps <n> all tunnels, KiB/s each way (CARRIER_TUNNEL_TOTAL_KBPS, default 8192)
|
|
121
|
+
--tunnels-per-ip <n> most tunnels from one seed address (CARRIER_TUNNELS_PER_IP, default 2)
|
|
122
|
+
--tunnel-buffer-mib <n> request and answer bytes the relay queues for all streams, MiB
|
|
123
|
+
(CARRIER_TUNNEL_BUFFER_MIB, default 64)
|
|
90
124
|
-h, --help print this help and exit
|
|
91
125
|
|
|
92
126
|
The carrier never mints a key. See the header of bin/carrier.mjs for details.`;
|
|
@@ -183,9 +217,74 @@ if (wantSeedKey) {
|
|
|
183
217
|
}
|
|
184
218
|
}
|
|
185
219
|
|
|
220
|
+
// Relay (2.8.0): off unless --accept-tunnels names an allow-file, or "open" (2.8.1: any seed).
|
|
221
|
+
const tunnelOpt = (flag, env) => { const v = args[flag] ?? process.env[env]; return v === "" ? null : (v ?? null); };
|
|
222
|
+
const acceptTunnels = tunnelOpt("accept-tunnels", "CARRIER_ACCEPT_TUNNELS");
|
|
223
|
+
const tunnelOriginText = tunnelOpt("tunnel-origin", "CARRIER_TUNNEL_ORIGIN");
|
|
224
|
+
const tunnelKeychainPath = tunnelOpt("tunnel-keychain", "CARRIER_TUNNEL_KEYCHAIN");
|
|
225
|
+
const tunnelPassphrase = process.env.CARRIER_TUNNEL_KEYCHAIN_PASSPHRASE;
|
|
226
|
+
delete process.env.CARRIER_TUNNEL_KEYCHAIN_PASSPHRASE;
|
|
227
|
+
const tunnelNumbers = {};
|
|
228
|
+
for (const [flag, env, key, scale] of [
|
|
229
|
+
["tunnel-max", "CARRIER_TUNNEL_MAX", "maxTunnels", 1],
|
|
230
|
+
["tunnel-kbps", "CARRIER_TUNNEL_KBPS", "tunnelBytesPerSec", 1024],
|
|
231
|
+
["tunnel-total-kbps", "CARRIER_TUNNEL_TOTAL_KBPS", "totalBytesPerSec", 1024],
|
|
232
|
+
// 2.8.1: every relay cap is a runtime flag, so a small host runs lower caps.
|
|
233
|
+
["tunnels-per-ip", "CARRIER_TUNNELS_PER_IP", "tunnelsPerIp", 1],
|
|
234
|
+
["tunnel-buffer-mib", "CARRIER_TUNNEL_BUFFER_MIB", "totalBufferedBytes", 1024 * 1024],
|
|
235
|
+
]) {
|
|
236
|
+
const v = tunnelOpt(flag, env);
|
|
237
|
+
if (v === null) continue;
|
|
238
|
+
if (!/^[1-9][0-9]{0,6}$/.test(String(v))) refuse(`--${flag} must be a whole number from 1 to 9999999`);
|
|
239
|
+
tunnelNumbers[key] = Number(v) * scale;
|
|
240
|
+
}
|
|
241
|
+
let tunnelRelay = null;
|
|
242
|
+
let tunnelOrigin = null;
|
|
243
|
+
let tunnelKeychain = null;
|
|
244
|
+
const tunnelLoopback = (h) => h === "::1" || /^127\.\d+\.\d+\.\d+$/.test(h);
|
|
245
|
+
if (acceptTunnels === null) {
|
|
246
|
+
if (tunnelOriginText !== null || tunnelKeychainPath !== null || Object.keys(tunnelNumbers).length) {
|
|
247
|
+
refuse("--tunnel-origin, --tunnel-keychain and the --tunnel-* limits need --accept-tunnels");
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
if (typeof acceptTunnels !== "string") refuse("--accept-tunnels needs an allow-file path, or open");
|
|
251
|
+
if (typeof tunnelOriginText !== "string") refuse("--accept-tunnels needs --tunnel-origin <https://origin>: the public origin seeds are served at");
|
|
252
|
+
const c = canonicalOrigin(tunnelOriginText);
|
|
253
|
+
if (!c.ok) refuse(`--tunnel-origin is not a relay origin (${c.reason}); the value is not shown`);
|
|
254
|
+
tunnelOrigin = c.origin;
|
|
255
|
+
if (acceptTunnels === "open") {
|
|
256
|
+
// 2.8.1 (owner order 2026-12-04): open admission on a public origin. The
|
|
257
|
+
// 2.8.0 loopback-only lock (RedTeam 085b71 C5) is lifted on purpose. With
|
|
258
|
+
// --tunnel-keychain an open relay attests "came through this live tunnel"
|
|
259
|
+
// (admission "open", V1 via Lead 3f4436), nothing more.
|
|
260
|
+
}
|
|
261
|
+
if (tunnelKeychainPath !== null) {
|
|
262
|
+
if (typeof tunnelKeychainPath !== "string") refuse("--tunnel-keychain needs a path to a keychain file");
|
|
263
|
+
tunnelKeychain = new Keychain(tunnelKeychainPath);
|
|
264
|
+
if (!tunnelKeychain.exists()) refuse(`tunnel keychain ${tunnelKeychainPath} not found (a carrier never mints its tunnel key)`);
|
|
265
|
+
let pub;
|
|
266
|
+
try { pub = tunnelKeychain.publicView(); } catch (e) { refuse(`tunnel keychain ${tunnelKeychainPath} is damaged or is not a key file (${e.code ?? e.message})`); }
|
|
267
|
+
if (!keyDerivesUuaid(pub?.publicKeyHex, pub?.uuaid)) refuse(`tunnel keychain ${tunnelKeychainPath}: its uuaid does not belong to its key`);
|
|
268
|
+
try { tunnelKeychain.load({ passphrase: tunnelPassphrase ?? "" }); } catch (e) { refuse(`tunnel keychain ${tunnelKeychainPath} did not load: ${e.message}`); }
|
|
269
|
+
const k = tunnelKeychain._identity.publicKeyHex;
|
|
270
|
+
if (receiptKeychain && receiptKeychain._identity.publicKeyHex === k) refuse("the tunnel key and the receipt key must be different keys");
|
|
271
|
+
if (seedKeychain && seedKeychain._identity.publicKeyHex === k) refuse("the tunnel key and the seed key must be different keys");
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
tunnelRelay = new TunnelRelay({
|
|
275
|
+
origin: tunnelOrigin,
|
|
276
|
+
admission: acceptTunnels === "open" ? { mode: "open" } : { mode: "allow-file", path: acceptTunnels },
|
|
277
|
+
keychain: tunnelKeychain, trustedProxies, limits: tunnelNumbers,
|
|
278
|
+
log: (line) => console.log(line),
|
|
279
|
+
});
|
|
280
|
+
} catch (e) {
|
|
281
|
+
refuse(`--accept-tunnels: ${e.message}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
186
285
|
let server;
|
|
187
286
|
try {
|
|
188
|
-
server = new CarrierServer({ dbPath, ttlDays, trustedTierIssuers: tierIssuers, secureDelete, receiptKeychain, keychain: seedKeychain, publicUrl, communityInboxWaits, trustedProxies });
|
|
287
|
+
server = new CarrierServer({ dbPath, ttlDays, trustedTierIssuers: tierIssuers, secureDelete, receiptKeychain, keychain: seedKeychain, publicUrl, communityInboxWaits, trustedProxies, tunnelRelay });
|
|
189
288
|
} catch (e) {
|
|
190
289
|
refuse(e.message);
|
|
191
290
|
}
|
|
@@ -196,6 +295,10 @@ console.log(` ttl: ${ttlDays} days`);
|
|
|
196
295
|
console.log(` tiers: ${tierIssuers.length ? `${tierIssuers.length} trusted issuer(s)` : "disabled (community budgets for all)"}`);
|
|
197
296
|
console.log(` secure-delete: ${secureDelete ? "on (expired envelopes are zeroed; WAL truncated after each expiry pass)" : "off (expired envelope bytes stay on disk until reused)"}`);
|
|
198
297
|
console.log(` seed: ${seedKeychain ? `${seedKeychain._identity.uuaid} at ${publicUrl} (signed /v1/seed-info)` : "off (no seed keychain; /v1/seed-info is 404)"}`);
|
|
298
|
+
if (acceptTunnels === "open" && !tunnelLoopback(addr.address)) {
|
|
299
|
+
console.error(`carrier: note: bound to ${addr.address}, not loopback. The carrier speaks plain http; serve ${tunnelOrigin} through a TLS proxy.`);
|
|
300
|
+
}
|
|
301
|
+
console.log(` tunnels: ${!tunnelRelay ? "off (/v1/tunnel and /e/* are 404)" : acceptTunnels === "open" ? `open (any seed that proves its uuaid key; caps on; one meter line per stream), serving ${tunnelOrigin}/e/<id>${tunnelKeychain ? `, attesting as ${tunnelKeychain._identity.publicKeyHex.slice(0, 16)}… (admission open)` : ", not attesting"}` : `allow-file ${acceptTunnels} (${tunnelRelay.allow.set.size} seed${tunnelRelay.allow.set.size === 1 ? "" : "s"}), serving ${tunnelOrigin}/e/<id>${tunnelKeychain ? `, attesting as ${tunnelKeychain._identity.publicKeyHex.slice(0, 16)}…` : ", not attesting"}`}`);
|
|
199
302
|
console.log(` receipts: ${server.receiptCarrier ? `signed as ${server.receiptCarrier} (uuaid.carrier-receipt.v1)` : "off (no receipt keychain)"}`);
|
|
200
303
|
|
|
201
304
|
// Vacuum expired envelopes hourly.
|