@decentnetwork/lan 0.1.293 → 0.1.294
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/dist/cli/commands.js +32 -0
- package/dist/ui/desktop/app.js +4 -1
- package/package.json +2 -2
package/dist/cli/commands.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { resolve, dirname, join } from "path";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, copyFileSync, writeSync } from "fs";
|
|
6
6
|
import { createConnection } from "net";
|
|
7
|
+
import { execFileSync } from "child_process";
|
|
7
8
|
import { createRequire } from "module";
|
|
8
9
|
import { fileURLToPath } from "url";
|
|
9
10
|
import { ConfigLoader, DEFAULT_BOOTSTRAP_NODES, DEFAULT_DORAS, DEFAULT_EXITS, mergeBootstrapNodes, } from "../config/loader.js";
|
|
@@ -75,11 +76,42 @@ function assertDaemonNotRunning(config, commandName) {
|
|
|
75
76
|
* response. Throws with the daemon's error message on failure, or
|
|
76
77
|
* if the socket isn't there / hangs up.
|
|
77
78
|
*/
|
|
79
|
+
/** Who, if anyone, is holding the identity lock without serving IPC. */
|
|
80
|
+
function readIdentityHolder(dataDir) {
|
|
81
|
+
try {
|
|
82
|
+
const pid = Number.parseInt(readFileSync(join(dataDir, "daemon.pid"), "utf8").trim(), 10);
|
|
83
|
+
if (!Number.isFinite(pid) || pid <= 0)
|
|
84
|
+
return undefined;
|
|
85
|
+
process.kill(pid, 0); // throws if it is gone
|
|
86
|
+
let command = "unknown process";
|
|
87
|
+
try {
|
|
88
|
+
command = execFileSync("ps", ["-o", "command=", "-p", String(pid)], { encoding: "utf8" })
|
|
89
|
+
.trim().split("\n")[0]?.slice(0, 90) ?? command;
|
|
90
|
+
}
|
|
91
|
+
catch { /* ps is best-effort */ }
|
|
92
|
+
return { pid, command };
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
78
98
|
async function ipcCall(config, req, timeoutMs = 30_000) {
|
|
79
99
|
const sockPath = ipcSocketPath(config.carrier.dataDir);
|
|
80
100
|
// fs.existsSync works for Unix-domain sockets, but always reports false for
|
|
81
101
|
// Windows named pipes. On Windows, connect directly and trust net's error.
|
|
82
102
|
if (ipcSocketSupportsFsExistenceCheck() && !existsSync(sockPath)) {
|
|
103
|
+
// "is the daemon running?" points the wrong way in the common case. beagle
|
|
104
|
+
// in embedded mode TAKES this identity — it writes its own pid into
|
|
105
|
+
// daemon.pid so `agentnet up` cannot start a second peer on the same
|
|
106
|
+
// keypair — and it serves no IPC socket. So the honest answer is usually
|
|
107
|
+
// "something else holds this identity", not "nothing is running".
|
|
108
|
+
// Seen on this machine: `agentnet restart` reported a missing daemon while
|
|
109
|
+
// beagle had been holding the identity for six hours.
|
|
110
|
+
const holder = readIdentityHolder(config.carrier.dataDir);
|
|
111
|
+
if (holder) {
|
|
112
|
+
throw new Error(`No daemon here — pid ${holder.pid} holds this identity (${holder.command}). ` +
|
|
113
|
+
`That is beagle running embedded; restart it from the app, or stop it and then \`agentnet up\`.`);
|
|
114
|
+
}
|
|
83
115
|
throw new Error(`Daemon socket not found at ${sockPath} — is the daemon running?`);
|
|
84
116
|
}
|
|
85
117
|
return new Promise((resolve, reject) => {
|
package/dist/ui/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.294";
|
|
2
2
|
const ICON_PATHS = {
|
|
3
3
|
// ---- tab bar (the four must feel like one set) ----
|
|
4
4
|
users: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
|
|
@@ -408,6 +408,9 @@ function dkRtcSignalBus() {
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
|
+
if (!signals.length) {
|
|
412
|
+
await new Promise((res) => setTimeout(res, 400));
|
|
413
|
+
}
|
|
411
414
|
}
|
|
412
415
|
}
|
|
413
416
|
const bus = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/lan",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.294",
|
|
4
4
|
"description": "Private virtual LAN for self-hosted services and AI agents, built on Elastos Carrier. NAT-traversal, name service, ACL, all over a peer-to-peer mesh — no public IP required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@decentnetwork/dora": "^0.1.14",
|
|
87
|
-
"@decentnetwork/peer": "^0.1.
|
|
87
|
+
"@decentnetwork/peer": "^0.1.162",
|
|
88
88
|
"@decentnetwork/peer-webrtc": "^0.2.10",
|
|
89
89
|
"ink": "^5.2.1",
|
|
90
90
|
"js-yaml": "^4.1.0",
|