@decentnetwork/peer 0.1.130 → 0.1.131

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 +20 -0
  2. package/package.json +1 -1
package/dist/peer.js CHANGED
@@ -4855,6 +4855,26 @@ export class Peer {
4855
4855
  if (this.#isUnroutableSelfSource(host, port, observed)) {
4856
4856
  return;
4857
4857
  }
4858
+ // An ADVERTISED private address is only usable if we are on that network.
4859
+ //
4860
+ // Same provenance rule as the self-address check above, one step wider: a
4861
+ // packet that ARRIVED from a private address proves the path exists, but a
4862
+ // peer merely listing one proves nothing — RFC1918 ranges are reused
4863
+ // everywhere. Seen in the field between tokyo (Japan) and a laptop at home:
4864
+ // tokyo adopted 10.0.0.245, an address that only means anything inside that
4865
+ // house, and sent every IP packet there. Friend online, session
4866
+ // established, transport "both", ping 100% loss.
4867
+ //
4868
+ // Only reached for advertised candidates, so the cached-but-not-free
4869
+ // getPhysicalLanSubnets() stays off the per-packet path (see the CCTV CPU
4870
+ // regression note on #isUnroutableSelfSource).
4871
+ if (!observed &&
4872
+ isPrivateAddress(host) &&
4873
+ !isCgnatAddress(host) &&
4874
+ !getPhysicalLanSubnets().some((sub) => isInIpv4Subnet(host, sub))) {
4875
+ this.#debugLog(`ignoring advertised private endpoint ${host}:${port} — not on any of our LANs`);
4876
+ return;
4877
+ }
4858
4878
  if (session.lanRemoteHost &&
4859
4879
  session.remote?.host === session.lanRemoteHost &&
4860
4880
  host !== session.lanRemoteHost &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.130",
3
+ "version": "0.1.131",
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",