@decentnetwork/peer 0.1.10 → 0.1.12

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.d.ts CHANGED
@@ -37,6 +37,17 @@ export declare class Peer {
37
37
  selfAnnounceStoredOn: number;
38
38
  udpLocalPort: number | null;
39
39
  tcpRelayConnected: number;
40
+ /** The specific relay endpoints this peer has live connections to.
41
+ * Lets us compare two peers' relay sets — if there's NO overlap,
42
+ * net_crypto handshake packets between them have nowhere to route
43
+ * via the TCP fallback path. This is the most common "session
44
+ * established=False forever on the WAN" failure mode after
45
+ * restart waves: peers picked different relays from the bootstrap
46
+ * pool. Surfacing this lets diag pinpoint it. */
47
+ tcpRelayEndpoints: Array<{
48
+ host: string;
49
+ port: number;
50
+ }>;
40
51
  };
41
52
  addKnownNodes(nodes: NetworkNode[]): void;
42
53
  knownNodes(): NetworkNode[];
package/dist/peer.js CHANGED
@@ -452,13 +452,15 @@ export class Peer {
452
452
  * through even when DHT is dead.
453
453
  */
454
454
  dhtHealth() {
455
+ const relays = this.#tcpRelays?.connectedRelays(99) ?? [];
455
456
  return {
456
457
  bootstrapsConfigured: this.#opts.bootstrapNodes.length,
457
458
  knownNodesCount: this.#knownNodes.length,
458
459
  lastSelfAnnounceMs: this.#lastSelfAnnounceMs,
459
460
  selfAnnounceStoredOn: this.#lastSelfAnnounceStoredCount,
460
461
  udpLocalPort: this.#udp?.localPort() ?? null,
461
- tcpRelayConnected: this.#tcpRelays?.connectedRelays(99).length ?? 0,
462
+ tcpRelayConnected: relays.length,
463
+ tcpRelayEndpoints: relays.map((r) => ({ host: r.host, port: r.port })),
462
464
  };
463
465
  }
464
466
  addKnownNodes(nodes) {
@@ -1972,7 +1974,12 @@ export class Peer {
1972
1974
  this.#debugLog(`self announce step1 no response from ${c.node.host}:${c.node.port}`);
1973
1975
  continue;
1974
1976
  }
1975
- this.#debugLog(`self announce step1 response from ${c.node.host}:${c.node.port} isStored=${resp1.isStored}`);
1977
+ // Promoted to console.log so we can see what bootstraps respond
1978
+ // without needing DECENT_DEBUG=1 set up at process launch.
1979
+ // selfAnnounceStoredOn has been stuck at 0 across all peers and
1980
+ // we need to see whether step1 itself fails or just step2.
1981
+ // Temporary — to be reverted once UDP is actually working.
1982
+ console.log(`[announce-step1] from=${c.node.host}:${c.node.port} isStored=${resp1.isStored}`);
1976
1983
  step1Hits.push({ c, resp1 });
1977
1984
  }
1978
1985
  const step2Settled = await Promise.allSettled(step1Hits.map(({ c, resp1 }) => this.#sendAnnounceAndWait({
@@ -1993,7 +2000,10 @@ export class Peer {
1993
2000
  const resp2 = r2.status === "fulfilled" ? r2.value : undefined;
1994
2001
  const final = resp2 ?? resp1;
1995
2002
  if (resp2) {
1996
- this.#debugLog(`self announce step2 response from ${c.node.host}:${c.node.port} isStored=${resp2.isStored}`);
2003
+ console.log(`[announce-step2] from=${c.node.host}:${c.node.port} isStored=${resp2.isStored}`);
2004
+ }
2005
+ else {
2006
+ console.log(`[announce-step2] from=${c.node.host}:${c.node.port} NO_RESPONSE`);
1997
2007
  }
1998
2008
  if (final.isStored === 2) {
1999
2009
  storedNodes.push(c.node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
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",