@uuaid/pillar 2.5.2 → 2.5.3
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 +58 -43
- package/README.md +29 -12
- package/bin/carrier.mjs +35 -9
- package/bin/pillar-directory.mjs +6 -4
- package/bin/pillar-escrow.mjs +7 -7
- package/bin/pillar-responder.mjs +2 -2
- package/bin/pillar-seed.mjs +36 -20
- package/bin/pillar.mjs +64 -22
- package/package.json +1 -1
- package/src/blob/blob.mjs +3 -0
- package/src/blob/broker.mjs +20 -0
- package/src/blob/store.mjs +9 -2
- package/src/escrow/escrow-service.mjs +44 -12
- package/src/escrow/terms.mjs +35 -8
- package/src/escrow/token-registry.mjs +3 -3
- package/src/groups-v2.mjs +51 -3
- package/src/identity/keychain.mjs +43 -8
- package/src/net/carrier-server.mjs +32 -7
- package/src/net/client-ip.mjs +45 -0
- package/src/net/transport.mjs +13 -1
- package/src/observability.mjs +2 -2
- package/src/pillar.mjs +32 -13
- package/src/sqlite-rekey.mjs +3 -2
package/HOSTING-LIMITS.md
CHANGED
|
@@ -5,9 +5,9 @@ clients do about each one, and how push/wake works. Read it before you write
|
|
|
5
5
|
a poll loop or host a carrier, seed, or push relay.
|
|
6
6
|
|
|
7
7
|
**Sources.** Each number is cited once, as `path:line`. Paths under `src/` and
|
|
8
|
-
`bin/` are in this package. `bin/` lines are as of 2.5.
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
`bin/` are in this package. `bin/` and `src/` lines are as of 2.5.3. `src/`
|
|
9
|
+
was unchanged from 2.4.1 to 2.5.2; 2.5.3 changes it, and every citation into a
|
|
10
|
+
file it changed was re-checked against 2.5.3. Paths under
|
|
11
11
|
`apps/`, `packages/` and `infra/` are in the UUAID monorepo at commit
|
|
12
12
|
`7e51fa2`, which is not public. `infra/pillar-blob/server.mjs` is cited at
|
|
13
13
|
monorepo commit `229c217`, the agent-first broker with RedTeam's conditions
|
|
@@ -31,45 +31,50 @@ envelope to every carrier, so each carrier counts all of your sends.
|
|
|
31
31
|
|
|
32
32
|
| Limit | Value | Source | When you hit it | What to do |
|
|
33
33
|
|---|---|---|---|---|
|
|
34
|
-
| Long-poll `wait` | 30 s. A larger value is cut to 30 without an error | :
|
|
35
|
-
| Re-check while waiting | every 400 ms | :
|
|
36
|
-
| Rows per reply | 200, oldest first | :
|
|
37
|
-
| Open long-polls (`wait` > 0) | 48 for community; 64 in all, so 16 are kept for priority grants | :
|
|
38
|
-
| `x-pillar-ts` clock skew | ±5 min | :
|
|
39
|
-
| `x-pillar-delegation` size | 8,192 bytes | :
|
|
40
|
-
|
|
41
|
-
**Authentication** (:
|
|
34
|
+
| Long-poll `wait` | 30 s. A larger value is cut to 30 without an error | :78 | 200 with `envelopes: []` after 30 s | Ask for 25 (§3) |
|
|
35
|
+
| Re-check while waiting | every 400 ms | :689 | n/a | Mail reaches a waiting poll about 0.4 s after it is stored, whatever `wait` is |
|
|
36
|
+
| Rows per reply | 200, oldest first | :681 | 200 with 200 rows | Poll again at once, `since` = highest `seq` |
|
|
37
|
+
| Open long-polls (`wait` > 0) | 48 for community; 64 in all, so 16 are kept for priority grants | :97, :101 | 503 `busy` | Wait at least 2 s, with jitter, and retry, or use `wait=0` for a while |
|
|
38
|
+
| `x-pillar-ts` clock skew | ±5 min | :81 | 401 `clock-skew` | Fix your clock (NTP). Retrying does not help |
|
|
39
|
+
| `x-pillar-delegation` size | 8,192 bytes | :82 | 401 `delegation-too-large` | Send a smaller delegation document |
|
|
40
|
+
|
|
41
|
+
**Authentication** (:595-624). Send `x-pillar-pubkey`, `x-pillar-ts` (Unix ms)
|
|
42
42
|
and `x-pillar-sig`, which is Ed25519 over
|
|
43
|
-
`GET /v1/inbox/<uuaid>?since=<seq>` + `"\n"` + ts. `wait` is not signed
|
|
43
|
+
`GET /v1/inbox/<uuaid>?since=<seq>` + `"\n"` + ts. `wait` is not signed, so
|
|
44
|
+
someone on the path can change it (to 0, turning a long-poll into a busy poll).
|
|
45
|
+
Signing it needs every client and every carrier to change together, so it waits
|
|
46
|
+
for a protocol revision. Within the ±5 min skew window a captured read can be
|
|
47
|
+
replayed to read the same page again; reads are idempotent and envelope bodies
|
|
48
|
+
are end-to-end encrypted. The
|
|
44
49
|
uuaid must be derived from the key. To read another identity's inbox, also
|
|
45
50
|
send `x-pillar-delegation`: a delegation document signed by that identity that
|
|
46
|
-
names your key and covers `inbox` or `*` (:
|
|
51
|
+
names your key and covers `inbox` or `*` (:639-655). Every auth failure is a
|
|
47
52
|
401 with the reason in `error`. Reads have no rate limit. Only the open
|
|
48
53
|
long-polls above are capped, and `wait=0` reads are not capped at all.
|
|
49
54
|
|
|
50
55
|
### Sending: `POST /v1/envelopes`
|
|
51
56
|
|
|
52
|
-
The carrier runs these checks in order (:
|
|
57
|
+
The carrier runs these checks in order (:503-593). Each budget is spent when
|
|
53
58
|
its check passes. So a send refused later for being stale or for a full store
|
|
54
59
|
has still used budget, and so has a duplicate.
|
|
55
60
|
|
|
56
61
|
| Check | Value | Source | When you hit it | What to do |
|
|
57
62
|
|---|---|---|---|---|
|
|
58
|
-
| Raw body read | 2 MiB + 8 KiB | :
|
|
59
|
-
| Envelope signature and shape | n/a | :
|
|
60
|
-
| Refused sends per client IP | 60 per window | :
|
|
61
|
-
| Body size | 512 KiB community; a tier grant can raise it (table below) | :
|
|
62
|
-
| Sends per sender uuaid | 120 per window for community | :
|
|
63
|
-
| Accepted sends per client IP | 300 per window; priority grants use their own bucket of 600 | :
|
|
64
|
-
| Envelope `createdAt` | within ±24 h of carrier time | :
|
|
65
|
-
| Store size | 256 MiB. Community sends are refused above 85% (217.6 MiB) | :
|
|
63
|
+
| Raw body read | 2 MiB + 8 KiB | :80 | Connection dropped, no JSON body | Stay under your tier's body limit |
|
|
64
|
+
| Envelope signature and shape | n/a | :504-514 | 400 with the reason (403 `delegation-invalid:*`) | Fix the envelope |
|
|
65
|
+
| Refused sends per client IP | 60 per window | :88 | 429 `rate-limited`, which hides the real reason | Stop and fix the sender |
|
|
66
|
+
| Body size | 512 KiB community; a tier grant can raise it (table below) | :79 | 413 `body-too-large` + `maxBodyBytes`, `tier` | Send the payload as a blob (§3) |
|
|
67
|
+
| Sends per sender uuaid | 120 per window for community | :86 | 429 `rate-limited` | Back off (§3) |
|
|
68
|
+
| Accepted sends per client IP | 300 per window; priority grants use their own bucket of 600 | :87, :113 | 429 `rate-limited` | Everyone behind your NAT shares this budget |
|
|
69
|
+
| Envelope `createdAt` | within ±24 h of carrier time | :84 | 400 `stale-envelope` | Seal a new envelope. Never retry an old one |
|
|
70
|
+
| Store size | 256 MiB. Community sends are refused above 85% (217.6 MiB) | :90, :96 | 503 `carrier-full` | Your other carriers still take it. Don't retry this one soon |
|
|
66
71
|
|
|
67
72
|
Sending the same envelope id again is safe. It returns 202 with
|
|
68
|
-
`duplicate: true` and the `seq` it was stored at (:
|
|
73
|
+
`duplicate: true` and the `seq` it was stored at (:582, :589). The carrier keys
|
|
69
74
|
envelopes on sender and id together (from 2.4.0), so another sender's envelope
|
|
70
75
|
under the same id is a different envelope and is stored. On a carrier with a
|
|
71
76
|
receipt key (below), the same id from the same sender with a different body is
|
|
72
|
-
refused 409 `envelope-id-conflict` (:
|
|
77
|
+
refused 409 `envelope-id-conflict` (:587).
|
|
73
78
|
|
|
74
79
|
**Carrier receipts (from 2.1.0).** Start the carrier with
|
|
75
80
|
`--receipt-keychain <file>` (`CARRIER_RECEIPT_KEYCHAIN`; passphrase in
|
|
@@ -79,18 +84,22 @@ acceptance receipt signed from the stored row (src/net/carrier-receipt.mjs).
|
|
|
79
84
|
The carrier never mints this key: a missing or unreadable file refuses to
|
|
80
85
|
start. Without the option nothing changes.
|
|
81
86
|
|
|
82
|
-
**Windows, memory, retention.** Every rate window is a sliding 60 s (:
|
|
83
|
-
held in process memory (:
|
|
84
|
-
keys the oldest is dropped (:
|
|
85
|
-
`--ttl`, bin/carrier.mjs:
|
|
86
|
-
deleted hourly (bin/carrier.mjs:
|
|
87
|
+
**Windows, memory, retention.** Every rate window is a sliding 60 s (:85),
|
|
88
|
+
held in process memory (:245), so a restart resets every budget; past 10,000
|
|
89
|
+
keys the oldest is dropped (:91). Envelopes are kept 14 days by default (:165;
|
|
90
|
+
`--ttl`, bin/carrier.mjs:62-68, bin/pillar-seed.mjs:206) and expired rows are
|
|
91
|
+
deleted hourly (bin/carrier.mjs:132-137, bin/pillar-seed.mjs:458-463). Each row
|
|
87
92
|
keeps the deadline set when it was stored (`retain_until` = acceptance time +
|
|
88
93
|
TTL), so lowering `--ttl` later never deletes a row before that deadline.
|
|
89
|
-
From 2.5.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
From 2.5.3 every carrier enforces a ceiling of 36500 days (100 years):
|
|
95
|
+
`CarrierServer` refuses a larger TTL (:171), so does `pillar-carrier --ttl` /
|
|
96
|
+
`CARRIER_TTL_DAYS` (bin/carrier.mjs:68), as `pillar-seed` has since 2.5.2
|
|
97
|
+
(bin/pillar-seed.mjs:209), and no deadline is written past
|
|
98
|
+
9999-12-31T23:59:59.999Z (:273). The deadline is an ISO-8601 string compared as
|
|
99
|
+
text: past year 9999 it read `+010000-…`, which the hourly expiry took as
|
|
100
|
+
already past, so from about 2,912,144 days mail was deleted on the next pass. A
|
|
101
|
+
store holding such a deadline from an earlier build gets the latest four-digit
|
|
102
|
+
one on its first 2.5.3 start (:209).
|
|
94
103
|
|
|
95
104
|
**Tier grants** (src/identity/tier.mjs:52-56). A signed grant in
|
|
96
105
|
`x-pillar-tier-grant` raises its holder's send budgets:
|
|
@@ -105,8 +114,8 @@ no ceiling yet; every shipped carrier unit passes `--ttl 14`.
|
|
|
105
114
|
|
|
106
115
|
No grant can go above 6,000 sends per window or 2 MiB
|
|
107
116
|
(src/identity/tier.mjs:67-68). Only `pillar-carrier --tier-issuers <hex>`
|
|
108
|
-
honors grants (bin/carrier.mjs:
|
|
109
|
-
(bin/pillar-seed.mjs:
|
|
117
|
+
honors grants (bin/carrier.mjs:85-86). `pillar-seed` passes no issuers
|
|
118
|
+
(bin/pillar-seed.mjs:399), so on a seed every sender gets community budgets
|
|
110
119
|
and the priority reserves are never used. `@uuaid/pillar-client` never sends a
|
|
111
120
|
grant.
|
|
112
121
|
|
|
@@ -114,8 +123,8 @@ grant.
|
|
|
114
123
|
|
|
115
124
|
| Client | `wait` | Request timeout | After an error | Carriers |
|
|
116
125
|
|---|---|---|---|---|
|
|
117
|
-
| `pillar recv`, `Pillar.startCarrierPolling()` | 25 s (src/pillar.mjs:
|
|
118
|
-
| `pillar inbox` | 0, reading pages until one is empty (src/pillar.mjs:
|
|
126
|
+
| `pillar recv`, `Pillar.startCarrierPolling()` | 25 s (src/pillar.mjs:542) | 40 s (src/net/carrier-client.mjs:143) | sleep 2 s (src/net/carrier-client.mjs:187) | all in parallel, one cursor each (src/net/carrier-client.mjs:175-180) |
|
|
127
|
+
| `pillar inbox` | 0, reading pages until one is empty (src/pillar.mjs:571-590) | 40 s | exits | one at a time |
|
|
119
128
|
| `pillar-responder` | 20 s (bin/pillar-responder.mjs:299) | 40 s | sleep 2 s | all in parallel |
|
|
120
129
|
| `@uuaid/pillar-client` `poll()` / `subscribe()` | 25 s (packages/pillar-client/src/carrier.ts:149) | `wait` + 15 s (packages/pillar-client/src/carrier.ts:158) | sleep 2 s (packages/pillar-client/src/carrier.ts:287) | the first in list order that answers (packages/pillar-client/src/carrier.ts:160-167) |
|
|
121
130
|
| Pillar mobile app, on screen | 25 s (apps/mobile/src/services/pillar.ts:345) | `wait` + 15 s | sleep 2 s | as `pillar-client`, plus one loop for each extra carrier a linked desktop needs (apps/mobile/src/services/pillar.ts:208-213) |
|
|
@@ -195,6 +204,9 @@ extra carriers.
|
|
|
195
204
|
uploaded, hash-checked objects, checked at reserve and again at finalize
|
|
196
205
|
(infra/pillar-blob/server.mjs:115). A reservation that is never finalized
|
|
197
206
|
expires after 1 h whatever its expiry (infra/pillar-blob/server.mjs:126);
|
|
207
|
+
a client cannot cancel one on this broker (an in-process broker takes it
|
|
208
|
+
back when the upload fails, from 2.5.3). A signed broker request has no
|
|
209
|
+
expiry of its own: it rides on a single-use challenge that expires;
|
|
198
210
|
- expiry at most 72 h (infra/pillar-blob/server.mjs:117), against 7 days
|
|
199
211
|
with a badge (infra/pillar-blob/server.mjs:78). The client default is
|
|
200
212
|
24 h (src/blob/blob.mjs:48);
|
|
@@ -303,7 +315,7 @@ registrations and 4 poll tokens.
|
|
|
303
315
|
## 5. Hosting a carrier, seed or relay
|
|
304
316
|
|
|
305
317
|
`pillar-carrier` and `pillar-seed` listen on 127.0.0.1:8799 by default
|
|
306
|
-
(bin/carrier.mjs:
|
|
318
|
+
(bin/carrier.mjs:59-60, bin/pillar-seed.mjs:197, :203). The relay listens on
|
|
307
319
|
127.0.0.1:8801 (apps/pillar-push/src/config.ts:38-39). Put a TLS proxy in
|
|
308
320
|
front of each one. The templates in the third column are in the monorepo
|
|
309
321
|
(see the top of this file), not in this package; the examples after the
|
|
@@ -312,7 +324,7 @@ table are complete on their own.
|
|
|
312
324
|
| Proxy rule | Why | pillar-sfo (live) and monorepo template |
|
|
313
325
|
|---|---|---|
|
|
314
326
|
| Carrier read timeout > 30 s + margin | The carrier can hold a request for 30 s plus one 400 ms tick | `/v1/` → 127.0.0.1:8799, 40 s; template: infra/pillar-carrier-fleet/provision-carrier.sh:102 |
|
|
315
|
-
| Replace `X-Forwarded-For` with the peer's address |
|
|
327
|
+
| Replace `X-Forwarded-For` with the peer's address | From 2.5.3 the carrier reads XFF only when the TCP peer is a trusted proxy: 127.0.0.1 and ::1 unless `--trusted-proxy` / `CARRIER_TRUSTED_PROXIES` / `SEED_TRUSTED_PROXIES` names others (exact addresses). It charges the right-most address that is not a trusted proxy (src/net/client-ip.mjs:37-44, used at :414-416), so a proxy that appends no longer lets a client pick its rate bucket (up to 2.5.2 the first entry counted, from anyone). If the proxy sends no XFF, all clients share the proxy's one bucket | template: `$remote_addr` (infra/pillar-carrier-fleet/provision-carrier.sh:107) |
|
|
316
328
|
| Body size ≥ largest honored body + 8 KiB | 512 KiB on a seed; 2 MiB + 8 KiB with `--tier-issuers`. Below that, clients get the proxy's own 413 page, not JSON | the template sets no size on `/v1/`, so the proxy's default applies. Set it explicitly |
|
|
317
329
|
| CORS: allow `x-pillar-pubkey`, `x-pillar-ts`, `x-pillar-sig` | Browser clients send them. Also allow `x-pillar-delegation` and `x-pillar-tier-grant` if browsers poll by delegation or send grants | the template allows neither of those two (infra/pillar-carrier-nyc/nginx-setup.sh:25) |
|
|
318
330
|
| Relay: a short timeout is fine | No relay route long-polls | `/push/` → 127.0.0.1:8801/, 30 s |
|
|
@@ -397,8 +409,8 @@ cannot reach a seed on one.
|
|
|
397
409
|
|
|
398
410
|
**Under load:**
|
|
399
411
|
- **`carrier-full` does not clear by itself.** `vacuum()` deletes expired rows
|
|
400
|
-
(:
|
|
401
|
-
(:
|
|
412
|
+
(:453-458) but never runs SQLite `VACUUM`. The size check reads `page_count`
|
|
413
|
+
(:544-547), which still counts freed pages. In a local test with the same
|
|
402
414
|
schema, deleting all 300 rows of a 30,904,320-byte store left
|
|
403
415
|
`page_count × page_size` at 30,904,320 bytes, with 7,540 pages free. So once
|
|
404
416
|
the file passes 217.6 MiB, community sends get 503 until you stop the
|
|
@@ -407,7 +419,7 @@ cannot reach a seed on one.
|
|
|
407
419
|
- **From 2.4.0 a start may run `VACUUM`.** Re-keying the envelopes table (see
|
|
408
420
|
RELEASE-NOTES-2.4.0.md in the pillar source repository) copies it and frees the old copy, which would double
|
|
409
421
|
the counted size. The carrier reclaims those pages right after the re-key,
|
|
410
|
-
then truncates the WAL (:
|
|
422
|
+
then truncates the WAL (:226-238). It also vacuums on any later start that
|
|
411
423
|
finds more than a quarter of the file's pages free. That retries a first
|
|
412
424
|
start that was killed or whose `VACUUM` failed. It also catches a store
|
|
413
425
|
thinned that much by TTL expiry, where the cap was counting the free pages.
|
|
@@ -431,6 +443,9 @@ cannot reach a seed on one.
|
|
|
431
443
|
still writing: its process is gone; or it is over an hour old; or it carries
|
|
432
444
|
the carrier's own pid but predates this start (a container restart reuses
|
|
433
445
|
the pid, often 1). After the first 2.4.0 start, check that none remains.
|
|
446
|
+
From 2.5.3 the backup's `-wal` and `-shm` go with it. Run one carrier per
|
|
447
|
+
store: two carriers on one store path can sweep each other's backups once
|
|
448
|
+
they are an hour old.
|
|
434
449
|
- Sends get 429 and 503 as in §1; new long-polls get 503 `busy` once 48
|
|
435
450
|
community (64 in all) are open.
|
|
436
451
|
- Nothing limits `wait=0` reads, `/v1/health` or `/v1/seed-info`. Rate-limit
|
package/README.md
CHANGED
|
@@ -123,6 +123,12 @@ recipient has it. Two recipient-signed signals from the
|
|
|
123
123
|
[interaction convention](INTERACTION-CONVENTION.md) close the gap, both
|
|
124
124
|
**off by default**:
|
|
125
125
|
|
|
126
|
+
In `pillar status`, "carrier" means a carrier accepted the envelope. From
|
|
127
|
+
2.5.3 that is the only thing that marks it: a send straight to a peer over
|
|
128
|
+
libp2p also goes to your carriers, because a stream that closes is not a
|
|
129
|
+
receipt. With no carrier configured, such a send stays pending until the
|
|
130
|
+
recipient's ack arrives, if it sends one.
|
|
131
|
+
|
|
126
132
|
```sh
|
|
127
133
|
pillar receipts on # or: receipts delivered on | receipts read on
|
|
128
134
|
pillar send kevin message '{"text":"…"}' --wait-ack 60 # exit 4 if no signed ack arrives
|
|
@@ -209,9 +215,14 @@ What an outside operator needs to know before the first start:
|
|
|
209
215
|
another address only for a proxy on another host, and firewall the port to it.
|
|
210
216
|
From 2.5.1 a `SEED_*` variable set to an empty string is refused rather than
|
|
211
217
|
read as a value: in 2.4 an empty `SEED_HOST` listened on every interface.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
From 2.5.3 the seed believes `X-Forwarded-For` only from a proxy on this
|
|
219
|
+
machine (127.0.0.1, ::1); name a proxy on another host with
|
|
220
|
+
`--trusted-proxy <ip>` (or `SEED_TRUSTED_PROXIES`).
|
|
221
|
+
Before it creates the key or the database, the start binds the host and
|
|
222
|
+
port, so a host that does not resolve, an address not on this machine, or a
|
|
223
|
+
port in use stops it with nothing written. From 2.5.3 the server keeps that
|
|
224
|
+
same listener, so the port cannot be taken between the check and the start
|
|
225
|
+
(up to 2.5.2 such a start failed with the key already minted).
|
|
215
226
|
- **The seed's identity is `uuaid:foundation:agent:…` by default.** Every
|
|
216
227
|
service identity this package mints (seed, directory, escrow) uses the
|
|
217
228
|
`foundation` namespace unless told otherwise. The namespace names neither the
|
|
@@ -228,10 +239,14 @@ What an outside operator needs to know before the first start:
|
|
|
228
239
|
0600) is protected by its file mode alone: anyone who can read it can sign as
|
|
229
240
|
your seed. From 2.5.1 a new key can be saved under a passphrase, read from a
|
|
230
241
|
file with `--passphrase-file <path>` or from `SEED_KEYCHAIN_PASSPHRASE`. One
|
|
231
|
-
trailing newline in the file is ignored.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
242
|
+
trailing newline in the file is ignored. From 2.5.3 a key saved under a
|
|
243
|
+
passphrase is written with scrypt (N=2^17, r=8, p=1; about 0.2 s per open,
|
|
244
|
+
`src/identity/keychain.mjs:27`, `:33-48`), so each guess at a copied file
|
|
245
|
+
costs that much. A key saved by 2.5.2 or earlier keeps its single
|
|
246
|
+
HKDF-SHA256, with no work factor, and still opens; a key minted by 2.5.3
|
|
247
|
+
under a passphrase does not open on 2.5.2 or earlier. **Use a long random
|
|
248
|
+
passphrase either way, not a memorable one:** a short or human-chosen one
|
|
249
|
+
can still be guessed offline from a copied key file. Prefer the
|
|
235
250
|
file to the variable: an environment variable can be read back from the
|
|
236
251
|
process by root and by the seed's own user. Under systemd, a credential keeps
|
|
237
252
|
it out of the unit file:
|
|
@@ -255,15 +270,17 @@ What an outside operator needs to know before the first start:
|
|
|
255
270
|
A key saved without a passphrase (every key from 2.4 or earlier) keeps
|
|
256
271
|
opening without one; a passphrase cannot be added to an existing key. Run the
|
|
257
272
|
seed as its own user, keep `--home` private, and encrypt the disk either way.
|
|
258
|
-
- **Keep `--ttl` at the default 14 days unless you need longer.**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
273
|
+
- **Keep `--ttl` at the default 14 days unless you need longer.** It is at most
|
|
274
|
+
36500 days (100 years): for `pillar-seed` from 2.5.2, and for `pillar-carrier`
|
|
275
|
+
and every `CarrierServer` from 2.5.3. Larger values used to be accepted, and
|
|
276
|
+
from about 2,912,144 days the hourly pass deleted mail as soon as it was stored.
|
|
277
|
+
- **There is no public seed registry yet** (as of 2.5.3, October 2026).
|
|
262
278
|
`https://pillar.uuaid.org` does not answer `/v1/seeds`, so
|
|
263
279
|
`--announce https://pillar.uuaid.org` cannot enroll.
|
|
264
280
|
A seed runs standalone: it carries mail for every client configured with its
|
|
265
281
|
URL (`pillar init --carriers https://seed.example.org`). `--announce` works
|
|
266
|
-
against a registry that runs `pillar-directory
|
|
282
|
+
against a registry that runs `pillar-directory`; from 2.5.3, announcing to a
|
|
283
|
+
host with no registry says so in the seed's output.
|
|
267
284
|
- **Use a real domain.** Free no-DNS names (such as `*.sslip.io`) are blocked
|
|
268
285
|
by some home and corporate network filters, so some clients cannot reach a
|
|
269
286
|
seed on one.
|
package/bin/carrier.mjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* carrier --port 8799 --host 127.0.0.1 --db /opt/pillar-carrier/carrier.db
|
|
6
6
|
* carrier ... --secure-delete off # keep deleted envelope bytes (default: on)
|
|
7
7
|
* carrier ... --community-waits 192 # community inbox long-poll cap (CARRIER_COMMUNITY_WAITS; default 48, +16 priority reserve)
|
|
8
|
+
* carrier ... --trusted-proxy 10.0.0.5 # whose X-Forwarded-For counts (CARRIER_TRUSTED_PROXIES; default 127.0.0.1,::1)
|
|
8
9
|
* carrier ... --receipt-keychain /opt/pillar-carrier/receipt-keychain.json
|
|
9
10
|
* # sign uuaid.carrier-receipt.v1 receipts (default: off)
|
|
10
11
|
*
|
|
@@ -24,8 +25,9 @@
|
|
|
24
25
|
* signs nothing and every response is as before.
|
|
25
26
|
*/
|
|
26
27
|
import "../src/node-check.mjs"; // must stay the first import: refuses Node < 22 before any dependency loads
|
|
27
|
-
import { CarrierServer, parseSecureDelete, parseCommunityWaits } from "../src/net/carrier-server.mjs";
|
|
28
|
+
import { CarrierServer, parseSecureDelete, parseCommunityWaits, MAX_TTL_DAYS } from "../src/net/carrier-server.mjs";
|
|
28
29
|
import { Keychain } from "../src/identity/keychain.mjs";
|
|
30
|
+
import { parseTrustedProxies } from "../src/net/client-ip.mjs";
|
|
29
31
|
|
|
30
32
|
function parseArgs(argv) {
|
|
31
33
|
const args = {};
|
|
@@ -39,18 +41,44 @@ function parseArgs(argv) {
|
|
|
39
41
|
return args;
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Refuse to start: one line to stderr, exit 2. A control character or a line
|
|
46
|
+
* separator in the message (an echoed value) is shown escaped, so a refusal is
|
|
47
|
+
* always one line (as pillar-seed's, 2.5.2 G2).
|
|
48
|
+
*/
|
|
49
|
+
function refuse(message) {
|
|
50
|
+
console.error(`carrier: ${oneLine(message)}`);
|
|
51
|
+
process.exit(2);
|
|
52
|
+
}
|
|
53
|
+
const ESCAPES = { "\n": "\\n", "\r": "\\r", "\t": "\\t" };
|
|
54
|
+
function oneLine(text) {
|
|
55
|
+
return String(text).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, (c) => ESCAPES[c] ?? `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
const args = parseArgs(process.argv.slice(2));
|
|
43
59
|
const port = Number(args.port ?? process.env.CARRIER_PORT ?? 8799);
|
|
44
60
|
const host = args.host ?? process.env.CARRIER_HOST ?? "127.0.0.1";
|
|
45
61
|
const dbPath = args.db ?? process.env.CARRIER_DB ?? "carrier.db";
|
|
46
|
-
const
|
|
62
|
+
const ttlText = String(args.ttl ?? process.env.CARRIER_TTL_DAYS ?? 14);
|
|
63
|
+
const ttlDays = Number(ttlText);
|
|
64
|
+
// Digits with an optional decimal part (Number() alone took "0x10", "1e3", " 14" and
|
|
65
|
+
// "", the last as 0), and at most MAX_TTL_DAYS: past year 9999 a stored deadline
|
|
66
|
+
// sorted before today and the hourly vacuum deleted fresh mail (2.5.3).
|
|
67
|
+
if (!/^[0-9]+(\.[0-9]+)?$/.test(ttlText) || !(ttlDays > 0)) refuse(`--ttl must be a positive number of days written as digits (14, 7.5), not ${JSON.stringify(ttlText)}`);
|
|
68
|
+
if (ttlDays > MAX_TTL_DAYS) refuse(`--ttl must be at most ${MAX_TTL_DAYS} days (100 years), not ${JSON.stringify(ttlText)}`);
|
|
47
69
|
// Community inbox long-poll cap (default 48; a 16-slot priority reserve sits on top).
|
|
48
70
|
let communityInboxWaits;
|
|
49
71
|
try {
|
|
50
72
|
communityInboxWaits = parseCommunityWaits(args["community-waits"] ?? process.env.CARRIER_COMMUNITY_WAITS);
|
|
51
73
|
} catch (e) {
|
|
52
|
-
|
|
53
|
-
|
|
74
|
+
refuse(e.message);
|
|
75
|
+
}
|
|
76
|
+
// Whose X-Forwarded-For counts for the per-IP budgets (2.5.3): this machine by default.
|
|
77
|
+
let trustedProxies;
|
|
78
|
+
try {
|
|
79
|
+
trustedProxies = parseTrustedProxies(args["trusted-proxy"] ?? process.env.CARRIER_TRUSTED_PROXIES);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
refuse(e.message);
|
|
54
82
|
}
|
|
55
83
|
// Tier grants: comma-separated issuer pubkeys (hex) whose signed grants this
|
|
56
84
|
// carrier honors for raised budgets. Unset = all senders get community tier.
|
|
@@ -62,8 +90,7 @@ let secureDelete;
|
|
|
62
90
|
try {
|
|
63
91
|
secureDelete = parseSecureDelete(args["secure-delete"] ?? process.env.CARRIER_SECURE_DELETE);
|
|
64
92
|
} catch (e) {
|
|
65
|
-
|
|
66
|
-
process.exit(2);
|
|
93
|
+
refuse(e.message);
|
|
67
94
|
}
|
|
68
95
|
|
|
69
96
|
// Optional receipt key (separate from any seed or agent keychain on the box).
|
|
@@ -89,10 +116,9 @@ if (receiptKeychainPath !== null && receiptKeychainPath !== "") {
|
|
|
89
116
|
|
|
90
117
|
let server;
|
|
91
118
|
try {
|
|
92
|
-
server = new CarrierServer({ dbPath, ttlDays, trustedTierIssuers: tierIssuers, secureDelete, receiptKeychain, communityInboxWaits });
|
|
119
|
+
server = new CarrierServer({ dbPath, ttlDays, trustedTierIssuers: tierIssuers, secureDelete, receiptKeychain, communityInboxWaits, trustedProxies });
|
|
93
120
|
} catch (e) {
|
|
94
|
-
|
|
95
|
-
process.exit(2);
|
|
121
|
+
refuse(e.message);
|
|
96
122
|
}
|
|
97
123
|
const addr = await server.listen(port, host);
|
|
98
124
|
console.log(`carrier listening on ${addr.address}:${addr.port}`);
|
package/bin/pillar-directory.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import { readFileSync, existsSync, mkdirSync } from "node:fs";
|
|
|
28
28
|
import { homedir } from "node:os";
|
|
29
29
|
import { join } from "node:path";
|
|
30
30
|
import { SeedRegistry } from "../src/net/seed-registry.mjs";
|
|
31
|
+
import { clientIpOf, parseTrustedProxies } from "../src/net/client-ip.mjs";
|
|
31
32
|
import { Keychain, mintNamespace, SERVICE_IDENTITY_NAMESPACE } from "../src/identity/keychain.mjs";
|
|
32
33
|
|
|
33
34
|
function parseArgs(argv) {
|
|
@@ -120,10 +121,11 @@ function readBody(req) {
|
|
|
120
121
|
});
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
124
|
+
// X-Forwarded-For counts only from a trusted proxy (2.5.3; src/net/client-ip.mjs).
|
|
125
|
+
let trustedProxies;
|
|
126
|
+
try { trustedProxies = parseTrustedProxies(args["trusted-proxy"] ?? process.env.DIRECTORY_TRUSTED_PROXIES); }
|
|
127
|
+
catch (e) { console.error(`pillar-directory: ${e.message}`); process.exit(2); }
|
|
128
|
+
const clientIp = (req) => clientIpOf(req, trustedProxies);
|
|
127
129
|
|
|
128
130
|
const server = createServer(async (req, res) => {
|
|
129
131
|
try {
|
package/bin/pillar-escrow.mjs
CHANGED
|
@@ -181,7 +181,7 @@ async function cmdInit(args) {
|
|
|
181
181
|
writeFileSync(zf, JSON.stringify({ apiKey: "", handle: "" }, null, 2) + "\n", { mode: 0o600 });
|
|
182
182
|
}
|
|
183
183
|
const cfg = join(home, "config.json");
|
|
184
|
-
if (!existsSync(cfg)) writeFileSync(cfg, JSON.stringify({ carriers: [] }, null, 2) + "\n");
|
|
184
|
+
if (!existsSync(cfg)) writeFileSync(cfg, JSON.stringify({ carriers: [] }, null, 2) + "\n", { mode: 0o600 });
|
|
185
185
|
console.log(JSON.stringify({
|
|
186
186
|
home,
|
|
187
187
|
uuaid: kc._identity.uuaid,
|
|
@@ -315,7 +315,7 @@ async function cmdSell(args) {
|
|
|
315
315
|
if (!verifyReceiptSig(terms.escrowPubKeyHex, receipt)) die("RECEIPT SIGNATURE INVALID — do not trust this completion");
|
|
316
316
|
const out = args["receipt-out"] ?? join(home, "sell-receipts", `${terms.offerId}.json`);
|
|
317
317
|
mkdirSync(dirname(out), { recursive: true });
|
|
318
|
-
writeFileSync(out, JSON.stringify(receipt, null, 2) + "\n");
|
|
318
|
+
writeFileSync(out, JSON.stringify(receipt, null, 2) + "\n", { mode: 0o600 });
|
|
319
319
|
console.log(JSON.stringify({
|
|
320
320
|
ok: true, offerId: terms.offerId, role: "seller",
|
|
321
321
|
priceGons: finalPrice, payoutGons: sellerPayout, feeAllocation: allocation ?? "mutual",
|
|
@@ -381,10 +381,10 @@ async function cmdBuy(args) {
|
|
|
381
381
|
if (!verifyReceiptSig(terms.escrowPubKeyHex, receipt)) die("RECEIPT SIGNATURE INVALID — do not trust this completion");
|
|
382
382
|
const plain = openBox(Buffer.from(contentKeyHex, "hex"), dv.env.payload.box);
|
|
383
383
|
if (sha256Hex(plain) !== terms.itemHash) die("deliverable hash mismatch — box does not match the signed terms");
|
|
384
|
-
writeFileSync(out, plain);
|
|
384
|
+
writeFileSync(out, plain, { mode: 0o600 }); // the bought plaintext: owner-only (2.5.3, AC7-Kimi n)
|
|
385
385
|
const receiptOut = args["receipt-out"] ?? join(home, "buy-receipts", `${terms.offerId}.json`);
|
|
386
386
|
mkdirSync(dirname(receiptOut), { recursive: true });
|
|
387
|
-
writeFileSync(receiptOut, JSON.stringify(receipt, null, 2) + "\n");
|
|
387
|
+
writeFileSync(receiptOut, JSON.stringify(receipt, null, 2) + "\n", { mode: 0o600 });
|
|
388
388
|
console.log(JSON.stringify({ ok: true, offerId: terms.offerId, role: "buyer", priceGons: terms.priceGons, file: out, receiptPath: receiptOut }, null, 2));
|
|
389
389
|
}
|
|
390
390
|
|
|
@@ -498,7 +498,7 @@ async function cmdVerify(args) {
|
|
|
498
498
|
});
|
|
499
499
|
if (typeof args.out === "string") {
|
|
500
500
|
mkdirSync(dirname(args.out), { recursive: true });
|
|
501
|
-
writeFileSync(args.out, JSON.stringify(att, null, 2) + "\n");
|
|
501
|
+
writeFileSync(args.out, JSON.stringify(att, null, 2) + "\n", { mode: 0o600 });
|
|
502
502
|
}
|
|
503
503
|
console.log(JSON.stringify(att, null, 2));
|
|
504
504
|
exit(att.verdict === "verified" ? 0 : att.verdict === "pending" ? 3 : 1);
|
|
@@ -556,7 +556,7 @@ async function cmdAck(args) {
|
|
|
556
556
|
const doc = { v: 1, kind: "vda-delivery-ack-bundle", ...r };
|
|
557
557
|
if (typeof args.out === "string") {
|
|
558
558
|
mkdirSync(dirname(args.out), { recursive: true });
|
|
559
|
-
writeFileSync(args.out, JSON.stringify(doc, null, 2) + "\n");
|
|
559
|
+
writeFileSync(args.out, JSON.stringify(doc, null, 2) + "\n", { mode: 0o600 });
|
|
560
560
|
}
|
|
561
561
|
console.log(JSON.stringify(doc, null, 2));
|
|
562
562
|
}
|
|
@@ -595,7 +595,7 @@ async function cmdAttestDelivery(args) {
|
|
|
595
595
|
}
|
|
596
596
|
if (typeof args.out === "string") {
|
|
597
597
|
mkdirSync(dirname(args.out), { recursive: true });
|
|
598
|
-
writeFileSync(args.out, JSON.stringify(out, null, 2) + "\n");
|
|
598
|
+
writeFileSync(args.out, JSON.stringify(out, null, 2) + "\n", { mode: 0o600 });
|
|
599
599
|
}
|
|
600
600
|
console.log(JSON.stringify(out, null, 2));
|
|
601
601
|
exit(final.verdict === "verified" ? 0 : final.verdict === "pending" ? 3 : 1);
|
package/bin/pillar-responder.mjs
CHANGED
|
@@ -82,7 +82,7 @@ function journalRequest(home, env) {
|
|
|
82
82
|
sender: env.sender,
|
|
83
83
|
senderPublicKey: env.transportSignature.publicKey,
|
|
84
84
|
payload: env.payload,
|
|
85
|
-
}) + "\n");
|
|
85
|
+
}) + "\n", { mode: 0o600 }); // decrypted request payloads: owner-only (2.5.3)
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function journalDone(home, id, reply) {
|
|
@@ -92,7 +92,7 @@ function journalDone(home, id, reply) {
|
|
|
92
92
|
id,
|
|
93
93
|
replyText: reply.text,
|
|
94
94
|
replyStatus: reply.status,
|
|
95
|
-
}) + "\n");
|
|
95
|
+
}) + "\n", { mode: 0o600 });
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// Requests journaled but never completed, within the replay window.
|
package/bin/pillar-seed.mjs
CHANGED
|
@@ -45,7 +45,8 @@ import { chmodSync, closeSync, constants as fsConstants, existsSync, fstatSync,
|
|
|
45
45
|
import { createServer } from "node:net";
|
|
46
46
|
import { homedir } from "node:os";
|
|
47
47
|
import { join, resolve } from "node:path";
|
|
48
|
-
import { CarrierServer, parseSecureDelete, parseCommunityWaits } from "../src/net/carrier-server.mjs";
|
|
48
|
+
import { CarrierServer, parseSecureDelete, parseCommunityWaits, MAX_TTL_DAYS } from "../src/net/carrier-server.mjs";
|
|
49
|
+
import { parseTrustedProxies } from "../src/net/client-ip.mjs";
|
|
49
50
|
import { Keychain, keyDerivesUuaid, mintNamespace, SERVICE_IDENTITY_NAMESPACE } from "../src/identity/keychain.mjs";
|
|
50
51
|
|
|
51
52
|
const USAGE = `usage: pillar-seed [flags]
|
|
@@ -67,6 +68,8 @@ and pass the proxy's address as --public-url.
|
|
|
67
68
|
--public-url <https://> the URL your proxy serves (SEED_PUBLIC_URL)
|
|
68
69
|
--secure-delete <on|off> zero expired envelopes (SEED_SECURE_DELETE, default on)
|
|
69
70
|
--community-waits <n> long-poll slots (SEED_COMMUNITY_WAITS, default 48)
|
|
71
|
+
--trusted-proxy <ips> whose X-Forwarded-For counts for per-IP budgets
|
|
72
|
+
(SEED_TRUSTED_PROXIES, default 127.0.0.1,::1)
|
|
70
73
|
--announce <registry> enroll --public-url in a seed registry
|
|
71
74
|
--operator <name> operator label sent with --announce (SEED_OPERATOR)
|
|
72
75
|
--region <name> region label sent with --announce (SEED_REGION)
|
|
@@ -92,10 +95,10 @@ key. Every refusal is one line on stderr, with exit code 2.`;
|
|
|
92
95
|
// Every flag this command reads. Every other token is refused before the seed
|
|
93
96
|
// key or the database is touched, so a typo, a bare word or `--help` never
|
|
94
97
|
// starts a seed.
|
|
95
|
-
const FLAGS = new Set(["announce", "community-waits", "db", "help", "home", "host", "namespace", "operator", "passphrase-file", "port", "public-url", "region", "secure-delete", "status", "ttl"]);
|
|
98
|
+
const FLAGS = new Set(["announce", "community-waits", "db", "help", "home", "host", "namespace", "operator", "passphrase-file", "port", "public-url", "region", "secure-delete", "status", "trusted-proxy", "ttl"]);
|
|
96
99
|
// Flags that only mean something with a value. Given bare, 2.4 fell through to a
|
|
97
100
|
// later crash (--home, --db) or a wrong value (--port meant port 1).
|
|
98
|
-
const VALUE_FLAGS = ["announce", "community-waits", "db", "home", "host", "namespace", "operator", "passphrase-file", "port", "public-url", "region", "ttl"];
|
|
101
|
+
const VALUE_FLAGS = ["announce", "community-waits", "db", "home", "host", "namespace", "operator", "passphrase-file", "port", "public-url", "region", "trusted-proxy", "ttl"];
|
|
99
102
|
// Flags that take no value in either form. `--help=` would otherwise set help to
|
|
100
103
|
// "" (falsy) and start a seed; `--status help` would swallow the word.
|
|
101
104
|
const BOOL_FLAGS = new Set(["help", "status"]);
|
|
@@ -103,15 +106,12 @@ const BOOL_FLAGS = new Set(["help", "status"]);
|
|
|
103
106
|
// refused like a bare flag: in 2.4 an empty SEED_HOST listened on every
|
|
104
107
|
// interface, an empty SEED_PORT took a random port, and an empty SEED_DB kept
|
|
105
108
|
// mail only in memory.
|
|
106
|
-
const SEED_ENV = ["SEED_COMMUNITY_WAITS", "SEED_DB", "SEED_HOME", "SEED_HOST", "SEED_KEYCHAIN_PASSPHRASE", "SEED_NAMESPACE", "SEED_OPERATOR", "SEED_PORT", "SEED_PUBLIC_URL", "SEED_REGION", "SEED_SECURE_DELETE", "SEED_TTL_DAYS"];
|
|
109
|
+
const SEED_ENV = ["SEED_COMMUNITY_WAITS", "SEED_DB", "SEED_HOME", "SEED_HOST", "SEED_KEYCHAIN_PASSPHRASE", "SEED_NAMESPACE", "SEED_OPERATOR", "SEED_PORT", "SEED_PUBLIC_URL", "SEED_REGION", "SEED_SECURE_DELETE", "SEED_TRUSTED_PROXIES", "SEED_TTL_DAYS"];
|
|
107
110
|
|
|
108
111
|
const VALUE_SET = new Set(VALUE_FLAGS);
|
|
109
|
-
// The longest envelope lifetime accepted
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
// from about 2,912,144 days the hourly vacuum deleted mail the moment it was
|
|
113
|
-
// accepted (and above about 99,979,245 days every POST failed). 100 years.
|
|
114
|
-
const MAX_TTL_DAYS = 36500;
|
|
112
|
+
// The longest envelope lifetime accepted, MAX_TTL_DAYS (36500, 100 years), comes
|
|
113
|
+
// from carrier-server.mjs, which enforces it too (2.5.3): past year 9999 a stored
|
|
114
|
+
// deadline sorted before today and the hourly vacuum deleted fresh mail.
|
|
115
115
|
|
|
116
116
|
function parseArgs(argv) {
|
|
117
117
|
const args = {};
|
|
@@ -158,8 +158,10 @@ function refuse(message) {
|
|
|
158
158
|
process.exit(2);
|
|
159
159
|
}
|
|
160
160
|
const ESCAPES = { "\n": "\\n", "\r": "\\r", "\t": "\\t" };
|
|
161
|
+
// U+2028 and U+2029 too: JSON.stringify leaves them as they are, and some
|
|
162
|
+
// terminals and log viewers break the line on them (2.5.3).
|
|
161
163
|
function oneLine(text) {
|
|
162
|
-
return String(text).replace(/[\u0000-\u001f\u007f-\u009f]/g, (c) => ESCAPES[c] ?? `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
164
|
+
return String(text).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, (c) => ESCAPES[c] ?? `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
163
165
|
}
|
|
164
166
|
/** An operator's token as a message shows it: as typed when it is plain, else JSON-quoted. */
|
|
165
167
|
const shown = (token) => (/^[\x21-\x7e]+$/.test(token) ? token : JSON.stringify(token));
|
|
@@ -222,6 +224,13 @@ try {
|
|
|
222
224
|
} catch (e) {
|
|
223
225
|
refuse(e.message);
|
|
224
226
|
}
|
|
227
|
+
// Whose X-Forwarded-For counts for the per-IP budgets (2.5.3): this machine by default.
|
|
228
|
+
let trustedProxies;
|
|
229
|
+
try {
|
|
230
|
+
trustedProxies = parseTrustedProxies(args["trusted-proxy"] ?? process.env.SEED_TRUSTED_PROXIES);
|
|
231
|
+
} catch (e) {
|
|
232
|
+
refuse(e.message);
|
|
233
|
+
}
|
|
225
234
|
|
|
226
235
|
// The seed key's passphrase: a file (preferred: a systemd credential) or an
|
|
227
236
|
// environment variable, never a flag value, so it is never in argv or ps. It is
|
|
@@ -307,12 +316,15 @@ if (args.status) {
|
|
|
307
316
|
await printStanding(registryUrl, savedUuaid);
|
|
308
317
|
process.exit(0);
|
|
309
318
|
}
|
|
310
|
-
//
|
|
311
|
-
//
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
|
|
315
|
-
|
|
319
|
+
// Bind the host and port once, before the key or database exists, and keep the
|
|
320
|
+
// listener: the server takes it over below, so the port cannot be lost in between
|
|
321
|
+
// (2.5.3; up to 2.5.2 this listened, closed, and listened again after minting, and
|
|
322
|
+
// a port taken in that gap failed the start with the key already minted). A host
|
|
323
|
+
// that does not resolve, an address not on this machine, or a port in use is
|
|
324
|
+
// refused with nothing written. A connection that arrives before the seed serves
|
|
325
|
+
// is reset, as a closed port would refuse it.
|
|
326
|
+
const listener = await new Promise((done) => {
|
|
327
|
+
const probe = createServer((socket) => socket.destroy());
|
|
316
328
|
probe.once("error", (e) => {
|
|
317
329
|
const why = {
|
|
318
330
|
EADDRINUSE: `port ${port} is already in use on ${host}`,
|
|
@@ -323,7 +335,7 @@ await new Promise((done) => {
|
|
|
323
335
|
}[e.code] ?? `cannot listen on ${host}:${port} (${e.code ?? e.message})`;
|
|
324
336
|
refuse(`--host/--port: ${why}. Nothing was written.`);
|
|
325
337
|
});
|
|
326
|
-
probe.listen(port, host, () => probe
|
|
338
|
+
probe.listen(port, host, () => done(probe));
|
|
327
339
|
});
|
|
328
340
|
const homeExisted = existsSync(home);
|
|
329
341
|
mkdirSync(home, { recursive: true, mode: 0o700 });
|
|
@@ -384,8 +396,8 @@ if (dbPath === undefined) {
|
|
|
384
396
|
}
|
|
385
397
|
}
|
|
386
398
|
|
|
387
|
-
const server = new CarrierServer({ dbPath, ttlDays, keychain, publicUrl, secureDelete, communityInboxWaits });
|
|
388
|
-
const addr = await server.listen(
|
|
399
|
+
const server = new CarrierServer({ dbPath, ttlDays, keychain, publicUrl, secureDelete, communityInboxWaits, trustedProxies });
|
|
400
|
+
const addr = await server.listen(listener);
|
|
389
401
|
console.log(`pillar-seed listening on http://${addr.address}:${addr.port}`);
|
|
390
402
|
console.log(` uuaid: ${keychain._identity.uuaid}`);
|
|
391
403
|
console.log(` db: ${dbPath}`);
|
|
@@ -423,6 +435,10 @@ if (registryUrl) {
|
|
|
423
435
|
console.log(` enrollment refused: ${body.reason ?? res.status}`);
|
|
424
436
|
if (String(body.reason ?? "").startsWith("seed-unreachable")) {
|
|
425
437
|
console.log(` (the registry could not fetch ${publicUrl}/v1/seed-info — check DNS, TLS, and your proxy)`);
|
|
438
|
+
} else if (body.reason === undefined && (res.status === 404 || res.status === 405)) {
|
|
439
|
+
// A carrier with no registry mounted (pillar.uuaid.org today) answers 404 here (2.5.3).
|
|
440
|
+
console.log(` (no seed registry answers at ${registryUrl}: POST /v1/seeds is ${res.status}. This seed keeps`);
|
|
441
|
+
console.log(` running standalone, used by every client that lists ${publicUrl} as a carrier.)`);
|
|
426
442
|
}
|
|
427
443
|
}
|
|
428
444
|
} catch (e) {
|