@decentnetwork/lan 0.1.9 → 0.1.11
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.
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/daemon/server.js
CHANGED
|
@@ -90,21 +90,26 @@ export class DaemonServer {
|
|
|
90
90
|
// optional dora registration can decide our IP.
|
|
91
91
|
const keyFile = resolve(this.config.carrier.dataDir, "keypair.json");
|
|
92
92
|
this.peerManager = new PeerManager();
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
//
|
|
93
|
+
// Daemon does NOT use express nodes. decentlan is a virtual
|
|
94
|
+
// LAN — peers must be ONLINE for IP packets to flow. Express
|
|
95
|
+
// is an offline-message store-and-forward relay for chat-style
|
|
96
|
+
// apps; if we enable it, sendText silently falls back to a
|
|
97
|
+
// queue when a friend is offline. That creates the illusion of
|
|
98
|
+
// connectivity ("the daemon says X is reachable") while
|
|
99
|
+
// packets actually pile up in HTTPS storage and never get
|
|
100
|
+
// forwarded in real time. For a VPN-like data plane, that's
|
|
101
|
+
// wrong — better to fail fast and let the operator see the
|
|
102
|
+
// peer as offline.
|
|
103
|
+
//
|
|
104
|
+
// Friend-request bootstrap is the only thing that benefits
|
|
105
|
+
// from express; for that case use the standalone CLI
|
|
106
|
+
// `agentnet friend-request` (which DOES use express via its
|
|
107
|
+
// own short-lived Peer instance) and accept the request on
|
|
108
|
+
// both ends before bringing the daemon up.
|
|
104
109
|
await this.peerManager.create({
|
|
105
110
|
keyFile,
|
|
106
111
|
bootstrapNodes: this.config.carrier.bootstrapNodes,
|
|
107
|
-
expressNodes:
|
|
112
|
+
expressNodes: [],
|
|
108
113
|
});
|
|
109
114
|
await this.peerManager.start();
|
|
110
115
|
this.logger.info(`Identity: ${this.peerManager.getAddress()}`);
|
|
@@ -279,10 +284,21 @@ export class DaemonServer {
|
|
|
279
284
|
const autoAcceptFriends = this.config.friends?.autoAccept ?? true;
|
|
280
285
|
const pendingPath = resolve(this.config.carrier.dataDir, "..", "pending-friends.json");
|
|
281
286
|
this.pendingFriends = new PendingFriendsStore(pendingPath);
|
|
282
|
-
const pubkeyHexToUserid = async (
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
287
|
+
const pubkeyHexToUserid = async (input) => {
|
|
288
|
+
// The SDK's friend-request event hands us EITHER a 64-char
|
|
289
|
+
// hex pubkey OR a base58 userid directly, depending on
|
|
290
|
+
// version. Detect by character set: hex is exactly 64 chars
|
|
291
|
+
// of [0-9a-f]; otherwise treat input as already-base58 userid
|
|
292
|
+
// and pass through. This caught us when the SDK switched
|
|
293
|
+
// formats and decentlan crashed the daemon (unhandled
|
|
294
|
+
// throw from carrierIdFromPublicKey because the base58
|
|
295
|
+
// bytes-from-hex was the wrong length).
|
|
296
|
+
if (/^[0-9a-fA-F]{64}$/.test(input)) {
|
|
297
|
+
const { carrierIdFromPublicKey } = await import("@decentnetwork/peer");
|
|
298
|
+
const bytes = Buffer.from(input, "hex");
|
|
299
|
+
return carrierIdFromPublicKey(new Uint8Array(bytes));
|
|
300
|
+
}
|
|
301
|
+
return input;
|
|
286
302
|
};
|
|
287
303
|
this.peerManager.on("friend-request", (req) => {
|
|
288
304
|
void pubkeyHexToUserid(req.pubkey).then((userid) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/lan",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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",
|