@decentnetwork/peer 0.1.133 → 0.1.134
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 +18 -1
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -5206,7 +5206,24 @@ export class Peer {
|
|
|
5206
5206
|
// Permit the advertised private candidate when both peers share the same
|
|
5207
5207
|
// public NAT; if it is a CGNAT/private collision and never validates, the
|
|
5208
5208
|
// normal 12s stale-LAN-lock breaker restores the public/relay path.
|
|
5209
|
-
|
|
5209
|
+
// "We share one NAT" — the only reason to trust a peer's private address
|
|
5210
|
+
// without checking our own subnets.
|
|
5211
|
+
//
|
|
5212
|
+
// It requires that we are actually BEHIND a NAT. A node with a public IP
|
|
5213
|
+
// has srflx == its own address, so the naive comparison matched every
|
|
5214
|
+
// offer whose observed source was that same address (relayed or
|
|
5215
|
+
// reflected through us), and the subnet check below was bypassed for any
|
|
5216
|
+
// private host at all. tokyo, on a public IP, took 10.0.0.245 from a
|
|
5217
|
+
// laptop across the Pacific this way and pinned its session to it —
|
|
5218
|
+
// re-adopting it within seconds of every self-heal, because this path
|
|
5219
|
+
// writes session.remote directly and never goes through #adoptRemote.
|
|
5220
|
+
//
|
|
5221
|
+
// Behind a NAT, srflx is the NAT's address and differs from every local
|
|
5222
|
+
// interface, so the extra test costs nothing there and closes the hole
|
|
5223
|
+
// for public hosts.
|
|
5224
|
+
const srflxHost = this.#srflxCache?.addr.host;
|
|
5225
|
+
const weAreBehindNat = !!srflxHost && !getPhysicalLanAddresses().includes(srflxHost);
|
|
5226
|
+
const samePublicNat = weAreBehindNat && srflxHost === host;
|
|
5210
5227
|
const sameLan = lanPort !== 0 &&
|
|
5211
5228
|
isPrivateAddress(lanHost) &&
|
|
5212
5229
|
!isCgnatAddress(lanHost) &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.134",
|
|
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",
|