@decentnetwork/peer 0.1.36 → 0.1.37
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 +10 -1
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -71,6 +71,15 @@ const FRIEND_PING_INTERVAL_MS = readEnvInt("DECENT_FRIEND_PING_INTERVAL_MS", 400
|
|
|
71
71
|
// slow enough not to burn CPU on idle peers. Tunable via env.
|
|
72
72
|
const FRIEND_CONNECTION_LOOP_MS = readEnvInt("DECENT_FRIEND_CONNECTION_LOOP_MS", 250);
|
|
73
73
|
const FRIEND_TIMEOUT_MS = readEnvInt("DECENT_FRIEND_TIMEOUT_MS", 32000);
|
|
74
|
+
// How long a relay path stays "confirmed" (carrying bulk data on its own, no
|
|
75
|
+
// tcp-relay fan-out) after the last packet received over it. The relay
|
|
76
|
+
// keepalive refreshes this every ~4s on a healthy path, so a generous window
|
|
77
|
+
// tolerates several missed keepalives on a high-RTT / lossy China<->abroad link
|
|
78
|
+
// instead of flapping back to fan-out — which delivered every IP packet twice
|
|
79
|
+
// (the lili DUP! storm). Still well under FRIEND_TIMEOUT_MS, so a relay that
|
|
80
|
+
// genuinely dies fails over (control packets always fan out, and the session
|
|
81
|
+
// times out + re-handshakes) within the friend-timeout regardless.
|
|
82
|
+
const RELAY_CONFIRM_WINDOW_MS = readEnvInt("DECENT_RELAY_CONFIRM_WINDOW_MS", 20000);
|
|
74
83
|
const LAN_DISCOVERY_INTERVAL_MS = readEnvInt("DECENT_LAN_DISCOVERY_INTERVAL_MS", 10000);
|
|
75
84
|
// When a same-LAN friend's actual address is unknown (it's not in their
|
|
76
85
|
// DHT-PK extras and their NAT-mapped public IP doesn't accept our UDP),
|
|
@@ -2747,7 +2756,7 @@ export class Peer {
|
|
|
2747
2756
|
let relayOk = false;
|
|
2748
2757
|
if (s?.relayRemote && s.relayPermitted) {
|
|
2749
2758
|
relayOk = this.#sendViaRelay(packet, s.relayRemote);
|
|
2750
|
-
const relayConfirmed = s.lastRelayRecvMs !== undefined && Date.now() - s.lastRelayRecvMs <
|
|
2759
|
+
const relayConfirmed = s.lastRelayRecvMs !== undefined && Date.now() - s.lastRelayRecvMs < RELAY_CONFIRM_WINDOW_MS;
|
|
2751
2760
|
if (isBulkData && relayOk && relayConfirmed) {
|
|
2752
2761
|
return;
|
|
2753
2762
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
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",
|