clavarium 0.2.301-next.1 → 0.2.302-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deploy/clavarium-host +13 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/main.mjs +3 -1
- package/server/network.mjs +22 -2
package/deploy/clavarium-host
CHANGED
|
@@ -1390,8 +1390,20 @@ OOMScoreAdjust=-900'
|
|
|
1390
1390
|
[ $# -eq 0 ] || usage
|
|
1391
1391
|
run pgrep -a qemu-system ;;
|
|
1392
1392
|
"net bridge")
|
|
1393
|
+
# The bridge the machines' taps are on: multipass 1.17 names it per zone
|
|
1394
|
+
# (mpqemubrzone1, ...), older ones mpqemubr0 (04-11: the offline rules
|
|
1395
|
+
# were never written, their bridge not found). The first tap's says.
|
|
1393
1396
|
[ $# -eq 0 ] || usage
|
|
1394
|
-
|
|
1397
|
+
if [ "$SAY" = "yes" ]; then echo "ip -4 -o addr show <the bridge of the taps, else $BRIDGE>"; exit 0; fi
|
|
1398
|
+
bridge="$BRIDGE"
|
|
1399
|
+
for t in /sys/class/net/tap-*; do
|
|
1400
|
+
[ -e "$t/master" ] || continue
|
|
1401
|
+
m=$(basename "$(readlink "$t/master")"); [[ "$m" =~ ^mpqemubr[a-z0-9]{1,12}$ ]] && { bridge="$m"; break; }
|
|
1402
|
+
done
|
|
1403
|
+
if [ "$bridge" = "$BRIDGE" ] && ! [ -e "/sys/class/net/$BRIDGE" ]; then
|
|
1404
|
+
for b in /sys/class/net/mpqemubr*; do [ -e "$b" ] && { bridge=$(basename "$b"); break; }; done
|
|
1405
|
+
fi
|
|
1406
|
+
run ip -4 -o addr show "$bridge" ;;
|
|
1395
1407
|
"net apply")
|
|
1396
1408
|
# <ruleset>: the whole table, as text. Each line must be one of the
|
|
1397
1409
|
# shapes the server writes; one unknown line refuses the whole.
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.302-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.302-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/main.mjs
CHANGED
|
@@ -361,6 +361,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
361
361
|
/* Each opening: the runner and the attached secrets are put in the VM,
|
|
362
362
|
and the tool is started through the runner. */
|
|
363
363
|
const network = new Network({ host: asHost, offline: () => all.offline() });
|
|
364
|
+
/* A machine the VM manager started by itself (after a reboot) is put in its silo too (04-11). */
|
|
365
|
+
const stopNetworkWatch = network.watch();
|
|
364
366
|
/* The rules follow what runs: applied now, and again each time a
|
|
365
367
|
conversation is opened, since a VM that just started has a new tap. */
|
|
366
368
|
const hostReady = (async () => { await hostSteps; await network.apply().catch((error) => console.error(`network rules: ${error.message}`)); })();
|
|
@@ -656,7 +658,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
656
658
|
rooms.boxesBound(boxes.all());
|
|
657
659
|
rooms.refresh();
|
|
658
660
|
const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, binders, meshcentral, tethers, accounts, groups, boxes, catalogue, rooms, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
|
|
659
|
-
server.on('close', () => { closing = true; stopBinders(); stopTethers(); clearInterval(historyTimer); clearInterval(secretsTimer); history.save(); stopVmWatch(); stopShelf(); stopHealth(); stopUpdates(); stopWatch(); clearInterval(mailTimer); clearInterval(restartTimer); clearInterval(expiryTimer); clearInterval(answerTimer); clearInterval(wakeTimer); clearInterval(docketTimer); dockets.stop(); clearInterval(gitTimer); talk.stop(); });
|
|
661
|
+
server.on('close', () => { closing = true; stopBinders(); stopTethers(); clearInterval(historyTimer); clearInterval(secretsTimer); history.save(); stopVmWatch(); stopShelf(); stopHealth(); stopNetworkWatch(); stopUpdates(); stopWatch(); clearInterval(mailTimer); clearInterval(restartTimer); clearInterval(expiryTimer); clearInterval(answerTimer); clearInterval(wakeTimer); clearInterval(docketTimer); dockets.stop(); clearInterval(gitTimer); talk.stop(); });
|
|
660
662
|
let closing = false;
|
|
661
663
|
boxes.attach(server, WebSocketServer);
|
|
662
664
|
for (const c of all.list()) talk.speakers(c.name, boxes.speakersOf(c.name));
|
package/server/network.mjs
CHANGED
|
@@ -26,6 +26,10 @@ const TAP = /^tap-[0-9a-f]{1,12}$/;
|
|
|
26
26
|
/* The taps of the running conversation VMs, read from the process list:
|
|
27
27
|
{ conversation: tap }. Anything that does not look exactly as expected is
|
|
28
28
|
left out: a rule is never built from a string that was not checked. */
|
|
29
|
+
/* How often what runs is looked at, for the rules (see watch). */
|
|
30
|
+
export const WATCH_MS = 20_000;
|
|
31
|
+
export const RELOAD_MS = 10 * 60_000;
|
|
32
|
+
|
|
29
33
|
export function readTaps(processList) {
|
|
30
34
|
const taps = {};
|
|
31
35
|
for (const line of String(processList ?? '').split('\n')) {
|
|
@@ -62,6 +66,8 @@ export function ruleset(taps, offline, bridgeAddress) {
|
|
|
62
66
|
|
|
63
67
|
export class Network {
|
|
64
68
|
#host; #offline;
|
|
69
|
+
/* The table last loaded, and whether it was: the same table is not loaded again. */
|
|
70
|
+
#last = null;
|
|
65
71
|
|
|
66
72
|
/* `host(argv)` reaches the host program;
|
|
67
73
|
`offline()` returns the names of the conversations switched offline. */
|
|
@@ -79,7 +85,21 @@ export class Network {
|
|
|
79
85
|
a pipe as its input file (measured), and nothing in the rules is
|
|
80
86
|
secret. Every name in them was checked by readTaps, and the host
|
|
81
87
|
program checks every line again before loading it. */
|
|
82
|
-
const
|
|
83
|
-
|
|
88
|
+
const text = ruleset(taps, bridge ? wanted : [], bridge ?? '0.0.0.0');
|
|
89
|
+
const ok = bridge !== undefined || wanted.length === 0;
|
|
90
|
+
/* Loaded again anyway now and then: a table taken off by someone else comes back. */
|
|
91
|
+
if (this.#last?.text === text && this.#last.loaded && Date.now() - this.#last.at < RELOAD_MS) return ok;
|
|
92
|
+
const r = await this.#host(['net', 'apply', text]);
|
|
93
|
+
this.#last = { text, loaded: r.code === 0, at: Date.now() };
|
|
94
|
+
return r.code === 0 && ok;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* KEPT UP TO DATE (04-11): a machine started by the VM manager itself -- after the server
|
|
98
|
+
restarted -- has a new tap that no opening told: looked at every `everyMs`, the table loaded
|
|
99
|
+
again only when what runs changed. Returns the stop. */
|
|
100
|
+
watch(everyMs = WATCH_MS) {
|
|
101
|
+
const timer = setInterval(() => { void this.apply().catch(() => {}); }, everyMs);
|
|
102
|
+
timer.unref?.();
|
|
103
|
+
return () => clearInterval(timer);
|
|
84
104
|
}
|
|
85
105
|
}
|