tesseract-agent 0.9.8 → 0.9.10

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.
Files changed (2) hide show
  1. package/dist-bundle/cli.js +17 -38
  2. package/package.json +1 -1
@@ -63375,7 +63375,19 @@ Next, issue an identity for a machine (pick a free address in ${formatPrefix(gen
63375
63375
  issuedAt: Date.now(),
63376
63376
  maxStaleness: DEFAULT_MAX_STALENESS_MS,
63377
63377
  groupTable: [],
63378
- rules: [{ action: ACTION_ACCEPT, srcGroups: [], srcCidrs: [], proto: PROTO_ANY, ports: [], dstCidrs: [], caps: 0 }],
63378
+ // `--caps exit` grants CAP_EXIT_NODE. It is a SEPARATE grant from being allowed
63379
+ // to reach the machine, which is the whole reason the capability lives in policy
63380
+ // rather than the certificate: revoking "route the internet through it" must not
63381
+ // require re-issuing anyone's identity.
63382
+ rules: [{
63383
+ action: ACTION_ACCEPT,
63384
+ srcGroups: [],
63385
+ srcCidrs: [],
63386
+ proto: PROTO_ANY,
63387
+ ports: [],
63388
+ dstCidrs: [],
63389
+ caps: String(flags.caps ?? "").split(",").includes("exit") ? CAP_EXIT_NODE : 0
63390
+ }],
63379
63391
  roster: [],
63380
63392
  revokedSerials: [],
63381
63393
  revokedStatics: [],
@@ -63392,7 +63404,7 @@ Next, issue an identity for a machine (pick a free address in ${formatPrefix(gen
63392
63404
  die(`Usage:
63393
63405
  tesseract-agent net init --org NAME [--ca-dir DIR]
63394
63406
  tesseract-agent net mint --name NODE --ip A.B.C.D [--out DIR] [--exit-node] [--relay] [--groups a,b]
63395
- tesseract-agent net policy [--epoch N] [--out FILE]`);
63407
+ tesseract-agent net policy [--epoch N] [--caps exit] [--out FILE]`);
63396
63408
  }
63397
63409
  var SEED_LEN;
63398
63410
  var init_mesh_ca = __esm({
@@ -86547,57 +86559,24 @@ async function runDaemon(opts = {}) {
86547
86559
  return pids;
86548
86560
  }
86549
86561
  async function takeoverMachine() {
86550
- const rivals = /* @__PURE__ */ new Set();
86551
86562
  let lockPid = 0, statusPid = 0;
86552
86563
  const otherPids = [];
86553
86564
  try {
86554
86565
  lockPid = Number(readFileSync31(pidfile(), "utf-8").trim());
86555
- if (lockPid > 0)
86556
- rivals.add(lockPid);
86557
86566
  } catch {
86558
86567
  }
86559
86568
  try {
86560
86569
  statusPid = Number(JSON.parse(readFileSync31(statusFile(), "utf-8")).pid ?? 0);
86561
- if (statusPid > 0)
86562
- rivals.add(statusPid);
86563
86570
  } catch {
86564
86571
  }
86565
- for (const p of otherDaemonPids()) {
86572
+ for (const p of otherDaemonPids())
86566
86573
  otherPids.push(p);
86567
- rivals.add(p);
86568
- }
86569
86574
  try {
86570
- log9(`takeover: me=${process.pid} lockPid=${lockPid || "-"} statusPid=${statusPid || "-"} otherDaemonPids=[${otherPids.join(",") || "-"}]`);
86575
+ log9(`takeover(no-kill): me=${process.pid} lockPid=${lockPid || "-"} statusPid=${statusPid || "-"} otherDaemonPids=[${otherPids.join(",") || "-"}]`);
86571
86576
  } catch {
86572
86577
  }
86573
- rivals.delete(process.pid);
86574
- const live = [...rivals].filter(isAlive2);
86575
- if (live.length) {
86576
- for (const pid of live) {
86577
- let cmd = "";
86578
- try {
86579
- cmd = execFileSync4("ps", ["-o", "command=", "-p", String(pid)], { encoding: "utf8", timeout: 2e3 }).trim().slice(0, 200);
86580
- } catch {
86581
- }
86582
- log9(`takeover: killing rival daemon pid=${pid} (latest-wins single-instance) cmd=[${cmd}]`);
86583
- try {
86584
- process.kill(pid, "SIGTERM");
86585
- } catch {
86586
- }
86587
- }
86588
- for (let i = 0; i < 25 && live.some(isAlive2); i++)
86589
- await new Promise((r) => setTimeout(r, 100));
86590
- for (const pid of live)
86591
- if (isAlive2(pid)) {
86592
- log9(`takeover: SIGKILL rival pid=${pid} (ignored SIGTERM)`);
86593
- try {
86594
- process.kill(pid, "SIGKILL");
86595
- } catch {
86596
- }
86597
- }
86598
- }
86599
86578
  try {
86600
- if (existsSync29(pidfile()))
86579
+ if (existsSync29(pidfile()) && (!lockPid || lockPid === process.pid || !isAlive2(lockPid)))
86601
86580
  unlinkSync4(pidfile());
86602
86581
  } catch {
86603
86582
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tesseract-agent",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "license": "UNLICENSED",
5
5
  "publishConfig": {
6
6
  "access": "public",