@torrent-tv/proxy 2.9.107 → 2.9.108
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/CHANGELOG.md +4 -0
- package/bin/cli.js +4 -1
- package/package.json +2 -3
- package/services/data-channel-handler.js +638 -542
- package/services/webrtc-manager.js +46 -1
|
@@ -429,5 +429,50 @@ export function createWebRtcManager({ sendSignal, onDataChannel, onLog, udpPort,
|
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
|
|
432
|
+
/**
|
|
433
|
+
* What the transport itself is doing for one session.
|
|
434
|
+
*
|
|
435
|
+
* The discriminator for a send queue that stops draining. `bufferedAmount`
|
|
436
|
+
* alone says only that bytes are stuck in OUR queue; these say whether they
|
|
437
|
+
* are leaving the machine:
|
|
438
|
+
*
|
|
439
|
+
* - `bytesSent` climbing while the queue climbs → packets ARE going out and
|
|
440
|
+
* nothing is acknowledging them: the path back is broken.
|
|
441
|
+
* - `bytesSent` flat while the queue climbs → SCTP is not transmitting at
|
|
442
|
+
* all: the peer's receive window is closed, or congestion control has
|
|
443
|
+
* collapsed. `bytesReceived` still climbing at the same time proves the
|
|
444
|
+
* peer is alive and its packets still reach us, i.e. the failure is
|
|
445
|
+
* one-directional.
|
|
446
|
+
* - both flat → nothing crosses in either direction.
|
|
447
|
+
*
|
|
448
|
+
* @param {string} sessionId
|
|
449
|
+
* @returns {{ bytesSent: number, bytesReceived: number, rtt: number, pair: string, state: string, iceState: string } | null}
|
|
450
|
+
*/
|
|
451
|
+
function getTransportSnapshot(sessionId) {
|
|
452
|
+
const pc = peers.get(sessionId);
|
|
453
|
+
if (!pc) {
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
const read = (fn, fallback) => {
|
|
457
|
+
try {
|
|
458
|
+
return fn();
|
|
459
|
+
} catch {
|
|
460
|
+
return fallback;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
const pair = read(() => pc.getSelectedCandidatePair(), null);
|
|
464
|
+
return {
|
|
465
|
+
bytesSent: read(() => pc.bytesSent(), -1),
|
|
466
|
+
bytesReceived: read(() => pc.bytesReceived(), -1),
|
|
467
|
+
rtt: read(() => pc.rtt(), -1),
|
|
468
|
+
pair: pair
|
|
469
|
+
? `${pair.local?.address}:${pair.local?.port}->${pair.remote?.address}:${pair.remote?.port}` +
|
|
470
|
+
` (${pair.local?.type}/${pair.remote?.type})`
|
|
471
|
+
: "none",
|
|
472
|
+
state: read(() => pc.state(), "?"),
|
|
473
|
+
iceState: read(() => pc.iceState(), "?")
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return { handleSignal, closeSession, dispose, getTransportSnapshot };
|
|
433
478
|
}
|