@decentnetwork/peer 0.1.59 → 0.1.60

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.
Files changed (2) hide show
  1. package/dist/peer.js +15 -1
  2. package/package.json +1 -1
package/dist/peer.js CHANGED
@@ -4057,8 +4057,22 @@ export class Peer {
4057
4057
  const r = session.remote;
4058
4058
  const remoteIsSameLan = !!r && isPrivateAddress(r.host) && !isCgnatAddress(r.host) &&
4059
4059
  getPhysicalLanSubnets().some((s) => isInIpv4Subnet(r.host, s));
4060
- if (!remoteIsSameLan)
4060
+ if (!remoteIsSameLan) {
4061
+ // If we ALREADY hold a same-LAN candidate for this peer (learned from
4062
+ // an earlier offer), switch the session onto it NOW — don't wait to
4063
+ // receive yet another offer at exactly the right moment. That delay is
4064
+ // what kept sessions stuck on the public/Tailscale-hairpin path after
4065
+ // the staggered restarts. Then send a keepalive over the LAN so the
4066
+ // peer learns our LAN source and replies over it; the downgrade guard
4067
+ // keeps us there once it sticks.
4068
+ const lanCand = (session.endpointCandidates ?? []).find((c) => isPrivateAddress(c.host) && !isCgnatAddress(c.host) &&
4069
+ getPhysicalLanSubnets().some((s) => isInIpv4Subnet(c.host, s)));
4070
+ if (lanCand) {
4071
+ session.remote = { host: lanCand.host, port: lanCand.port };
4072
+ void this.#sendMessengerPacket(friendId, PACKET_ID_ALIVE, new Uint8Array()).catch(() => undefined);
4073
+ }
4061
4074
  void this.#sendUdpEndpointOffer(friendId).catch(() => undefined);
4075
+ }
4062
4076
  }
4063
4077
  }
4064
4078
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
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",