@uuaid/pillar 2.6.0 → 2.7.0
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 +12 -0
- package/README.md +201 -5
- package/bin/carrier.mjs +72 -2
- package/bin/pillar-ask.mjs +4 -1
- package/bin/pillar-blob.mjs +6 -0
- package/bin/pillar-directory.mjs +280 -16
- package/bin/pillar-escrow.mjs +4 -1
- package/bin/pillar-group-v2.mjs +6 -0
- package/bin/pillar-notify.mjs +13 -0
- package/bin/pillar-responder.mjs +266 -23
- package/bin/pillar.mjs +504 -255
- package/package.json +17 -25
- package/src/cli-help.mjs +23 -0
- package/src/group-v2-cli.mjs +1 -1
- package/src/identity/trust.mjs +72 -6
- package/src/mailbox/mailbox.mjs +308 -12
- package/src/net/carrier-server.mjs +34 -2
- package/src/net/refusals.mjs +2 -0
- package/src/net/seed-registry.mjs +2 -1
- package/src/net/transport.mjs +308 -92
- package/src/node-check.mjs +29 -8
- package/src/notify-events.mjs +148 -0
- package/src/notify-log.mjs +124 -0
- package/src/notify-runner.mjs +372 -0
- package/src/notify-store.mjs +725 -0
- package/src/notify.mjs +350 -0
- package/src/pillar.mjs +382 -27
- package/src/readers.mjs +2 -2
- package/src/registry/federation.mjs +3056 -0
- package/src/registry/gossip.mjs +294 -0
- package/src/registry/heartbeats.mjs +195 -0
- package/src/registry/lineage-verifier.mjs +972 -0
- package/src/registry/lineage.mjs +984 -0
- package/src/registry/listings.mjs +549 -0
- package/src/registry/resolve.mjs +376 -0
- package/src/registry/stats.mjs +508 -0
- package/src/sqlite-loader.mjs +40 -0
- package/src/vendor/pillar-core.mjs +22 -0
- package/src/vendor/uuaid-soul.mjs +2246 -0
- package/src/vnext/a6b-common.mjs +270 -0
- package/src/vnext/b1-cli.mjs +970 -0
- package/src/vnext/card-cli.mjs +370 -0
- package/src/vnext/greeter-operator.mjs +160 -0
- package/src/vnext/greeter-suggest.mjs +318 -0
- package/src/vnext/greeter.mjs +571 -0
- package/src/vnext/homes.mjs +48 -0
- package/src/vnext/init-cli.mjs +489 -0
- package/src/vnext/intro-cli.mjs +81 -0
- package/src/vnext/json-dir-mailbox.mjs +296 -0
- package/src/vnext/jsonl-mailbox.mjs +1066 -0
- package/src/vnext/knock-answer.mjs +162 -0
- package/src/vnext/knock-cli.mjs +520 -0
- package/src/vnext/knock-lane.mjs +312 -0
- package/src/vnext/knock-responder.mjs +344 -0
- package/src/vnext/lineage-cli.mjs +653 -0
- package/src/vnext/listing-cli.mjs +323 -0
- package/src/vnext/resolve-cli.mjs +86 -0
- package/src/vnext/soul-cli.mjs +666 -0
- package/src/vnext/verify-cli.mjs +251 -0
- package/src/vnext/w4-redirect.mjs +178 -0
- package/src/vnext/wave-a.mjs +193 -0
- package/src/vnext/witness-cli.mjs +547 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* notify-events.mjs — notification eligibility events (brief S2-E; RedTeam
|
|
3
|
+
* notify C+N1, Q5).
|
|
4
|
+
*
|
|
5
|
+
* Pillar._receive calls NotifySink.emit only after authentication,
|
|
6
|
+
* decryption, the final trust verdict and group admission, and only for a
|
|
7
|
+
* first store. The sink then writes one durable event to notify/state.json
|
|
8
|
+
* under the writer lock. Nothing else produces events: a reader that tails
|
|
9
|
+
* visible rows, a carrier peek, or a manual quarantine release never does.
|
|
10
|
+
*
|
|
11
|
+
* No event for: knocks, duplicates, collisions, failed decrypts (none reach
|
|
12
|
+
* here), quarantined or erased rows, blocked senders (even on the
|
|
13
|
+
* receipt pass-through), group control messages, v1 rows whose sender is not
|
|
14
|
+
* a member, v2 rows not accepted (warning, held, rejected), kinds outside
|
|
15
|
+
* notify.kinds, and acks unless notify.acks is "outbox" and this ack is the
|
|
16
|
+
* first committed transition of our own outbox row to its sender.
|
|
17
|
+
*
|
|
18
|
+
* Claim key = home + sender + envelope id (eventId). An id already emitted
|
|
19
|
+
* is never emitted again, whichever process (named or unnamed reader, or a
|
|
20
|
+
* held-group release) stored it.
|
|
21
|
+
*/
|
|
22
|
+
import { createHash } from "node:crypto";
|
|
23
|
+
import { NotifyStore, WRITER_WAIT_MS } from "./notify-store.mjs";
|
|
24
|
+
import { isSafeId, isSafeUuaid } from "./notify.mjs";
|
|
25
|
+
import { isErasedRow } from "./mailbox/mailbox.mjs";
|
|
26
|
+
|
|
27
|
+
// Bounds keep state.json (rewritten, with fsync, on every event) small:
|
|
28
|
+
// at both caps it is about 95 KiB.
|
|
29
|
+
export const MAX_EVENTS = 256;
|
|
30
|
+
export const RECENT_CAP = 1024;
|
|
31
|
+
|
|
32
|
+
/** Stable event id: the claim key (home uuaid, sender, envelope id). */
|
|
33
|
+
export function eventId(homeUuaid, sender, envelopeId) {
|
|
34
|
+
return createHash("sha256").update(`${homeUuaid}\n${sender}\n${envelopeId}`).digest("hex").slice(0, 32);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function bump(st, key, n = 1) {
|
|
38
|
+
st.counters[key] = (st.counters[key] ?? 0) + n;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Why a delivered envelope earns no event, or null when it does.
|
|
43
|
+
* filed the inbox row is filed under groupId (group admission passed)
|
|
44
|
+
* ackFirst this ack made our outbox row's first acked transition
|
|
45
|
+
*/
|
|
46
|
+
export function ineligible({ kind, sender, cfg, blocked = false, groupId = null, op = null, filed = false, ackFirst = false }) {
|
|
47
|
+
if (!cfg?.enabled) return "disabled";
|
|
48
|
+
if (blocked) return "blocked"; // @rule notify.event-blocked
|
|
49
|
+
if (kind === "ack") return cfg.acks === "outbox" && ackFirst === true ? null : "ack"; // @rule notify.event-ack-first-only
|
|
50
|
+
if (!cfg.kinds.includes(kind)) return "kind"; // @rule notify.event-kind
|
|
51
|
+
if (groupId !== null && op !== "message") return "control"; // @rule notify.event-control-only
|
|
52
|
+
if (groupId !== null && !filed) return "group-not-admitted"; // @rule notify.event-group-admitted
|
|
53
|
+
if (cfg.watchedUuaids.length && !cfg.watchedUuaids.includes(sender)) return "unwatched";
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The sink a Pillar writes eligibility events into. One per home and
|
|
59
|
+
* process; `cfg` is notifyConfigFrom(config.json).
|
|
60
|
+
*/
|
|
61
|
+
export class NotifySink {
|
|
62
|
+
constructor({ home, cfg, store = null, waitMs = WRITER_WAIT_MS, retryDelayMs = 250 }) {
|
|
63
|
+
this.cfg = cfg;
|
|
64
|
+
this.store = store ?? new NotifyStore(home);
|
|
65
|
+
this.onEvent = null; // in-process wake (the resident notifier pokes itself)
|
|
66
|
+
this.waitMs = waitMs;
|
|
67
|
+
this.retryDelayMs = retryDelayMs;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async _retry(write) {
|
|
71
|
+
await new Promise((res) => setTimeout(res, this.retryDelayMs + Math.floor(Math.random() * this.retryDelayMs)));
|
|
72
|
+
return write();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get wantsAcks() { return !!this.cfg.enabled && this.cfg.acks === "outbox"; }
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Record one event for a delivered envelope. `facts`: { groupId, op,
|
|
79
|
+
* ackFirst, via }. Returns { event } | { duplicate } | { skipped: reason }.
|
|
80
|
+
*/
|
|
81
|
+
async emit(pillar, envelope, payload, { groupId = null, op = null, ackFirst = false, via = "receive" } = {}) {
|
|
82
|
+
// Before a wake path's first start, an event could never be noticed (that
|
|
83
|
+
// start baselines at the tip), so none is written: a home with notify on
|
|
84
|
+
// but no wake path installed pays one small unlocked read per receive.
|
|
85
|
+
let snap = null;
|
|
86
|
+
snap = this.store.peek();
|
|
87
|
+
if (!snap || snap.cursor === null) return { skipped: "inactive" }; // @rule notify.event-skip-inactive
|
|
88
|
+
const sender = envelope.sender;
|
|
89
|
+
const row = pillar.mailbox.getInbound(envelope.id, sender);
|
|
90
|
+
if (!row || isErasedRow(row) || row.quarantined) return { skipped: "not-delivered" }; // @rule notify.event-not-delivered
|
|
91
|
+
const why = ineligible({
|
|
92
|
+
kind: envelope.kind, sender, cfg: this.cfg,
|
|
93
|
+
blocked: !!pillar.trust?.block?.includes(sender),
|
|
94
|
+
groupId, op, filed: groupId !== null && row.group_id === groupId, ackFirst,
|
|
95
|
+
});
|
|
96
|
+
if (why) return { skipped: why };
|
|
97
|
+
// inReplyTo only for a verified own-outbox match (an ack's first transition is one).
|
|
98
|
+
let inReplyTo = null;
|
|
99
|
+
if (envelope.kind === "ack") inReplyTo = payload?.inReplyTo;
|
|
100
|
+
else if (typeof payload?.inReplyTo === "string" && payload.inReplyTo.length <= 256) {
|
|
101
|
+
const out = pillar.mailbox.getOutbound(payload.inReplyTo);
|
|
102
|
+
if (out && !isErasedRow(out) && out.recipient === sender) inReplyTo = payload.inReplyTo;
|
|
103
|
+
}
|
|
104
|
+
// V1 F1a: only protocol-safe id and sender strings are stored. A sender
|
|
105
|
+
// controls both (open() does not check the id; only the uuaid's local id
|
|
106
|
+
// is bound to the key), and control characters cost 6 bytes in JSON.
|
|
107
|
+
let id = envelope.id;
|
|
108
|
+
if (!isSafeId(id)) id = null; // @rule notify.event-safe-id
|
|
109
|
+
let from = sender;
|
|
110
|
+
if (!isSafeUuaid(from)) from = null; // @rule notify.event-safe-from
|
|
111
|
+
const ev = {
|
|
112
|
+
eid: eventId(pillar.uuaid, sender, envelope.id),
|
|
113
|
+
id,
|
|
114
|
+
from,
|
|
115
|
+
kind: envelope.kind,
|
|
116
|
+
at: new Date().toISOString(), // local receipt time
|
|
117
|
+
known: !!pillar.addressBook?.get(sender) || !!pillar.trust?.allow?.includes(sender),
|
|
118
|
+
via,
|
|
119
|
+
...(isSafeId(inReplyTo) ? { inReplyTo, inReplyToVerified: true } : {}),
|
|
120
|
+
};
|
|
121
|
+
const write = () => this.store.mutate((st) => {
|
|
122
|
+
if (st.cursor === null) return { skipped: "inactive" }; // re-checked under the lock
|
|
123
|
+
if (st.recent.includes(ev.eid)) { bump(st, "emit.duplicate"); return { duplicate: true }; } // @rule notify.event-claim-key
|
|
124
|
+
ev.seq = st.nextSeq++;
|
|
125
|
+
if (ev.id === null) bump(st, "event.unsafe-id");
|
|
126
|
+
if (ev.from === null) bump(st, "event.unsafe-from");
|
|
127
|
+
st.events.push(ev);
|
|
128
|
+
st.recent.push(ev.eid);
|
|
129
|
+
st.recent = st.recent.slice(-RECENT_CAP);
|
|
130
|
+
const over = Math.max(0, st.events.length - MAX_EVENTS);
|
|
131
|
+
st.events.splice(0, over); // @rule notify.event-queue-bounded
|
|
132
|
+
st.overflow += over;
|
|
133
|
+
bump(st, "emitted");
|
|
134
|
+
return { event: ev };
|
|
135
|
+
}, { waitMs: this.waitMs });
|
|
136
|
+
// V1 F6: a writer lock held past waitMs gets one more try after a short,
|
|
137
|
+
// randomized backoff. If that fails too, the caller counts
|
|
138
|
+
// notify.emit-failed and this envelope gets no notice (mail is kept).
|
|
139
|
+
let r = null;
|
|
140
|
+
let busy = null;
|
|
141
|
+
try { r = await write(); }
|
|
142
|
+
catch (e) { if (e.code !== "notify-busy") throw e; busy = e; }
|
|
143
|
+
if (busy) r = await this._retry(write); // @rule notify.event-retry-once
|
|
144
|
+
if (!r) throw busy;
|
|
145
|
+
if (r.event) { try { this.onEvent?.(r.event); } catch (_e) { /* a wake hint only */ } }
|
|
146
|
+
return r;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* notify-log.mjs — bounded stderr for `pillar recv --notify` (V1 F3).
|
|
3
|
+
*
|
|
4
|
+
* Receive-path warnings (quarantine, collision, failed decrypt) quote the
|
|
5
|
+
* sender-chosen envelope id, which can be any length and hold control
|
|
6
|
+
* characters. In --notify mode every stderr line goes through:
|
|
7
|
+
* safeLogLine control characters escaped, each word cut to 64 characters,
|
|
8
|
+
* the line cut to 400, one line per call
|
|
9
|
+
* RateLimiter at most 30 lines a minute; the rest are counted and one
|
|
10
|
+
* "N warnings suppressed" line is written when the window ends
|
|
11
|
+
* PrivateLog a copy in <home>/notify/recv.log, 0600, appended with
|
|
12
|
+
* O_NOFOLLOW under notify/ custody, rotated at 256 KiB into
|
|
13
|
+
* recv.1.log (the printed units send stderr to /dev/null)
|
|
14
|
+
*/
|
|
15
|
+
import { closeSync, constants as C, fchmodSync, fstatSync, lstatSync, openSync, renameSync, unlinkSync, writeSync } from "node:fs";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import { assertSafeFile, currentUid, ensurePrivateDir } from "./notify-store.mjs";
|
|
18
|
+
|
|
19
|
+
export const LOG_TOKEN_MAX = 64;
|
|
20
|
+
export const LOG_LINE_MAX = 400;
|
|
21
|
+
export const RECV_LOG = "recv.log";
|
|
22
|
+
export const RECV_LOG_ROTATED = "recv.1.log";
|
|
23
|
+
export const RECV_LOG_MAX_BYTES = 256 * 1024;
|
|
24
|
+
export const WARN_LINES_PER_WINDOW = 30;
|
|
25
|
+
export const WARN_WINDOW_MS = 60_000;
|
|
26
|
+
|
|
27
|
+
const UNSAFE_CHARS = new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]", "g"); // C0, DEL, C1, line/paragraph separators
|
|
28
|
+
|
|
29
|
+
/** Escape control characters (and line separators) as \uXXXX. */
|
|
30
|
+
export function escapeControls(s) {
|
|
31
|
+
let out = String(s);
|
|
32
|
+
out = out.replace(UNSAFE_CHARS, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`); // @rule notify.log-escape-controls
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** One bounded, printable line: escaped, words <= maxToken, line <= maxLine. */
|
|
37
|
+
export function safeLogLine(text, { maxToken = LOG_TOKEN_MAX, maxLine = LOG_LINE_MAX } = {}) {
|
|
38
|
+
const words = escapeControls(text).split(/( +)/).map((w) => {
|
|
39
|
+
if (w.length <= maxToken || /^ +$/.test(w)) return w;
|
|
40
|
+
let cut = w;
|
|
41
|
+
cut = `${w.slice(0, maxToken)}…(+${w.length - maxToken})`; // @rule notify.log-token-cap
|
|
42
|
+
return cut;
|
|
43
|
+
});
|
|
44
|
+
let line = words.join("");
|
|
45
|
+
if (line.length > maxLine) line = `${line.slice(0, maxLine)}…(+${line.length - maxLine})`; // @rule notify.log-line-cap
|
|
46
|
+
return line;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** At most `lines` per `windowMs`; reports how many were suppressed in the last window. */
|
|
50
|
+
export class RateLimiter {
|
|
51
|
+
constructor({ lines = WARN_LINES_PER_WINDOW, windowMs = WARN_WINDOW_MS, now = () => Date.now() } = {}) {
|
|
52
|
+
Object.assign(this, { lines, windowMs, now });
|
|
53
|
+
this.start = now();
|
|
54
|
+
this.count = 0;
|
|
55
|
+
this.suppressed = 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
allow() {
|
|
59
|
+
const t = this.now();
|
|
60
|
+
let report = 0;
|
|
61
|
+
if (t - this.start >= this.windowMs) {
|
|
62
|
+
report = this.suppressed;
|
|
63
|
+
this.start = t;
|
|
64
|
+
this.count = 0;
|
|
65
|
+
this.suppressed = 0;
|
|
66
|
+
}
|
|
67
|
+
if (this.count >= this.lines) { this.suppressed++; return { ok: false, report }; } // @rule notify.log-rate-limit
|
|
68
|
+
this.count++;
|
|
69
|
+
return { ok: true, report };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Append-only private log in notify/, rotated by size. One writer: the
|
|
75
|
+
* resident wake path (one per home, notify/wake.lock).
|
|
76
|
+
*/
|
|
77
|
+
export class PrivateLog {
|
|
78
|
+
constructor(dir, { name = RECV_LOG, rotated = RECV_LOG_ROTATED, maxBytes = RECV_LOG_MAX_BYTES, uid = currentUid() } = {}) {
|
|
79
|
+
Object.assign(this, { dir, name, rotated, maxBytes, uid });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get path() { return join(this.dir, this.name); }
|
|
83
|
+
|
|
84
|
+
append(line) {
|
|
85
|
+
ensurePrivateDir(this.dir, this.uid); // a symlinked or foreign notify/ is refused
|
|
86
|
+
const p = this.path;
|
|
87
|
+
const data = Buffer.from(`${line}\n`, "utf-8");
|
|
88
|
+
let st = null;
|
|
89
|
+
try { st = lstatSync(p); } catch (e) { if (e.code !== "ENOENT") throw e; }
|
|
90
|
+
if (st) {
|
|
91
|
+
assertSafeFile(st, p, this.uid);
|
|
92
|
+
if (st.size + data.length > this.maxBytes) this._rotate(); // @rule notify.recv-log-rotate
|
|
93
|
+
}
|
|
94
|
+
const fd = openSync(p, C.O_WRONLY | C.O_APPEND | C.O_CREAT | C.O_NOFOLLOW, 0o600);
|
|
95
|
+
try {
|
|
96
|
+
const f = fstatSync(fd);
|
|
97
|
+
assertSafeFile(f, p, this.uid);
|
|
98
|
+
if ((f.mode & 0o777) !== 0o600) fchmodSync(fd, 0o600);
|
|
99
|
+
writeSync(fd, data);
|
|
100
|
+
} finally { closeSync(fd); }
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
_rotate() {
|
|
104
|
+
const r = join(this.dir, this.rotated);
|
|
105
|
+
try { assertSafeFile(lstatSync(r), r, this.uid); unlinkSync(r); } catch (e) { if (e.code !== "ENOENT") throw e; }
|
|
106
|
+
renameSync(this.path, r);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A console replacement for --notify mode: every line bounded, rate-limited,
|
|
112
|
+
* written to `stderr` and (best effort) to the private log.
|
|
113
|
+
*/
|
|
114
|
+
export function boundedWriter({ log = null, stderr = (s) => process.stderr.write(s), limiter = new RateLimiter(), clock = () => new Date().toISOString() } = {}) {
|
|
115
|
+
const emit = (line) => {
|
|
116
|
+
stderr(`${line}\n`);
|
|
117
|
+
if (log) { try { log.append(`${clock()} ${line}`); } catch (_e) { /* notify/ unusable: stderr only */ } }
|
|
118
|
+
};
|
|
119
|
+
return (text) => {
|
|
120
|
+
const a = limiter.allow();
|
|
121
|
+
if (a.report) emit(`notify: ${a.report} warnings suppressed (rate limit)`);
|
|
122
|
+
if (a.ok) emit(safeLogLine(text));
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* notify-runner.mjs — the wake path (brief S2-H, S2-I, S2-R, S2-B, S2-1).
|
|
3
|
+
*
|
|
4
|
+
* A Notifier claims committed eligibility events from notify/state.json and
|
|
5
|
+
* wakes the agent through the configured hook. It runs as the resident
|
|
6
|
+
* notifier (`pillar recv --notify`) or as the one-shot fallback
|
|
7
|
+
* (`pillar notify`); notify/wake.lock admits one of them per home.
|
|
8
|
+
*
|
|
9
|
+
* One wake, in order:
|
|
10
|
+
* 1. Under the writer lock: activate (first run baselines at the tip),
|
|
11
|
+
* re-check each pending event against the mailbox (erased, quarantined
|
|
12
|
+
* or missing rows drop out), ask the budget, and if it allows a start,
|
|
13
|
+
* claim every pending event (coalesced), move the cursor, charge the
|
|
14
|
+
* budget and record the run as "started": one commit. The log line is
|
|
15
|
+
* written after that commit, under the same lock.
|
|
16
|
+
* 2. Outside the lock: run the hook (shell: false, fresh env, cwd = home,
|
|
17
|
+
* closed JSON on stdin), with a deadline, then kill its process group
|
|
18
|
+
* and reap it. One hook at a time per home.
|
|
19
|
+
* 3. Under the lock: record the run's outcome.
|
|
20
|
+
*
|
|
21
|
+
* Retry contract: a notice is attempted at most once per event. The claim is
|
|
22
|
+
* committed before the hook starts, so a crash after step 1 leaves a run
|
|
23
|
+
* "started"; the next start marks it "ambiguous" and never re-runs it. A
|
|
24
|
+
* failed or timed-out hook is not re-run either. The mail itself stays in
|
|
25
|
+
* the mailbox; a consumer that needs every message reads the mailbox, not
|
|
26
|
+
* the notice. Events not yet claimed survive a restart and are noticed once.
|
|
27
|
+
*/
|
|
28
|
+
import { spawn } from "node:child_process";
|
|
29
|
+
import { accessSync, constants as C, lstatSync, realpathSync, statSync } from "node:fs";
|
|
30
|
+
import { hostname } from "node:os";
|
|
31
|
+
import { dirname, isAbsolute } from "node:path";
|
|
32
|
+
import { randomBytes } from "node:crypto";
|
|
33
|
+
import { buildBatch, planWake, recordStart } from "./notify.mjs";
|
|
34
|
+
import { STATE_FILE } from "./notify-store.mjs";
|
|
35
|
+
import { bump } from "./notify-events.mjs";
|
|
36
|
+
import { isErasedRow } from "./mailbox/mailbox.mjs";
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line no-control-regex
|
|
39
|
+
const CONTROL_RE = /[\u0000-\u001f\u007f]/;
|
|
40
|
+
export const HOOK_MAX_ARGS = 64;
|
|
41
|
+
export const HOOK_MAX_ARG_BYTES = 4096;
|
|
42
|
+
export const KILL_GRACE_MS = 1000;
|
|
43
|
+
|
|
44
|
+
export class NotifyHookError extends Error {
|
|
45
|
+
constructor(message) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.name = "NotifyHookError";
|
|
48
|
+
this.code = "notify-hook";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Validate config.json notify.hook = { exec: "<absolute path>", args: [fixed strings] }.
|
|
54
|
+
* Returns { exec: <resolved path>, args } or null when no hook is set.
|
|
55
|
+
* Refuses a path that is not absolute, not a regular executable file, or
|
|
56
|
+
* writable by group or others.
|
|
57
|
+
*/
|
|
58
|
+
export function checkHook(hook, { uid = typeof process.getuid === "function" ? process.getuid() : null } = {}) {
|
|
59
|
+
if (hook === null || hook === undefined) return null;
|
|
60
|
+
if (typeof hook !== "object" || Array.isArray(hook)) throw new NotifyHookError("notify.hook must be an object: { \"exec\": \"/absolute/path\", \"args\": [\"fixed\", \"strings\"] }");
|
|
61
|
+
const extra = Object.keys(hook).filter((k) => k !== "exec" && k !== "args");
|
|
62
|
+
if (extra.length) throw new NotifyHookError(`notify.hook takes only exec and args (not ${extra.join(", ")})`);
|
|
63
|
+
const { exec } = hook;
|
|
64
|
+
const args = hook.args ?? [];
|
|
65
|
+
if (typeof exec !== "string" || CONTROL_RE.test(exec)) throw new NotifyHookError("notify.hook.exec must be a path string");
|
|
66
|
+
if (!isAbsolute(exec)) throw new NotifyHookError(`notify.hook.exec must be an absolute path, not ${JSON.stringify(exec)}`); // @rule notify.hook-absolute
|
|
67
|
+
if (!Array.isArray(args) || args.length > HOOK_MAX_ARGS
|
|
68
|
+
|| args.some((a) => typeof a !== "string" || a.includes("\u0000") || Buffer.byteLength(a) > HOOK_MAX_ARG_BYTES)) {
|
|
69
|
+
throw new NotifyHookError(`notify.hook.args must be up to ${HOOK_MAX_ARGS} fixed strings of at most ${HOOK_MAX_ARG_BYTES} bytes`);
|
|
70
|
+
}
|
|
71
|
+
let real;
|
|
72
|
+
try { real = realpathSync(exec); } catch (e) { throw new NotifyHookError(`notify.hook.exec ${exec}: ${e.code ?? e.message}`); }
|
|
73
|
+
const st = statSync(real);
|
|
74
|
+
if (!st.isFile()) throw new NotifyHookError(`notify.hook.exec ${exec} is not a regular file`); // @rule notify.hook-regular
|
|
75
|
+
if (st.mode & 0o022) throw new NotifyHookError(`notify.hook.exec ${exec} is writable by group or others (mode ${(st.mode & 0o777).toString(8)})`); // @rule notify.hook-not-writable
|
|
76
|
+
// V1 F5: owned by this user or root, in a directory no one else can write.
|
|
77
|
+
const owner = st.uid;
|
|
78
|
+
if (uid !== null && owner !== uid && owner !== 0) throw new NotifyHookError(`notify.hook.exec ${exec} is owned by uid ${owner}, not ${uid} or root`); // @rule notify.hook-owner
|
|
79
|
+
const parent = statSync(dirname(real));
|
|
80
|
+
if (parent.mode & 0o022) throw new NotifyHookError(`notify.hook.exec ${exec}: its directory ${dirname(real)} is writable by group or others (mode ${(parent.mode & 0o777).toString(8)})`); // @rule notify.hook-parent-dir
|
|
81
|
+
try { accessSync(real, C.X_OK); } catch (_e) { throw new NotifyHookError(`notify.hook.exec ${exec} is not executable`); } // @rule notify.hook-executable
|
|
82
|
+
return { exec: real, args: [...args] };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Run the hook once. stdin = `json`; env = { PILLAR_NEW, PILLAR_UUAID } only;
|
|
87
|
+
* cwd = the home; no shell; its own process group. Output is counted and
|
|
88
|
+
* discarded. At the deadline: SIGTERM to the group, SIGKILL after a grace,
|
|
89
|
+
* and the child is reaped. Resolves { status, code, signal, ms, outBytes, errBytes, pid }.
|
|
90
|
+
*/
|
|
91
|
+
export function runHook(hook, json, { cwd, uuaid, newCount, timeoutMs, killGraceMs = KILL_GRACE_MS, onSpawn = null }) {
|
|
92
|
+
return new Promise((resolve) => {
|
|
93
|
+
const t0 = Date.now();
|
|
94
|
+
let env = { ...process.env };
|
|
95
|
+
env = { PILLAR_NEW: String(newCount), PILLAR_UUAID: String(uuaid ?? "") }; // @rule notify.hook-fresh-env
|
|
96
|
+
let child;
|
|
97
|
+
try {
|
|
98
|
+
child = spawn(hook.exec, hook.args, { cwd, env, shell: false, detached: true, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
|
|
99
|
+
} catch (e) {
|
|
100
|
+
resolve({ status: "spawn-error", error: e.code ?? e.message, ms: 0, outBytes: 0, errBytes: 0, pid: null });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
onSpawn?.(child);
|
|
104
|
+
let outBytes = 0;
|
|
105
|
+
let errBytes = 0;
|
|
106
|
+
let timedOut = false;
|
|
107
|
+
let done = false;
|
|
108
|
+
let grace = null;
|
|
109
|
+
child.stdout.on("data", (b) => { outBytes += b.length; });
|
|
110
|
+
child.stderr.on("data", (b) => { errBytes += b.length; });
|
|
111
|
+
child.stdin.on("error", () => {});
|
|
112
|
+
child.stdin.end(json);
|
|
113
|
+
const killGroup = (sig) => { try { process.kill(-child.pid, sig); } catch (_e) { /* gone */ } };
|
|
114
|
+
const onDeadline = () => {
|
|
115
|
+
timedOut = true;
|
|
116
|
+
killGroup("SIGTERM");
|
|
117
|
+
grace = setTimeout(() => killGroup("SIGKILL"), killGraceMs);
|
|
118
|
+
};
|
|
119
|
+
let timer = null;
|
|
120
|
+
timer = setTimeout(onDeadline, timeoutMs); // @rule notify.hook-deadline
|
|
121
|
+
const finish = (r) => {
|
|
122
|
+
if (done) return;
|
|
123
|
+
done = true;
|
|
124
|
+
clearTimeout(timer);
|
|
125
|
+
clearTimeout(grace);
|
|
126
|
+
child.stdout.destroy();
|
|
127
|
+
child.stderr.destroy();
|
|
128
|
+
resolve({ ms: Date.now() - t0, outBytes, errBytes, pid: child.pid ?? null, ...r });
|
|
129
|
+
};
|
|
130
|
+
child.on("error", (e) => finish({ status: "spawn-error", error: e.code ?? e.message }));
|
|
131
|
+
child.on("exit", (code, signal) => {
|
|
132
|
+
// V1 F4: on ANY exit of the leader, whatever it left in its process
|
|
133
|
+
// group dies with it (a hook cannot leave background work running).
|
|
134
|
+
// A descendant that called setsid() has left the group: not reachable.
|
|
135
|
+
killGroup("SIGKILL"); // @rule notify.hook-reap-on-exit
|
|
136
|
+
finish({ status: timedOut ? "timeout" : code === 0 ? "ok" : "failed", code, signal });
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const iso = (ms) => new Date(ms).toISOString();
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The wake path for one home. mode: "resident" | "fallback".
|
|
145
|
+
*/
|
|
146
|
+
export class Notifier {
|
|
147
|
+
constructor({ home, store, cfg, uuaid, mailbox, mode, log = (s) => process.stderr.write(`${s}\n`), now = () => Date.now(), holdCheck = null }) {
|
|
148
|
+
Object.assign(this, { home, store, cfg, uuaid, mailbox, mode, log, now });
|
|
149
|
+
// Lead L2/L3: true while this process still holds notify/wake.lock (it
|
|
150
|
+
// re-reads the lock). null = the caller holds it for the whole run (fallback).
|
|
151
|
+
this.holdCheck = holdCheck;
|
|
152
|
+
this.running = false;
|
|
153
|
+
this.again = false;
|
|
154
|
+
this.stopped = false;
|
|
155
|
+
this.child = null;
|
|
156
|
+
this.timer = null;
|
|
157
|
+
this.poll = null;
|
|
158
|
+
this.pokeQueued = false;
|
|
159
|
+
this._mtime = null;
|
|
160
|
+
this.startedAt = iso(this.now());
|
|
161
|
+
this.lastError = null; // { code, at }: an error code only, never message or sender text
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* V1 F1d: a notify error (custody, I/O) never stops the receive loop. One
|
|
166
|
+
* bounded line per distinct error; the same error again stays quiet until
|
|
167
|
+
* a later pass succeeds.
|
|
168
|
+
*/
|
|
169
|
+
_report(e) {
|
|
170
|
+
const code = typeof e?.code === "string" && /^[A-Za-z0-9_.-]{1,40}$/.test(e.code) ? e.code : "error";
|
|
171
|
+
this._fail(code);
|
|
172
|
+
const key = `${code}|${e?.message ?? e}`;
|
|
173
|
+
if (this._reported === key) return;
|
|
174
|
+
this._reported = key;
|
|
175
|
+
this.log(`notify: ${code}: ${String(e?.message ?? e).slice(0, 300)}`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
_fail(code) {
|
|
179
|
+
const c = typeof code === "string" && /^[A-Za-z0-9_.-]{1,40}$/.test(code) ? code : "error";
|
|
180
|
+
this.lastError = { code: c, at: iso(this.now()) };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* notify/status.json (Lead D5): bounded, metadata-free status for an owner
|
|
185
|
+
* whose unit sends stdout and stderr to /dev/null. Counts, the last run's
|
|
186
|
+
* outcome and the last error code; no ids, senders, paths or text.
|
|
187
|
+
*/
|
|
188
|
+
_statusOf(st) {
|
|
189
|
+
const counters = {};
|
|
190
|
+
for (const [k, v] of Object.entries(st.counters ?? {}).slice(0, 64)) if (Number.isFinite(v)) counters[k] = v;
|
|
191
|
+
const r = st.run;
|
|
192
|
+
return {
|
|
193
|
+
v: "pillar-notify-status/1",
|
|
194
|
+
mode: this.mode, pid: process.pid, startedAt: this.startedAt, updatedAt: iso(this.now()),
|
|
195
|
+
activatedAt: st.activatedAt ?? null, cursor: st.cursor,
|
|
196
|
+
pending: st.cursor === null ? 0 : st.events.filter((e) => e.seq > st.cursor).length,
|
|
197
|
+
overflow: st.overflow ?? 0,
|
|
198
|
+
counters,
|
|
199
|
+
lastRun: r ? { id: r.id, mode: r.mode, status: r.status, trigger: r.trigger, n: r.n, startedAt: r.startedAt, endedAt: r.endedAt ?? null, code: r.code ?? null, signal: r.signal ?? null, ms: r.ms ?? null } : null,
|
|
200
|
+
lastError: this.lastError,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Write status.json now (under the writer lock); a busy lock just skips it. */
|
|
205
|
+
async _writeStatus() {
|
|
206
|
+
try { await this.store.mutate((st, tx) => { tx.writeStatus(this._statusOf(st)); }, { waitMs: 500 }); }
|
|
207
|
+
catch (e) { if (e.code !== "notify-busy") throw e; }
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Why a claimed-to-be event is no longer deliverable, or null. */
|
|
211
|
+
_stale(e) {
|
|
212
|
+
if (!this.mailbox || typeof e.id !== "string" || typeof e.from !== "string") return null;
|
|
213
|
+
const row = this.mailbox.getInbound(e.id, e.from);
|
|
214
|
+
if (!row) return "missing";
|
|
215
|
+
if (isErasedRow(row)) return "erased";
|
|
216
|
+
if (row.quarantined) return "quarantined";
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** An unlocked look at state: a result when there is surely nothing to claim, else null. */
|
|
221
|
+
_quickLook() {
|
|
222
|
+
let st;
|
|
223
|
+
try { st = this.store.peek(); } catch (_e) { return null; }
|
|
224
|
+
if (!st || st.cursor === null || st.run?.status === "started") return null;
|
|
225
|
+
if (st.events.some((e) => e.seq > st.cursor)) return null;
|
|
226
|
+
return { activated: false, pending: 0 };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Step 1: one commit. Returns { activated, pending, batch?, runId?, input?, json?, deferred?, nextAt? }. */
|
|
230
|
+
_claim(st, tx) {
|
|
231
|
+
const now = this.now();
|
|
232
|
+
const out = { activated: false, pending: 0 };
|
|
233
|
+
if (st.cursor === null) { // first activation: what is already there stays old
|
|
234
|
+
st.cursor = st.nextSeq - 1; // @rule notify.activation-baseline
|
|
235
|
+
st.overflow = 0;
|
|
236
|
+
st.activatedAt = iso(now);
|
|
237
|
+
out.activated = true;
|
|
238
|
+
}
|
|
239
|
+
if (st.run?.status === "started") { // a run that never reported back
|
|
240
|
+
st.run.status = "ambiguous"; // @rule notify.run-ambiguous-no-rerun
|
|
241
|
+
bump(st, "runs.ambiguous");
|
|
242
|
+
}
|
|
243
|
+
st.events = st.events.filter((e) => e.seq > st.cursor);
|
|
244
|
+
const pending = [];
|
|
245
|
+
for (const e of st.events) {
|
|
246
|
+
let why = null;
|
|
247
|
+
why = this._stale(e); // @rule notify.claim-revalidate
|
|
248
|
+
if (why) { e.drop = true; bump(st, `dropped.${why}`); } else pending.push(e);
|
|
249
|
+
}
|
|
250
|
+
st.events = st.events.filter((e) => !e.drop);
|
|
251
|
+
out.pending = pending.length;
|
|
252
|
+
if (!pending.length) return out; // dropped-event counts ride on the next real wake
|
|
253
|
+
const plan = planWake(st.budget, pending, now, this.cfg);
|
|
254
|
+
if (!plan.ok) {
|
|
255
|
+
for (const e of pending) if (!e.deferred) { e.deferred = plan.reason; bump(st, `suppressed.${plan.reason}`); }
|
|
256
|
+
return { ...out, deferred: plan.reason, nextAt: plan.nextAt };
|
|
257
|
+
}
|
|
258
|
+
recordStart(st.budget, plan.trigger, plan.cls, now, this.cfg);
|
|
259
|
+
const dropped = st.overflow;
|
|
260
|
+
st.overflow = 0;
|
|
261
|
+
st.cursor = pending.at(-1).seq;
|
|
262
|
+
st.events = st.events.filter((e) => e.seq > st.cursor);
|
|
263
|
+
const { input, json } = buildBatch(this.uuaid, pending, { dropped });
|
|
264
|
+
const runId = randomBytes(6).toString("hex");
|
|
265
|
+
st.run = { id: runId, pid: process.pid, host: hostname(), mode: this.mode, startedAt: iso(now), n: input.new, seqTo: st.cursor, trigger: plan.cls, by: plan.trigger.from, status: this.cfg.hook ? "started" : "logged" };
|
|
266
|
+
bump(st, "starts");
|
|
267
|
+
bump(st, `starts.${plan.cls}`);
|
|
268
|
+
bump(st, "delivered", pending.length);
|
|
269
|
+
bump(st, "coalesced", Math.max(0, pending.length - 1));
|
|
270
|
+
if (dropped) bump(st, "overflow", dropped);
|
|
271
|
+
tx.appendLog([{ at: iso(now), run: runId, mode: this.mode, ...input }]);
|
|
272
|
+
return { ...out, batch: true, runId, input, json, trigger: plan.cls };
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** One pass: claim, run the hook, record the outcome. Never two at once. */
|
|
276
|
+
async tick() {
|
|
277
|
+
if (this.stopped) return { stopped: true };
|
|
278
|
+
if (this.running) { this.again = true; return { busy: true }; } // @rule notify.one-active-hook
|
|
279
|
+
if (this.holdCheck && !this.holdCheck()) { this.stop(); return { lockLost: true }; } // @rule notify.claim-needs-lock
|
|
280
|
+
this.running = true;
|
|
281
|
+
try {
|
|
282
|
+
// A hook that fails its checks claims nothing: the events wait for a good one.
|
|
283
|
+
let hook = null;
|
|
284
|
+
try { hook = checkHook(this.cfg.hook); }
|
|
285
|
+
catch (e) {
|
|
286
|
+
if (this._hookWarned !== e.message) {
|
|
287
|
+
this._hookWarned = e.message;
|
|
288
|
+
this.log(`notify: hook refused, nothing claimed: ${e.message}`);
|
|
289
|
+
this._fail("notify-hook");
|
|
290
|
+
await this._writeStatus();
|
|
291
|
+
}
|
|
292
|
+
return { refusedHook: e.message };
|
|
293
|
+
}
|
|
294
|
+
// Nothing new and no unfinished run: no need to take the writer lock.
|
|
295
|
+
const snap = this._quickLook();
|
|
296
|
+
if (snap) return snap;
|
|
297
|
+
let claim;
|
|
298
|
+
try { claim = await this.store.mutate((st, tx) => { const c = this._claim(st, tx); tx.writeStatus(this._statusOf(st)); return c; }); this._reported = null; }
|
|
299
|
+
catch (e) {
|
|
300
|
+
if (e.code !== "notify-busy") { this._fail(e.code ?? "error"); throw e; }
|
|
301
|
+
this._fail("notify-busy");
|
|
302
|
+
this._schedule(this.now() + 500); // transient: nothing was claimed; look again soon
|
|
303
|
+
return { busy: "writer-lock" };
|
|
304
|
+
}
|
|
305
|
+
if (!claim.batch) { this._schedule(claim.nextAt); return claim; }
|
|
306
|
+
let res = { status: "no-hook" };
|
|
307
|
+
// The lock may have been lost while the claim was written (a paused
|
|
308
|
+
// process resuming): no hook starts after the loss (Lead L2).
|
|
309
|
+
if (hook && this.holdCheck && !this.holdCheck()) { this.stop(); res = { status: "lock-lost" }; hook = null; }
|
|
310
|
+
if (hook) {
|
|
311
|
+
res = await runHook(hook, claim.json, {
|
|
312
|
+
cwd: this.home, uuaid: this.uuaid, newCount: claim.input.new, timeoutMs: this.cfg.timeoutS * 1000,
|
|
313
|
+
onSpawn: (c) => { this.child = c; },
|
|
314
|
+
});
|
|
315
|
+
this.child = null;
|
|
316
|
+
}
|
|
317
|
+
if (res.status === "spawn-error") this._fail(typeof res.error === "string" && /^E[A-Z0-9_]+$/.test(res.error) ? res.error : "spawn-error");
|
|
318
|
+
else if (res.status === "failed" || res.status === "timeout") this._fail(`hook-${res.status}`);
|
|
319
|
+
await this.store.mutate((st, tx) => {
|
|
320
|
+
if (st.run?.id === claim.runId) Object.assign(st.run, { status: res.status, endedAt: iso(this.now()), code: res.code ?? null, signal: res.signal ?? null, ms: res.ms ?? 0 });
|
|
321
|
+
bump(st, `hook.${res.status}`);
|
|
322
|
+
tx.writeStatus(this._statusOf(st));
|
|
323
|
+
});
|
|
324
|
+
this.log(`notify: run ${claim.runId}: ${claim.input.new} new, ${claim.input.records.length} listed; hook ${res.status}`
|
|
325
|
+
+ `${res.code !== undefined && res.code !== null ? ` exit ${res.code}` : ""}${res.signal ? ` ${res.signal}` : ""}`
|
|
326
|
+
+ `${res.ms !== undefined ? ` in ${res.ms} ms` : ""}${res.outBytes || res.errBytes ? ` (output ${res.outBytes} + ${res.errBytes} bytes discarded)` : ""}`
|
|
327
|
+
+ `${res.error ? `: ${String(res.error).slice(0, 200)}` : ""}`);
|
|
328
|
+
return { ...claim, hook: res };
|
|
329
|
+
} finally {
|
|
330
|
+
this.running = false;
|
|
331
|
+
if (this.again && !this.stopped) { this.again = false; this.poke(); }
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** Ask for a pass soon (coalesces). Called by the sink and by the poll. */
|
|
336
|
+
poke() {
|
|
337
|
+
if (this.stopped || this.pokeQueued) return;
|
|
338
|
+
this.pokeQueued = true;
|
|
339
|
+
setImmediate(() => {
|
|
340
|
+
this.pokeQueued = false;
|
|
341
|
+
this.tick().catch((e) => this._report(e));
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
_schedule(nextAt) {
|
|
346
|
+
if (this.mode !== "resident" || this.stopped || !Number.isFinite(nextAt)) return;
|
|
347
|
+
clearTimeout(this.timer);
|
|
348
|
+
const ms = Math.max(0, Math.min(nextAt - this.now(), 3600_000)) + 5;
|
|
349
|
+
this.timer = setTimeout(() => this.poke(), ms);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Resident: first pass now (activation), then watch state.json for other processes' events. */
|
|
353
|
+
async startResident({ pollMs = 1000 } = {}) {
|
|
354
|
+
let first;
|
|
355
|
+
try { first = await this.tick(); }
|
|
356
|
+
catch (e) { this._report(e); first = { error: this.lastError?.code ?? "error" }; } // intake goes on (V1 F1d)
|
|
357
|
+
this.poll = setInterval(() => {
|
|
358
|
+
let m = null;
|
|
359
|
+
try { m = lstatSync(this.store.path(STATE_FILE)).mtimeMs; } catch (_e) { m = null; }
|
|
360
|
+
if (m !== this._mtime) { this._mtime = m; this.poke(); }
|
|
361
|
+
}, pollMs);
|
|
362
|
+
return first;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** Stop: no new passes; a running hook's process group is killed. */
|
|
366
|
+
stop() {
|
|
367
|
+
this.stopped = true;
|
|
368
|
+
clearTimeout(this.timer);
|
|
369
|
+
clearInterval(this.poll);
|
|
370
|
+
if (this.child?.pid) { try { process.kill(-this.child.pid, "SIGKILL"); } catch (_e) {} }
|
|
371
|
+
}
|
|
372
|
+
}
|