strom-research 1.37.0-beta.6 → 1.37.0-beta.7

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/CHANGELOG.cs.md CHANGED
@@ -7,7 +7,7 @@ Změny každé verze ve zkratce. Úplné poznámky a instalační řádky jsou n
7
7
 
8
8
  ## 1.37.0
9
9
 
10
- *Připravuje se: bety do 1.37.0-beta.6. Oddíl bude úplný s vydáním.*
10
+ *Připravuje se: bety do 1.37.0-beta.7. Oddíl bude úplný s vydáním.*
11
11
 
12
12
  - **Záznam archivu už nedrží portál ze seznamu stromu:** kniha s adresou na portálu, který seznam stromu zná (Porta
13
13
  fontium, Acta Publica…), už nedělá portál tak přísný jako archiv, pod kterým je zapsaná – portál se řídí svými
package/CHANGELOG.de.md CHANGED
@@ -7,7 +7,7 @@ Die Änderungen jeder Version in Kürze. Die vollständigen Hinweise und die Ins
7
7
 
8
8
  ## 1.37.0
9
9
 
10
- *In Vorbereitung: die Betas bis 1.37.0-beta.6. Der Abschnitt ist mit dem Release vollständig.*
10
+ *In Vorbereitung: die Betas bis 1.37.0-beta.7. Der Abschnitt ist mit dem Release vollständig.*
11
11
 
12
12
  - **Ein Archiveintrag der Forschung hält kein Portal der Liste von strom mehr:** ein Buch mit einer Adresse auf einem
13
13
  Portal, das die Liste von strom kennt (Porta fontium, Acta Publica…), macht das Portal nicht mehr so streng wie das
package/CHANGELOG.md CHANGED
@@ -7,7 +7,7 @@ The changes of each version in short. The full notes and the install lines are o
7
7
 
8
8
  ## 1.37.0
9
9
 
10
- *In preparation: the betas up to 1.37.0-beta.6. The section is complete with the release.*
10
+ *In preparation: the betas up to 1.37.0-beta.7. The section is complete with the release.*
11
11
 
12
12
  - **A research's archive no longer holds a portal of strom's list:** a book whose address is on a portal strom's list
13
13
  knows (Porta fontium, Acta Publica…) no longer makes the portal as strict as the archive the book is recorded under —
package/CHANGELOG.pl.md CHANGED
@@ -7,7 +7,7 @@ Zmiany każdej wersji w skrócie. Pełne informacje o wydaniach i polecenia inst
7
7
 
8
8
  ## 1.37.0
9
9
 
10
- *W przygotowaniu: bety do 1.37.0-beta.6. Sekcja będzie kompletna z wydaniem.*
10
+ *W przygotowaniu: bety do 1.37.0-beta.7. Sekcja będzie kompletna z wydaniem.*
11
11
 
12
12
  - **Wpis archiwum w badaniu nie utrzymuje już portalu z listy stroma:** księga z adresem na portalu, który zna lista
13
13
  stroma (Porta fontium, Acta Publica…), nie czyni już portalu tak surowym jak archiwum, pod którym jest zapisana –
@@ -4,7 +4,8 @@ import { register } from "../cli/registry.js";
4
4
  import { lines, table } from "../cli/format.js";
5
5
  import { ui } from "../cli/ui.js";
6
6
  import { StromError } from "../core/errors.js";
7
- import { pairCode, pairedPhones, pairUrl, phoneConfig, phoneLogFile, phoneProbeNow, phoneState, phoneWindowText, removePhone, servePhone, stopPhone, turnPhoneOn } from "../core/phone.js";
7
+ import { configDir } from "../core/paths.js";
8
+ import { pairCode, pairedPhones, pairUrl, phoneConfig, phoneLogFile, phoneProbeNow, phoneState, phoneTest, phoneTestOnCommand, phoneTestPortRefused, phoneWindowText, removePhone, servePhone, stopPhone, turnPhoneOn } from "../core/phone.js";
8
9
  import { qrTerminal } from "../core/qr.js";
9
10
  /** What the state says to a person, in their language. */
10
11
  function stateLines(lang, s) {
@@ -59,12 +60,22 @@ function qrLines(ctx, s, address) {
59
60
  const time = new Date(expiresAt).toLocaleTimeString(lang, { hour: "2-digit", minute: "2-digit" });
60
61
  return lines(qrTerminal(pairUrl(url, code, lang)), "", ui(lang, "ui.phone.qr", { time }), ui(lang, "ui.phone.qr.url", { url }), ...s.addresses.filter((a) => a.url !== url).map((a) => ui(lang, "ui.phone.qr.more", { url: a.url })));
61
62
  }
63
+ /** A test of the network (STROM_PHONE_TEST=lan, isolated): said first, never mistaken for the phone connection of this computer. */
64
+ function testLines(ctx) {
65
+ return phoneTest(ctx.env) === "lan" ? [`test lan (STROM_PHONE_TEST=lan): the computer's network, the settings of ${configDir(ctx.env)}`] : [];
66
+ }
67
+ /** A test of the network on a port of a strom that is no test's (or none said): refused before anything. */
68
+ function refuseTestPort(ctx) {
69
+ const refused = phoneTestPortRefused(ctx.env);
70
+ if (refused)
71
+ throw new StromError(refused, { hint: "the test's own port in its phone.json, then again", code: "phone.test-port" });
72
+ }
62
73
  /** The person's own terminal: a QR code may be shown. */
63
74
  const showsQr = (ctx) => ctx.io.tty && !ctx.json;
64
75
  async function status(ctx) {
65
76
  const s = phoneState(ctx.env);
66
77
  const probe = await phoneProbeNow(ctx.env);
67
- return { text: stateLines(ctx.uiLang(), s), data: { ...s, ...probe } };
78
+ return { text: lines(...testLines(ctx), stateLines(ctx.uiLang(), s)), data: { ...s, ...probe } };
68
79
  }
69
80
  register({
70
81
  path: ["phone"],
@@ -90,11 +101,14 @@ register({
90
101
  description: "An agent cannot answer for the user: without a terminal of theirs or a window of the system it ends with needs-input (exit 4).",
91
102
  async run(ctx) {
92
103
  const lang = ctx.uiLang();
104
+ refuseTestPort(ctx);
93
105
  if (!phoneConfig(ctx.env).on) {
94
106
  // in a terminal too, the person's own yes (it opens the computer to its network; Enter says no): a terminal an agent
95
107
  // opened round its markers turns nothing on by itself
96
108
  const w = phoneWindowText(ctx.env, lang);
97
- const how = await ctx.requireHumanYes("Turn on the connection with a phone on the local network (a phone paired by its QR code sees an overview of the research and sends photos into it)?", "strom phone on", "phone", windowSays(ctx, lang), { terminal: w.question, ask: w.title });
109
+ const how = await ctx.requireHumanYes("Turn on the connection with a phone on the local network (a phone paired by its QR code sees an overview of the research and sends photos into it)?",
110
+ // a test of the network: no answer of a test — the person's own terminal, in the test's environment
111
+ phoneTestOnCommand(ctx.env) ?? "strom phone on", "phone", windowSays(ctx, lang), { terminal: w.question, ask: w.title });
98
112
  if (!how)
99
113
  return { text: ui(lang, "ui.phone.notturned"), data: phoneState(ctx.env) };
100
114
  turnPhoneOn(ctx.env, how === "terminal" ? "strom phone on, yes in the user's terminal" : "strom phone on, yes in a window");
@@ -104,7 +118,7 @@ register({
104
118
  // the QR code to pair a phone right away, in the person's terminal; to an agent only where it is
105
119
  const s = showsQr(ctx) ? await withAddresses(ctx) : phoneState(ctx.env);
106
120
  const qr = s.state !== "on" ? "" : showsQr(ctx) && s.addresses.length ? qrLines(ctx, s) : ui(lang, "ui.phone.qr.app");
107
- return { text: lines(stateLines(lang, s), ...(qr ? ["", qr] : [])), data: phoneState(ctx.env) };
121
+ return { text: lines(...testLines(ctx), stateLines(lang, s), ...(qr ? ["", qr] : [])), data: phoneState(ctx.env) };
108
122
  },
109
123
  }, {
110
124
  path: ["phone", "qr"],
@@ -164,8 +178,11 @@ register({
164
178
  summary: "Run the phone's server here, in the foreground (strom phone on runs it in the background; only while on)",
165
179
  group: "setup",
166
180
  async run(ctx) {
181
+ refuseTestPort(ctx);
167
182
  if (!phoneConfig(ctx.env).on)
168
- throw new StromError("the phone connection is off", { hint: "the user turns it on: strom phone on", code: "phone.off" });
183
+ throw new StromError("the phone connection is off", { hint: `the user turns it on: ${phoneTestOnCommand(ctx.env) ?? "strom phone on"}`, code: "phone.off" });
184
+ for (const l of testLines(ctx))
185
+ ctx.io.stderr(`${l}\n`);
169
186
  const why = await servePhone(ctx.env);
170
187
  // a server that ended is gone as a process, whatever still holds it
171
188
  setTimeout(() => process.exit(), 3000).unref();
@@ -246,10 +246,17 @@ function bridgeHeaders(got) {
246
246
  headers[k.replace(/(^|-)([a-z])/g, (_m, d, c) => d + c.toUpperCase())] = v;
247
247
  return headers;
248
248
  }
249
- /** How often the gateway looks for uploads of devices unpaired (STROM_DEVICE_SWEEP_MS in a test of the loopback alone). */
249
+ /**
250
+ * A test's hooks of the gateway (STROM_DEVICE_*): an isolated strom's test of the loopback, or of the network with a real
251
+ * phone (STROM_PHONE_TEST=lan) — never elsewhere.
252
+ */
253
+ function testHooks(env) {
254
+ return (env.STROM_PHONE_TEST === "loopback" || env.STROM_PHONE_TEST === "lan") && env.STROM_ISOLATED === "1";
255
+ }
256
+ /** How often the gateway looks for uploads of devices unpaired (STROM_DEVICE_SWEEP_MS in a test: testHooks). */
250
257
  function sweepMs(env) {
251
258
  const asked = Number(env.STROM_DEVICE_SWEEP_MS);
252
- return env.STROM_PHONE_TEST === "loopback" && env.STROM_ISOLATED === "1" && Number.isInteger(asked) && asked >= 50 ? asked : 10_000;
259
+ return testHooks(env) && Number.isInteger(asked) && asked >= 50 ? asked : 10_000;
253
260
  }
254
261
  const HEADERS = {
255
262
  "Content-Type": "application/json; charset=utf-8",
@@ -276,11 +283,16 @@ const DNS_LABEL = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/;
276
283
  /**
277
284
  * The computer's own name on the home network, `<name>.local` (lower case): the first part of its hostname, when it
278
285
  * is a name DNS can say (none — a name with diacritics, spaces, nothing: null, the devices stay at an IP address). A
279
- * test of the loopback alone may say it (STROM_DEVICE_LOCAL_NAME; "" for none) — never elsewhere.
286
+ * test (testHooks) may say it (STROM_DEVICE_LOCAL_NAME; "" for none) — never elsewhere; a test of the network with a real
287
+ * phone (lan) never the computer's own (a device of it is not mixed with the phone connection of a strom that is no
288
+ * test's): none unless said.
280
289
  */
281
290
  export function localName(env) {
282
291
  const asked = env.STROM_DEVICE_LOCAL_NAME;
283
- const test = asked !== undefined && env.STROM_PHONE_TEST === "loopback" && env.STROM_ISOLATED === "1";
292
+ const lan = env.STROM_PHONE_TEST === "lan" && env.STROM_ISOLATED === "1";
293
+ const test = asked !== undefined && testHooks(env);
294
+ if (lan && !test)
295
+ return null;
284
296
  const raw = test ? asked.replace(/\.local$/i, "") : (os.hostname().split(".")[0] ?? "");
285
297
  return DNS_LABEL.test(raw) ? `${raw.toLowerCase()}.local` : null;
286
298
  }
@@ -293,10 +305,10 @@ export function localName(env) {
293
305
  export function deviceActions(device, at) {
294
306
  return ["device.rename", "device.unpair", ...(device.of ? [] : ["device.home"]), ...(at.local && at.host && at.host !== at.local ? ["device.move"] : []), "conflict.decide", "hypothesis.decide", "sync.undo", "media.put"];
295
307
  }
296
- /** The gate of the app for the devices in a test of the loopback alone (STROM_DEVICE_APP_GATE): never elsewhere. */
297
- function appGate(env) {
308
+ /** The gate of the app for the devices in a test (STROM_DEVICE_APP_GATE; testHooks): never elsewhere. */
309
+ export function appGate(env) {
298
310
  const asked = env.STROM_DEVICE_APP_GATE;
299
- if (asked && env.STROM_PHONE_TEST === "loopback" && env.STROM_ISOLATED === "1" && isAppVersion(asked))
311
+ if (asked && testHooks(env) && isAppVersion(asked))
300
312
  return asked;
301
313
  return undefined;
302
314
  }
@@ -440,10 +452,10 @@ function parseJson(b) {
440
452
  const DEVICE_EVENTS = new Set(["hello", "change", "read", "history", "quality", "device", "end"]);
441
453
  /** An event of the bridge longer than this ends the stream (the bridge's own on the loopback: never one of a device). */
442
454
  const EVENT_BLOCK_MAX = 64 * 1024 * 1024;
443
- /** How often a stream of events says `: ping` (STROM_DEVICE_PING_MS in a test of the loopback alone — never elsewhere). */
455
+ /** How often a stream of events says `: ping` (STROM_DEVICE_PING_MS in a test: testHooks — never elsewhere). */
444
456
  function pingMs(env) {
445
457
  const asked = Number(env.STROM_DEVICE_PING_MS);
446
- return env.STROM_PHONE_TEST === "loopback" && env.STROM_ISOLATED === "1" && Number.isInteger(asked) && asked >= 50 ? asked : EVENT_PING_MS;
458
+ return testHooks(env) && Number.isInteger(asked) && asked >= 50 ? asked : EVENT_PING_MS;
447
459
  }
448
460
  const IMAGE_TYPES = { ".png": "image/png", ".svg": "image/svg+xml", ".webp": "image/webp" };
449
461
  export function deviceGateway(env, note) {
@@ -602,10 +614,14 @@ export function deviceGateway(env, note) {
602
614
  nonces.forget(paired.device.id);
603
615
  note(`the device ${paired.device.id} paired (${paired.code ?? paired.mode})`);
604
616
  const { said } = deviceTrees(env);
617
+ // the tree whose window made the code (as trees[].id) — the app opens that one; a code of no tree (home, move), or
618
+ // of a tree no longer said here: no field
619
+ const tree = paired.tree && said.some((t) => t.id === paired.tree) ? { tree: paired.tree } : {};
605
620
  const sealed = sealPair(paired.key, String(s.pairId), {
606
621
  device: { id: paired.device.id, name: paired.device.name, kind: paired.device.kind },
607
622
  computer: { name: localName(env) ?? computerName(), label: computerName() },
608
623
  trees: said,
624
+ ...tree,
609
625
  });
610
626
  answer(res, 200, sealed);
611
627
  });
package/dist/core/live.js CHANGED
@@ -882,7 +882,7 @@ import { gateLabel } from "./gate.js";
882
882
  import { LINK_SCHEME, linkActions, linkHandlerState, linkHandlerStateLater, linkScheme, linkText } from "./links.js";
883
883
  import { handoffsNow } from "./handoffs.js";
884
884
  import { autoTidy } from "./tidy.js";
885
- import { askPhoneOn, endPhoneLater, pairCode, pairUrl, phoneConfig, phoneProbe, phoneRunning, phoneState, phoneSummary, removePhone, restorePhone, revivePhone, stopPhone } from "./phone.js";
885
+ import { askPhoneOn, endPhoneLater, pairCode, pairUrl, phoneConfig, phoneProbe, phoneRunning, phoneState, phoneSummary, phoneTestPortRefused, phoneTestYesHint, removePhone, restorePhone, revivePhone, stopPhone } from "./phone.js";
886
886
  import { qrSvg } from "./qr.js";
887
887
  import { clientOfDevice, deviceEvents, deviceName, devicePairCode, devicePairUrl, deviceRows, devicesList, devicesOn, hostOf, removeDevice, renameDevice, restoreDevice } from "./devices.js";
888
888
  import { deviceAppState, ensureDeviceApp, noteDeviceAppSource } from "./deviceapp.js";
@@ -8334,8 +8334,9 @@ export function serveLive(root, env) {
8334
8334
  }
8335
8335
  const how = askPhoneOn(env, lang ?? Tree.open(root, env).lang);
8336
8336
  noteLive(root, `the phone connection: asked to turn it on — ${how === "confirm" ? "a window asks the person" : how === "on" ? "on already" : "no window can be shown here"}`);
8337
+ // a test of the network (lan): its port refused, or what the person runs to say yes (no answer of a test there)
8337
8338
  if (how === "no-dialog")
8338
- return phoneJson(res, 200, { ...phoneState(env), state: "off", error: { code: "no-dialog", detail: "no window of the system can be shown on this computer: strom phone on in a terminal" } });
8339
+ return phoneJson(res, 200, { ...phoneState(env), state: "off", error: { code: "no-dialog", detail: phoneTestPortRefused(env) ?? phoneTestYesHint(env) ?? "no window of the system can be shown on this computer: strom phone on in a terminal" } });
8339
8340
  return phoneJson(res, 200, phoneState(env));
8340
8341
  }
8341
8342
  if (sub === "off" && !act) {
@@ -187,21 +187,64 @@ function sameNetwork(ip, local, mask) {
187
187
  const [a, b, m] = [n(ip), n(local), n(mask)];
188
188
  return a !== undefined && b !== undefined && m !== undefined && ((a & m) >>> 0) === ((b & m) >>> 0);
189
189
  }
190
- /** STROM_PHONE_TEST: "loopback" — a test's server on 127.0.0.1 alone; any other value — no network at all. */
191
- function phoneTest(env) {
192
- return env.STROM_PHONE_TEST === "loopback" ? "loopback" : env.STROM_PHONE_TEST ? "none" : undefined;
190
+ /**
191
+ * STROM_PHONE_TEST: "loopback" — a test's server on 127.0.0.1 alone; "lan" with STROM_ISOLATED=1 — a test with a real
192
+ * phone on the Wi-Fi: the computer's network as for every strom (its addresses, a device of that network alone, never
193
+ * the computer itself), on the port of the isolated phone.json alone (never PHONE_PORT's range: phoneTestPortRefused),
194
+ * no answer of a test for the person (STROM_PHONE_TEST_ANSWER ignored), no name of the computer on the network; any
195
+ * other value — "lan" not isolated too — no network at all.
196
+ */
197
+ export function phoneTest(env) {
198
+ if (env.STROM_PHONE_TEST === "loopback")
199
+ return "loopback";
200
+ if (env.STROM_PHONE_TEST === "lan" && env.STROM_ISOLATED === "1")
201
+ return "lan";
202
+ return env.STROM_PHONE_TEST ? "none" : undefined;
203
+ }
204
+ /**
205
+ * In a test of the network (lan): why its port is refused — none in phone.json (it would be PHONE_PORT's), or one of
206
+ * PHONE_PORT's range (the port of a strom that is no test's, on this computer); undefined — the port is the test's.
207
+ */
208
+ export function phoneTestPortRefused(env) {
209
+ if (phoneTest(env) !== "lan")
210
+ return undefined;
211
+ const port = phoneConfig(env).port;
212
+ const where = file(env, "phone.json");
213
+ if (port === undefined)
214
+ return `test lan: no port of the test in ${where} — write one there outside ${PHONE_PORT}–${PHONE_PORT + PORT_TRIES - 1}, e.g. {"on": false, "port": 47900}`;
215
+ if (port >= PHONE_PORT && port < PHONE_PORT + PORT_TRIES)
216
+ return `test lan: the port ${port} in ${where} is of the phone connection of a strom that is no test's (${PHONE_PORT}–${PHONE_PORT + PORT_TRIES - 1}) — write another there, e.g. {"port": 47900}`;
217
+ return undefined;
218
+ }
219
+ /**
220
+ * In a test of the network (lan): what the person runs to say yes, where no window can be shown (STROM_NO_DIALOG) or no
221
+ * terminal of theirs asks (STROM_NONINTERACTIVE) — the same environment, in their own terminal.
222
+ */
223
+ export function phoneTestYesHint(env) {
224
+ const command = phoneTestOnCommand(env);
225
+ return command && `test lan: no answer of a test here — the person says yes in their own terminal, in the test's environment: ${command}`;
226
+ }
227
+ /**
228
+ * In a test of the network (lan): the command of the person's yes in their terminal (no STROM_NONINTERACTIVE there), its
229
+ * settings folder and isolation named (a terminal that lost them never turns on the phone connection of their own strom).
230
+ */
231
+ export function phoneTestOnCommand(env) {
232
+ if (phoneTest(env) !== "lan")
233
+ return undefined;
234
+ const q = (s) => (/^[\p{L}\p{M}\p{N}/._+:=-]+$/u.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`);
235
+ return `STROM_NONINTERACTIVE= STROM_ISOLATED=1 STROM_PHONE_TEST=lan STROM_CONFIG_DIR=${q(configDir(env))} ${q(process.execPath)} ${q(process.argv[1] ?? "strom")} phone on`;
193
236
  }
194
237
  /**
195
238
  * The computer's addresses a phone may reach it at: private IPv4 of a Wi-Fi or a cable that is up (never loopback, never
196
239
  * a VPN's — neither its tunnel nor its shared range 100.64/10 —, never a virtual machine's network, never IPv6), Wi-Fi
197
- * and a cable first. STROM_PHONE_TEST (tests never bind the computer's network): "loopback" — 127.0.0.1 alone; any
198
- * other value — no network.
240
+ * and a cable first. STROM_PHONE_TEST (tests never bind the computer's network): "loopback" — 127.0.0.1 alone; "lan"
241
+ * of an isolated strom — these, as for every strom (phoneTest); any other value — no network.
199
242
  */
200
243
  export function lanAddresses(env, ifaces = os.networkInterfaces(), platform = process.platform) {
201
244
  const test = phoneTest(env);
202
245
  if (test === "loopback")
203
246
  return [{ ip: "127.0.0.1", iface: "lo", kind: null, mask: "255.0.0.0" }];
204
- if (test)
247
+ if (test === "none")
205
248
  return [];
206
249
  const out = [];
207
250
  for (const [name, list] of Object.entries(ifaces)) {
@@ -426,10 +469,11 @@ export function phoneWindowText(env, lang) {
426
469
  /**
427
470
  * The window that asks the person: a window of the system, or — STROM_PHONE_TEST loopback|none with STROM_ISOLATED=1 and
428
471
  * STROM_PHONE_TEST_ANSWER yes|no|wait (tests: a stand-in that answers, never a window; what it turns on is a test's, on
429
- * the loopback alone, off for any strom that is no test's) — a process standing for one. None where no window can be
430
- * shown.
472
+ * the loopback alone, off for any strom that is no test's) — a process standing for one; never in a test of the network
473
+ * (lan: the person's window, or their terminal). None where no window can be shown.
431
474
  */
432
475
  function phoneDialog(env, lang) {
476
+ // never in a test of the network (lan): the person answers it (a real phone, the computer's network)
433
477
  const test = (env.STROM_PHONE_TEST === "loopback" || env.STROM_PHONE_TEST === "none") && env.STROM_ISOLATED === "1" && env.STROM_PHONE_TEST_ANSWER;
434
478
  if (test === "yes" || test === "no" || test === "wait") {
435
479
  const ms = test === "wait" ? WAIT_SECONDS * 1000 : Number(env.STROM_PHONE_TEST_ANSWER_MS ?? 300);
@@ -450,6 +494,12 @@ export function askPhoneOn(env, lang, done) {
450
494
  return "on";
451
495
  if (asking(readAsk(env)))
452
496
  return "confirm";
497
+ // a test of the network on a port of a strom that is no test's: never asked (phoneTestPortRefused says why)
498
+ const refused = phoneTestPortRefused(env);
499
+ if (refused) {
500
+ notePhone(env, refused);
501
+ return "no-dialog";
502
+ }
453
503
  const command = phoneDialog(env, lang);
454
504
  if (!command)
455
505
  return "no-dialog";
@@ -840,7 +890,7 @@ function output(cmd, args) {
840
890
  }
841
891
  async function lookUp(env, platform) {
842
892
  const checkedAt = new Date().toISOString();
843
- if (env.STROM_PHONE_TEST)
893
+ if (env.STROM_PHONE_TEST && phoneTest(env) !== "lan")
844
894
  return { network: null, firewall: null };
845
895
  if (platform === "darwin") {
846
896
  const out = await output("/usr/libexec/ApplicationFirewall/socketfilterfw", ["--getglobalstate"]);
@@ -931,6 +981,9 @@ export function servePhone(env) {
931
981
  // each address bound and the mask of its network
932
982
  const nets = new Map();
933
983
  let port = phoneConfig(env).port ?? PHONE_PORT;
984
+ // a test of the network: on its own port alone (never PHONE_PORT's range, never another tried)
985
+ const lan = phoneTest(env) === "lan";
986
+ const refused = phoneTestPortRefused(env);
934
987
  let current = { pid: me, version: runs, started: new Date().toISOString(), port, state: "error", error: { code: "no-lan", detail: "" }, addresses: [], ...(before?.addressChangedAt ? { addressChangedAt: before.addressChangedAt } : {}), ...(before?.lanSeenAt ? { lanSeenAt: before.lanSeenAt } : {}) };
935
988
  let urls = before?.addresses.map((a) => a.url).sort();
936
989
  let ended = false;
@@ -1145,7 +1198,7 @@ export function servePhone(env) {
1145
1198
  else
1146
1199
  failure = r.code === "EADDRINUSE" ? { code: "port-busy", detail: r.detail ?? "" } : (failure ?? { code: "bind-failed", detail: r.detail ?? "" });
1147
1200
  }
1148
- if (failure?.code !== "port-busy")
1201
+ if (failure?.code !== "port-busy" || lan)
1149
1202
  break;
1150
1203
  closeAll();
1151
1204
  notePhone(env, `the port ${port} is taken by another program`);
@@ -1224,7 +1277,9 @@ export function servePhone(env) {
1224
1277
  const rebind = setInterval(() => void bindAll().catch((e) => notePhone(env, `the addresses not looked at: ${String(e)}`)), Number(env.STROM_PHONE_REBIND_MS ?? 30_000));
1225
1278
  if (!phoneConfig(env).on)
1226
1279
  return end("turned off");
1227
- notePhone(env, `the server started (strom ${runs})`);
1280
+ if (refused)
1281
+ return end(refused);
1282
+ notePhone(env, `the server started (strom ${runs}${lan ? `, test lan: the computer's network, the port ${port} of ${file(env, "phone.json")}` : ""})`);
1228
1283
  void bindAll().catch((e) => notePhone(env, `the addresses not looked at: ${String(e)}`));
1229
1284
  });
1230
1285
  }
package/dist/core/tree.js CHANGED
@@ -32,7 +32,7 @@ export const TREE_FILE = "strom.json";
32
32
  export const SEAL_FOREIGN = "seal.foreign";
33
33
  // between releases the candidate being made (a bridge run from the sources says what it is: the Strom app goes by it);
34
34
  // at a release the release's own (package.json)
35
- export const VERSION = "1.37.0-beta.6";
35
+ export const VERSION = "1.37.0-beta.7";
36
36
  /** What a new research is settled with from the start: nothing an older strom counted otherwise to set right in it. */
37
37
  export const NEW_TREE_SETTLED = ["readers-1", "proven-originals-1", "origins-1", "verify-originals-1", "origins-tree-1", "name-status-1"];
38
38
  const GITIGNORE = `# Strom Research — local state and large files are not versioned
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strom-research",
3
- "version": "1.37.0-beta.6",
3
+ "version": "1.37.0-beta.7",
4
4
  "stromDoc": "8940ea14ca510aebcd7f00d2de6f4a64da84de0e",
5
5
  "description": "Genealogical research toolkit for AI coding agents",
6
6
  "type": "module",