@decentnetwork/peer 0.1.107 → 0.1.109
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/compat/filetransfer.js +13 -1
- package/dist/peer.js +12 -8
- package/package.json +1 -1
|
@@ -119,6 +119,8 @@ const LAN_STARTUP_QUEUE_MS = 500; // unmistakable raw queue spike; smaller app-l
|
|
|
119
119
|
const LAN_STARTUP_HARD_QUEUE_MS = 2000; // one multi-second queue sample is unsafe
|
|
120
120
|
const LAN_STARTUP_QUEUE_ROUNDS = 2; // tolerate one scheduler/session-handover outlier on LAN
|
|
121
121
|
const LAN_STARTUP_KEEPUP = 0.70; // delivered goodput below 70% of pace means the receiver is no longer keeping up
|
|
122
|
+
const LAN_RECOVERY_GAIN = 1.20; // after a LAN overshoot drains, climb out of the 120KB/s floor quickly but smoothly
|
|
123
|
+
const LAN_RECOVERY_QUEUE_MS = 250; // only recover while queueing is clearly gone
|
|
122
124
|
// Five 200 ms samples was still only about one Windows ACK scheduling cycle in
|
|
123
125
|
// practice: a clean LAN (0% loss) exited STARTUP after ~3 MB and threw away a
|
|
124
126
|
// healthy 2.3 MB/s probe. Require a few seconds of sustained under-delivery;
|
|
@@ -923,8 +925,18 @@ export class FileTransferManager {
|
|
|
923
925
|
}
|
|
924
926
|
else {
|
|
925
927
|
// PROBE_BW cruise: one sample probes up, one drains, six cruise.
|
|
928
|
+
// If LAN STARTUP hit one real overshoot (e.g. a 1s ACK pause with
|
|
929
|
+
// high reported loss), the normal max-filter can be rebuilt from
|
|
930
|
+
// tiny post-drain samples and then takes tens of seconds to climb
|
|
931
|
+
// out of the 120KB/s floor. Once loss and queueing are gone, let
|
|
932
|
+
// a validated LAN recover toward its safe initial probe rate. The
|
|
933
|
+
// existing loss/queue brakes still stop a bad path immediately.
|
|
926
934
|
const gain = PACE_CYCLE_GAINS[st.roundCount % PACE_CYCLE_GAINS.length];
|
|
927
|
-
|
|
935
|
+
const cruiseRate = Math.max(PACE_INIT_BPS * 0.5, st.btlBwBps * gain * lossMult);
|
|
936
|
+
const healthyLan = lanNow && st.lossEwma < 0.02 && rawQueue < LAN_RECOVERY_QUEUE_MS;
|
|
937
|
+
st.paceRateBps = healthyLan
|
|
938
|
+
? Math.max(cruiseRate, Math.min(LAN_PACE_INIT_BPS, Math.max(st.paceRateBps * LAN_RECOVERY_GAIN, measuredRate * LAN_STARTUP_DELIVERY_GAIN)))
|
|
939
|
+
: cruiseRate;
|
|
928
940
|
}
|
|
929
941
|
// Hard safety cap: never pace faster than a full window drains in 1 RTT.
|
|
930
942
|
if (st.minRttMs !== Infinity && st.minRttMs > 0) {
|
package/dist/peer.js
CHANGED
|
@@ -2169,17 +2169,21 @@ export class Peer {
|
|
|
2169
2169
|
// syscall (that was the CCTV CPU regression) — safe at CCTV packet
|
|
2170
2170
|
// rates.
|
|
2171
2171
|
this.#adoptRemote(state, remote.address, remote.port);
|
|
2172
|
-
// A successfully decrypted packet arriving from a private address
|
|
2173
|
-
//
|
|
2174
|
-
//
|
|
2175
|
-
//
|
|
2176
|
-
//
|
|
2177
|
-
//
|
|
2178
|
-
//
|
|
2172
|
+
// A successfully decrypted packet arriving from a private address is
|
|
2173
|
+
// stronger proof than an endpoint hint: it demonstrates that this
|
|
2174
|
+
// exact host:port already reaches us. Do not require the address to be
|
|
2175
|
+
// in one of this process' physical subnets. WSL commonly has only a
|
|
2176
|
+
// 172.16/12 vNIC while the real LAN peer is 10.0.0.x via the Windows
|
|
2177
|
+
// host NAT; direct UDP is confirmed, but a strict same-subnet check
|
|
2178
|
+
// leaves file transfer on the conservative public/relay pacer.
|
|
2179
|
+
//
|
|
2180
|
+
// Unverified private candidates still require same-subnet matching at
|
|
2181
|
+
// candidate-learn time. This relaxed lock is only for decrypted UDP,
|
|
2182
|
+
// so it cannot promote a spoofed or merely advertised private host.
|
|
2179
2183
|
if (!state.lanRemoteHost &&
|
|
2180
2184
|
isPrivateAddress(remote.address) &&
|
|
2181
2185
|
!isCgnatAddress(remote.address) &&
|
|
2182
|
-
|
|
2186
|
+
!this.#isUnroutableSelfSource(remote.address, remote.port)) {
|
|
2183
2187
|
state.lanRemoteHost = remote.address;
|
|
2184
2188
|
this.#rememberEndpointCandidate(state, remote.address, remote.port);
|
|
2185
2189
|
this.#debugLog(`lan_lock_confirmed friend=${friendId} host=${remote.address}:${remote.port} (decrypted UDP source)`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.109",
|
|
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",
|