@decentnetwork/lan 0.1.281 → 0.1.283
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/daemon/ipc.d.ts +3 -0
- package/dist/daemon/ipc.js +27 -1
- package/dist/daemon/server.js +14 -48
- package/dist/ui/desktop/app.js +1 -1
- package/package.json +1 -1
package/dist/daemon/ipc.d.ts
CHANGED
|
@@ -169,6 +169,9 @@ export declare class IpcServer {
|
|
|
169
169
|
private socketPath;
|
|
170
170
|
private handlers;
|
|
171
171
|
private server?;
|
|
172
|
+
/** Live client connections, so stop() can end them instead of waiting on
|
|
173
|
+
* a subscriber that never hangs up. */
|
|
174
|
+
private openSockets;
|
|
172
175
|
private logger;
|
|
173
176
|
constructor(socketPath: string, handlers: IpcHandlers);
|
|
174
177
|
start(): Promise<void>;
|
package/dist/daemon/ipc.js
CHANGED
|
@@ -61,6 +61,9 @@ export class IpcServer {
|
|
|
61
61
|
socketPath;
|
|
62
62
|
handlers;
|
|
63
63
|
server;
|
|
64
|
+
/** Live client connections, so stop() can end them instead of waiting on
|
|
65
|
+
* a subscriber that never hangs up. */
|
|
66
|
+
openSockets = new Set();
|
|
64
67
|
logger;
|
|
65
68
|
constructor(socketPath, handlers) {
|
|
66
69
|
this.socketPath = socketPath;
|
|
@@ -79,7 +82,14 @@ export class IpcServer {
|
|
|
79
82
|
this.logger.warn(`Could not remove stale socket ${this.socketPath}: ${err}`);
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
this.server = createServer((sock) =>
|
|
85
|
+
this.server = createServer((sock) => {
|
|
86
|
+
// Track every live connection so stop() can force them shut. Without
|
|
87
|
+
// this, server.close() waits for all of them and a single long-lived
|
|
88
|
+
// subscriber deadlocks shutdown (see stop()).
|
|
89
|
+
this.openSockets.add(sock);
|
|
90
|
+
sock.once("close", () => this.openSockets.delete(sock));
|
|
91
|
+
this.handleConnection(sock);
|
|
92
|
+
});
|
|
83
93
|
await new Promise((resolve, reject) => {
|
|
84
94
|
this.server.once("error", reject);
|
|
85
95
|
this.server.listen(this.socketPath, () => {
|
|
@@ -103,6 +113,22 @@ export class IpcServer {
|
|
|
103
113
|
async stop() {
|
|
104
114
|
if (!this.server)
|
|
105
115
|
return;
|
|
116
|
+
// server.close() only fires its callback once every EXISTING connection
|
|
117
|
+
// has closed — it stops new ones, it does not end open ones. Event
|
|
118
|
+
// subscribers ({op:"subscribe"}) hold their connection open by design and
|
|
119
|
+
// never close it, so waiting on that callback is an unbounded wait on a
|
|
120
|
+
// peer that is never going to hang up.
|
|
121
|
+
//
|
|
122
|
+
// That is not theoretical: a daemon logged "Stopping daemon" and then sat
|
|
123
|
+
// in teardown for 24h46m, finishing 300ms after an unrelated `pm2 restart`
|
|
124
|
+
// happened to drop the subscriber. The same bug is behind the SIGTERM
|
|
125
|
+
// hangs that ran out systemd's TimeoutStopSec — every journal entry with
|
|
126
|
+
// "Shutting down..." and no matching "Daemon stopped" is this.
|
|
127
|
+
//
|
|
128
|
+
// We are shutting down, so end them ourselves and let close() complete.
|
|
129
|
+
for (const sock of this.openSockets)
|
|
130
|
+
sock.destroy();
|
|
131
|
+
this.openSockets.clear();
|
|
106
132
|
await new Promise((resolve) => {
|
|
107
133
|
this.server.close(() => resolve());
|
|
108
134
|
});
|
package/dist/daemon/server.js
CHANGED
|
@@ -564,54 +564,20 @@ export class DaemonServer {
|
|
|
564
564
|
this.logger.info(`Queued file "${name}" (${data.length}B) for offline ${userid.slice(0, 8)} (delivers on reconnect)`);
|
|
565
565
|
return { queued: true, name: safe, size: data.length };
|
|
566
566
|
}
|
|
567
|
-
// NATIVE friends (iOS/Android/C Carrier)
|
|
568
|
-
//
|
|
569
|
-
//
|
|
570
|
-
//
|
|
571
|
-
//
|
|
572
|
-
//
|
|
573
|
-
//
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
// Append the chip as "sending" FIRST, then let the SDK's delivery
|
|
582
|
-
// verdict decide what it becomes. Marking "sent" the moment
|
|
583
|
-
// sendInlineFile resolved was a lie — that only meant the bytes
|
|
584
|
-
// left this machine; a half-open session swallowed them silently
|
|
585
|
-
// while the sender stared at a checkmark (INBOX 2026-08-21 A).
|
|
586
|
-
const safeName = sanitizeFileName(name);
|
|
587
|
-
const chip = this.messageStore?.appendFile(userid, "out", { name: safeName, size: data.length, status: "sending", sent: 0 });
|
|
588
|
-
this.friendMeta?.ensure(userid);
|
|
589
|
-
this.ipcEvents.emit("event", { type: "chat", userid, dir: "out" });
|
|
590
|
-
// Sends are NON-BLOCKING (the 2026-08-05 rule): the delivery wait
|
|
591
|
-
// scales with size (up to 180s), and holding the HTTP request open
|
|
592
|
-
// that long froze the UI on an 8MB inline send. Return now; the
|
|
593
|
-
// verdict patches the chip and the event stream repaints it.
|
|
594
|
-
const bytes = new Uint8Array(data);
|
|
595
|
-
void (async () => {
|
|
596
|
-
let delivery;
|
|
597
|
-
try {
|
|
598
|
-
delivery = await this.peerManager.sendInlineFile(userid, bytes, name);
|
|
599
|
-
}
|
|
600
|
-
catch (e) {
|
|
601
|
-
if (chip)
|
|
602
|
-
this.messageStore?.patchFile(userid, chip.id, { status: "failed" });
|
|
603
|
-
this.ipcEvents.emit("event", { type: "chat", userid, dir: "out" });
|
|
604
|
-
this.logger.warn(`Inline file "${name}" to native ${userid.slice(0, 8)} failed: ${e.message}`);
|
|
605
|
-
return;
|
|
606
|
-
}
|
|
607
|
-
const status = delivery === "acked" ? "sent" : delivery === "offline" ? "queued" : "failed";
|
|
608
|
-
if (chip)
|
|
609
|
-
this.messageStore?.patchFile(userid, chip.id, { status, sent: delivery === "acked" ? data.length : 0 });
|
|
610
|
-
this.ipcEvents.emit("event", { type: "chat", userid, dir: "out" });
|
|
611
|
-
this.logger.info(`Inline file "${name}" (${data.length}B) to native ${userid.slice(0, 8)}: delivery=${delivery} → ${status}`);
|
|
612
|
-
})();
|
|
613
|
-
return { inline: true, name, size: data.length, pending: true };
|
|
614
|
-
}
|
|
567
|
+
// NATIVE friends (iOS/Android/C Carrier) stream like everyone else:
|
|
568
|
+
// sendFile below reaches them as DNFT1 frames (peer >= 0.1.141 —
|
|
569
|
+
// offset acks, FEC, resume; verified 100MB JS→iPad). There is NO
|
|
570
|
+
// inline shortcut any more, at any size. The inline envelope has no
|
|
571
|
+
// usable confirmation against a native peer — protoVersion is
|
|
572
|
+
// structurally 0 (no text-ack), the bare FileModel carries no
|
|
573
|
+
// deliveryId to ack, and the transport-ack signal (our send window
|
|
574
|
+
// draining) was FIELD-FALSIFIED at every scale: a 282-BYTE
|
|
575
|
+
// single-fragment PNG sat unconfirmed for 20s on the same session
|
|
576
|
+
// that streamed 100MB with 0.0% loss moments earlier. Routing small
|
|
577
|
+
// files inline just manufactured a daily stream of failed chips for
|
|
578
|
+
// images that had actually arrived. DNFT1's contiguous ack is the
|
|
579
|
+
// only true delivery signal a native can give us; the cost is one
|
|
580
|
+
// offer round trip.
|
|
615
581
|
// Add the "out" chip immediately as STATUS=sending (not "sent" — the
|
|
616
582
|
// transfer is reliable+acked, so it only flips to "sent" once the
|
|
617
583
|
// receiver confirms every byte). Progress/complete/cancel events patch
|
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.283";
|
|
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"/>',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/lan",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.283",
|
|
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",
|