@decentnetwork/peer 0.1.92 → 0.1.93
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 +24 -4
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -593,10 +593,8 @@ export class Peer {
|
|
|
593
593
|
};
|
|
594
594
|
}
|
|
595
595
|
async stop() {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
this.#tcpRelays = undefined;
|
|
599
|
-
}
|
|
596
|
+
// Stop background producers first so no keepalive/profile packet can race
|
|
597
|
+
// behind the shutdown notice and make the remote session look live again.
|
|
600
598
|
if (this.#expressPollTimer) {
|
|
601
599
|
clearInterval(this.#expressPollTimer);
|
|
602
600
|
this.#expressPollTimer = undefined;
|
|
@@ -613,6 +611,28 @@ export class Peer {
|
|
|
613
611
|
clearInterval(this.#friendConnectionTimer);
|
|
614
612
|
this.#friendConnectionTimer = undefined;
|
|
615
613
|
}
|
|
614
|
+
// Gracefully retire every established net_crypto session before closing
|
|
615
|
+
// UDP/TCP. The identity key survives an AgentNet restart but the ephemeral
|
|
616
|
+
// session key does not. Without PACKET_ID_KILL, a service node keeps the old
|
|
617
|
+
// established session and rejects the restarted daemon's new-key handshake
|
|
618
|
+
// until its liveness timeout expires (or the service node is restarted).
|
|
619
|
+
// Carrier/toxcore peers already handle KILL by deleting that one session, so
|
|
620
|
+
// this is wire-compatible with older holders and does not disturb any other
|
|
621
|
+
// friend served by an exit node.
|
|
622
|
+
const establishedFriends = [...this.#friendSessions.entries()]
|
|
623
|
+
.filter(([, session]) => session.established)
|
|
624
|
+
.map(([friendId]) => friendId);
|
|
625
|
+
if (establishedFriends.length > 0) {
|
|
626
|
+
await Promise.allSettled(establishedFriends.map((friendId) => this.#sendMessengerPacket(friendId, PACKET_ID_KILL, new Uint8Array())));
|
|
627
|
+
// TcpRelayClient.close() destroys its socket. Give queued relay writes a
|
|
628
|
+
// brief chance to reach the relay before tearing transports down. UDP and
|
|
629
|
+
// TURN sends have already been handed to their sockets at this point.
|
|
630
|
+
await sleep(250);
|
|
631
|
+
}
|
|
632
|
+
if (this.#tcpRelays) {
|
|
633
|
+
await this.#tcpRelays.stop().catch(() => { });
|
|
634
|
+
this.#tcpRelays = undefined;
|
|
635
|
+
}
|
|
616
636
|
this.#udp.off("datagram", this.#onDatagram);
|
|
617
637
|
await this.#udp.stop();
|
|
618
638
|
// Release the TURN allocation + its dedicated socket.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.93",
|
|
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",
|