@decentnetwork/peer 0.1.16 → 0.1.17
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/peer.js +22 -18
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -889,14 +889,16 @@ export class Peer {
|
|
|
889
889
|
return;
|
|
890
890
|
}
|
|
891
891
|
this.#tracePacket("rx", packet, { host: remote.address, port: remote.port });
|
|
892
|
-
//
|
|
893
|
-
//
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
892
|
+
// Debug: log every inbound UDP datagram (gated on DECENT_ANNOUNCE_DEBUG)
|
|
893
|
+
// so we can see what bootstraps reply with. Off by default.
|
|
894
|
+
if (process.env.DECENT_ANNOUNCE_DEBUG === "1") {
|
|
895
|
+
import("fs").then((fs) => {
|
|
896
|
+
try {
|
|
897
|
+
fs.appendFileSync("/tmp/decent-udp-rx.log", `${new Date().toISOString()} from=${remote.address}:${remote.port} firstByte=0x${packet[0]?.toString(16) ?? "??"} len=${packet.length}\n`);
|
|
898
|
+
}
|
|
899
|
+
catch { /* best-effort */ }
|
|
900
|
+
}).catch(() => { });
|
|
901
|
+
}
|
|
900
902
|
if (packet[0] === NET_PACKET_CRYPTO) {
|
|
901
903
|
const opened = openToxDhtCryptoRequest(packet, this.#keyPair);
|
|
902
904
|
if (!opened) {
|
|
@@ -1987,11 +1989,12 @@ export class Peer {
|
|
|
1987
1989
|
catch { /* best-effort */ }
|
|
1988
1990
|
continue;
|
|
1989
1991
|
}
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1992
|
+
if (process.env.DECENT_ANNOUNCE_DEBUG === "1")
|
|
1993
|
+
try {
|
|
1994
|
+
const fs = await import("fs");
|
|
1995
|
+
fs.appendFileSync("/tmp/decent-announce.log", `${new Date().toISOString()} step1 from=${c.node.host}:${c.node.port} isStored=${resp1.isStored}\n`);
|
|
1996
|
+
}
|
|
1997
|
+
catch { /* best-effort */ }
|
|
1995
1998
|
step1Hits.push({ c, resp1 });
|
|
1996
1999
|
}
|
|
1997
2000
|
const step2Settled = await Promise.allSettled(step1Hits.map(({ c, resp1 }) => this.#sendAnnounceAndWait({
|
|
@@ -2011,11 +2014,12 @@ export class Peer {
|
|
|
2011
2014
|
const r2 = step2Settled[j];
|
|
2012
2015
|
const resp2 = r2.status === "fulfilled" ? r2.value : undefined;
|
|
2013
2016
|
const final = resp2 ?? resp1;
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2017
|
+
if (process.env.DECENT_ANNOUNCE_DEBUG === "1")
|
|
2018
|
+
try {
|
|
2019
|
+
const fs = await import("fs");
|
|
2020
|
+
fs.appendFileSync("/tmp/decent-announce.log", `${new Date().toISOString()} step2 from=${c.node.host}:${c.node.port} ${resp2 ? "isStored=" + resp2.isStored : "NO_RESPONSE"}\n`);
|
|
2021
|
+
}
|
|
2022
|
+
catch { /* best-effort */ }
|
|
2019
2023
|
if (final.isStored === 2) {
|
|
2020
2024
|
storedNodes.push(c.node);
|
|
2021
2025
|
// Keep dhtHealth.selfAnnounceStoredOn live within the loop,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Pure TypeScript port of Elastos Carrier (toxcore-derived) P2P messaging. DHT, onion routing, TCP relay, FlatBuffers app payloads, Express offline relay. Wire-compatible with iOS Beagle and the Carrier C SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|