werift 0.27.0 → 0.29.0
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/README.md +299 -8
- package/lib/common/src/event.d.ts +26 -0
- package/lib/common/src/event.js +87 -2
- package/lib/common/src/event.js.map +1 -1
- package/lib/common/src/network.d.ts +6 -1
- package/lib/common/src/network.js +8 -2
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/transport.d.ts +51 -10
- package/lib/common/src/transport.js +35 -9
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/alert.d.ts +49 -0
- package/lib/dtls/src/alert.js +103 -0
- package/lib/dtls/src/alert.js.map +1 -0
- package/lib/dtls/src/carrier/direct.d.ts +67 -0
- package/lib/dtls/src/carrier/direct.js +226 -0
- package/lib/dtls/src/carrier/direct.js.map +1 -0
- package/lib/dtls/src/carrier/types.d.ts +81 -0
- package/lib/dtls/src/carrier/types.js +7 -0
- package/lib/dtls/src/carrier/types.js.map +1 -0
- package/lib/dtls/src/cipher/const.d.ts +6 -0
- package/lib/dtls/src/cipher/const.js +13 -2
- package/lib/dtls/src/cipher/const.js.map +1 -1
- package/lib/dtls/src/cipher/prf.js +11 -2
- package/lib/dtls/src/cipher/prf.js.map +1 -1
- package/lib/dtls/src/cipher/tls13/aead.d.ts +41 -0
- package/lib/dtls/src/cipher/tls13/aead.js +128 -0
- package/lib/dtls/src/cipher/tls13/aead.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/hkdf.d.ts +30 -0
- package/lib/dtls/src/cipher/tls13/hkdf.js +76 -0
- package/lib/dtls/src/cipher/tls13/hkdf.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.d.ts +70 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.js +114 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/signature.d.ts +30 -0
- package/lib/dtls/src/cipher/tls13/signature.js +149 -0
- package/lib/dtls/src/cipher/tls13/signature.js.map +1 -0
- package/lib/dtls/src/client.d.ts +253 -0
- package/lib/dtls/src/client.js +1269 -14
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +47 -0
- package/lib/dtls/src/context/dtls.js +121 -0
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +30 -1
- package/lib/dtls/src/context/transport.js +67 -3
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/engine/v1_3/connection-base.d.ts +520 -0
- package/lib/dtls/src/engine/v1_3/connection-base.js +1644 -0
- package/lib/dtls/src/engine/v1_3/connection-base.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/connection.d.ts +181 -0
- package/lib/dtls/src/engine/v1_3/connection.js +680 -0
- package/lib/dtls/src/engine/v1_3/connection.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.d.ts +38 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.js +166 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.d.ts +4 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.js +62 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.d.ts +8 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.js +119 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.d.ts +8 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.js +251 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.d.ts +5 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.js +99 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.d.ts +12 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.js +138 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.d.ts +13 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.js +46 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.d.ts +6 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.js +16 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.d.ts +12 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.js +94 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.d.ts +21 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.js +227 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.d.ts +6 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.js +455 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.d.ts +5 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.js +48 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.d.ts +119 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.js +782 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/host.d.ts +86 -0
- package/lib/dtls/src/engine/v1_3/host.js +11 -0
- package/lib/dtls/src/engine/v1_3/host.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/record-rx.d.ts +77 -0
- package/lib/dtls/src/engine/v1_3/record-rx.js +818 -0
- package/lib/dtls/src/engine/v1_3/record-rx.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/transcript.d.ts +22 -0
- package/lib/dtls/src/engine/v1_3/transcript.js +65 -0
- package/lib/dtls/src/engine/v1_3/transcript.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/types.d.ts +169 -0
- package/lib/dtls/src/engine/v1_3/types.js +113 -0
- package/lib/dtls/src/engine/v1_3/types.js.map +1 -0
- package/lib/dtls/src/flight/client/flight1.d.ts +7 -1
- package/lib/dtls/src/flight/client/flight1.js +9 -3
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight3.d.ts +8 -0
- package/lib/dtls/src/flight/client/flight3.js +24 -4
- package/lib/dtls/src/flight/client/flight3.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +17 -2
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +21 -0
- package/lib/dtls/src/flight/flight.js +119 -9
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/commitClientHello.d.ts +35 -0
- package/lib/dtls/src/flight/server/commitClientHello.js +149 -0
- package/lib/dtls/src/flight/server/commitClientHello.js.map +1 -0
- package/lib/dtls/src/flight/server/flight2.d.ts +12 -3
- package/lib/dtls/src/flight/server/flight2.js +29 -105
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.js +14 -2
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +12 -1
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +10 -0
- package/lib/dtls/src/handshake/const.js +10 -0
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/cookie.d.ts +113 -0
- package/lib/dtls/src/handshake/extensions/cookie.js +326 -0
- package/lib/dtls/src/handshake/extensions/cookie.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/ids.d.ts +7 -0
- package/lib/dtls/src/handshake/extensions/ids.js +11 -0
- package/lib/dtls/src/handshake/extensions/ids.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/keyShare.d.ts +28 -0
- package/lib/dtls/src/handshake/extensions/keyShare.js +156 -0
- package/lib/dtls/src/handshake/extensions/keyShare.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.d.ts +27 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.js +67 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.d.ts +20 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.js +90 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/unique.d.ts +7 -0
- package/lib/dtls/src/handshake/extensions/unique.js +19 -0
- package/lib/dtls/src/handshake/extensions/unique.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/useSrtp.d.ts +26 -3
- package/lib/dtls/src/handshake/extensions/useSrtp.js +68 -12
- package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
- package/lib/dtls/src/handshake/message/tls13/ack.d.ts +50 -0
- package/lib/dtls/src/handshake/message/tls13/ack.js +107 -0
- package/lib/dtls/src/handshake/message/tls13/ack.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.d.ts +17 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.js +112 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.d.ts +17 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.js +99 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.d.ts +21 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.js +77 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.d.ts +19 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.js +56 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.d.ts +13 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.js +54 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.d.ts +33 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.js +158 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.js.map +1 -0
- package/lib/dtls/src/handshake/random.d.ts +14 -0
- package/lib/dtls/src/handshake/random.js +24 -0
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/handshake/validation.d.ts +26 -0
- package/lib/dtls/src/handshake/validation.js +32 -0
- package/lib/dtls/src/handshake/validation.js.map +1 -0
- package/lib/dtls/src/index.d.ts +8 -1
- package/lib/dtls/src/index.js +125 -44
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/internal.d.ts +7 -0
- package/lib/dtls/src/internal.js +57 -0
- package/lib/dtls/src/internal.js.map +1 -0
- package/lib/dtls/src/peer.d.ts +49 -0
- package/lib/dtls/src/peer.js +54 -0
- package/lib/dtls/src/peer.js.map +1 -0
- package/lib/dtls/src/record/antiReplayWindow.d.ts +33 -0
- package/lib/dtls/src/record/antiReplayWindow.js +119 -0
- package/lib/dtls/src/record/antiReplayWindow.js.map +1 -0
- package/lib/dtls/src/record/const.d.ts +15 -0
- package/lib/dtls/src/record/const.js +15 -1
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.d.ts +0 -2
- package/lib/dtls/src/record/message/fragment.js +36 -17
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/reassembler.d.ts +62 -0
- package/lib/dtls/src/record/message/reassembler.js +249 -0
- package/lib/dtls/src/record/message/reassembler.js.map +1 -0
- package/lib/dtls/src/record/receive.d.ts +6 -0
- package/lib/dtls/src/record/receive.js +58 -19
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/record/v1_3/header.d.ts +34 -0
- package/lib/dtls/src/record/v1_3/header.js +95 -0
- package/lib/dtls/src/record/v1_3/header.js.map +1 -0
- package/lib/dtls/src/record/v1_3/record.d.ts +133 -0
- package/lib/dtls/src/record/v1_3/record.js +370 -0
- package/lib/dtls/src/record/v1_3/record.js.map +1 -0
- package/lib/dtls/src/retransmission.d.ts +26 -0
- package/lib/dtls/src/retransmission.js +39 -0
- package/lib/dtls/src/retransmission.js.map +1 -0
- package/lib/dtls/src/server.d.ts +38 -0
- package/lib/dtls/src/server.js +382 -17
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +487 -11
- package/lib/dtls/src/socket.js +1359 -70
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/dtls/src/version.d.ts +89 -0
- package/lib/dtls/src/version.js +204 -0
- package/lib/dtls/src/version.js.map +1 -0
- package/lib/ice/src/candidateError.d.ts +155 -0
- package/lib/ice/src/candidateError.js +246 -0
- package/lib/ice/src/candidateError.js.map +1 -0
- package/lib/ice/src/candidateGatherer.d.ts +127 -0
- package/lib/ice/src/candidateGatherer.js +745 -0
- package/lib/ice/src/candidateGatherer.js.map +1 -0
- package/lib/ice/src/consent.d.ts +126 -0
- package/lib/ice/src/consent.js +470 -0
- package/lib/ice/src/consent.js.map +1 -0
- package/lib/ice/src/dns/lookup.d.ts +10 -0
- package/lib/ice/src/dns/lookup.js +130 -3
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +9 -0
- package/lib/ice/src/exceptions.js +14 -1
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/failover.d.ts +270 -0
- package/lib/ice/src/failover.js +674 -0
- package/lib/ice/src/failover.js.map +1 -0
- package/lib/ice/src/gatheringError.d.ts +28 -0
- package/lib/ice/src/gatheringError.js +17 -0
- package/lib/ice/src/gatheringError.js.map +1 -0
- package/lib/ice/src/ice.d.ts +486 -78
- package/lib/ice/src/ice.js +2415 -1129
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +404 -14
- package/lib/ice/src/iceBase.js +251 -38
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +3 -0
- package/lib/ice/src/index.js +5 -1
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/checkMessages.d.ts +41 -0
- package/lib/ice/src/internal/checkMessages.js +63 -0
- package/lib/ice/src/internal/checkMessages.js.map +1 -0
- package/lib/ice/src/internal/datagram.d.ts +37 -0
- package/lib/ice/src/internal/datagram.js +45 -0
- package/lib/ice/src/internal/datagram.js.map +1 -0
- package/lib/ice/src/internal/defaultRoute.d.ts +20 -0
- package/lib/ice/src/internal/defaultRoute.js +134 -0
- package/lib/ice/src/internal/defaultRoute.js.map +1 -0
- package/lib/ice/src/internal/hostInterfaces.d.ts +28 -0
- package/lib/ice/src/internal/hostInterfaces.js +89 -0
- package/lib/ice/src/internal/hostInterfaces.js.map +1 -0
- package/lib/ice/src/internal/hostPreference.d.ts +24 -0
- package/lib/ice/src/internal/hostPreference.js +38 -0
- package/lib/ice/src/internal/hostPreference.js.map +1 -0
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +56 -8
- package/lib/ice/src/internal/resolveHostAddresses.js +127 -24
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -1
- package/lib/ice/src/internal/selectAddresses.d.ts +27 -0
- package/lib/ice/src/internal/selectAddresses.js +37 -18
- package/lib/ice/src/internal/selectAddresses.js.map +1 -1
- package/lib/ice/src/internal/sped-bind.d.ts +44 -0
- package/lib/ice/src/internal/sped-bind.js +53 -0
- package/lib/ice/src/internal/sped-bind.js.map +1 -0
- package/lib/ice/src/internal/sped-binding-cache.d.ts +27 -0
- package/lib/ice/src/internal/sped-binding-cache.js +102 -0
- package/lib/ice/src/internal/sped-binding-cache.js.map +1 -0
- package/lib/ice/src/internal/sped.d.ts +15 -0
- package/lib/ice/src/internal/sped.js +62 -0
- package/lib/ice/src/internal/sped.js.map +1 -0
- package/lib/ice/src/nomination/regularNomination.d.ts +200 -0
- package/lib/ice/src/nomination/regularNomination.js +311 -0
- package/lib/ice/src/nomination/regularNomination.js.map +1 -0
- package/lib/ice/src/nomination/selectionController.d.ts +111 -0
- package/lib/ice/src/nomination/selectionController.js +172 -0
- package/lib/ice/src/nomination/selectionController.js.map +1 -0
- package/lib/ice/src/nomination/selectionReplacement.d.ts +178 -0
- package/lib/ice/src/nomination/selectionReplacement.js +429 -0
- package/lib/ice/src/nomination/selectionReplacement.js.map +1 -0
- package/lib/ice/src/provisional.d.ts +139 -0
- package/lib/ice/src/provisional.js +468 -0
- package/lib/ice/src/provisional.js.map +1 -0
- package/lib/ice/src/sped/draft00/codec.d.ts +20 -0
- package/lib/ice/src/sped/draft00/codec.js +59 -0
- package/lib/ice/src/sped/draft00/codec.js.map +1 -0
- package/lib/ice/src/sped/draft00/constants.d.ts +14 -0
- package/lib/ice/src/sped/draft00/constants.js +18 -0
- package/lib/ice/src/sped/draft00/constants.js.map +1 -0
- package/lib/ice/src/sped/draft00/index.d.ts +6 -0
- package/lib/ice/src/sped/draft00/index.js +26 -0
- package/lib/ice/src/sped/draft00/index.js.map +1 -0
- package/lib/ice/src/sped/draft00/mtu.d.ts +38 -0
- package/lib/ice/src/sped/draft00/mtu.js +96 -0
- package/lib/ice/src/sped/draft00/mtu.js.map +1 -0
- package/lib/ice/src/sped/draft00/session.d.ts +86 -0
- package/lib/ice/src/sped/draft00/session.js +353 -0
- package/lib/ice/src/sped/draft00/session.js.map +1 -0
- package/lib/ice/src/sped/draft00/types.d.ts +16 -0
- package/lib/ice/src/sped/draft00/types.js +3 -0
- package/lib/ice/src/sped/draft00/types.js.map +1 -0
- package/lib/ice/src/sped/runtime.d.ts +188 -0
- package/lib/ice/src/sped/runtime.js +643 -0
- package/lib/ice/src/sped/runtime.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +38 -2
- package/lib/ice/src/stun/protocol.js +107 -21
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/rawAttributeValue.d.ts +1 -0
- package/lib/ice/src/stun/rawAttributeValue.js +6 -0
- package/lib/ice/src/stun/rawAttributeValue.js.map +1 -0
- package/lib/ice/src/stun/tcpProtocol.d.ts +2 -1
- package/lib/ice/src/stun/tcpProtocol.js +21 -9
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +4 -0
- package/lib/ice/src/stun/transaction.js +27 -2
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/protocol.d.ts +23 -4
- package/lib/ice/src/turn/protocol.js +99 -11
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +25 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice/src/utils.d.ts +13 -0
- package/lib/ice/src/utils.js +13 -0
- package/lib/ice/src/utils.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.js +4 -0
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +20 -1
- package/lib/ice-server/src/stun/const.js +9 -1
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +43 -3
- package/lib/ice-server/src/stun/message.js +258 -40
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/ice-server/src/stun/rawAttributeValue.d.ts +6 -0
- package/lib/ice-server/src/stun/rawAttributeValue.js +12 -0
- package/lib/ice-server/src/stun/rawAttributeValue.js.map +1 -0
- package/lib/index.mjs +47427 -25303
- package/lib/nonstandard/index.mjs +3076 -1318
- package/lib/polyfill/dom.mjs +40430 -18730
- package/lib/polyfill/index.mjs +40333 -18639
- package/lib/rtp/src/extra/processor/fsRetry.d.ts +20 -0
- package/lib/rtp/src/extra/processor/fsRetry.js +73 -0
- package/lib/rtp/src/extra/processor/fsRetry.js.map +1 -0
- package/lib/rtp/src/extra/processor/webm.d.ts +6 -0
- package/lib/rtp/src/extra/processor/webm.js +6 -2
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.d.ts +11 -0
- package/lib/rtp/src/extra/processor/webmCallback.js +23 -31
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmFileWriter.d.ts +24 -0
- package/lib/rtp/src/extra/processor/webmFileWriter.js +94 -0
- package/lib/rtp/src/extra/processor/webmFileWriter.js.map +1 -0
- package/lib/rtp/src/index.d.ts +1 -0
- package/lib/rtp/src/index.js +1 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +14 -1
- package/lib/rtp/src/rtp/continuity.js +24 -4
- package/lib/rtp/src/rtp/continuity.js.map +1 -1
- package/lib/rtp/src/rtp/timelineRewriter.d.ts +178 -0
- package/lib/rtp/src/rtp/timelineRewriter.js +417 -0
- package/lib/rtp/src/rtp/timelineRewriter.js.map +1 -0
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +10 -0
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/index.d.ts +1 -1
- package/lib/sctp/src/index.js +4 -1
- package/lib/sctp/src/index.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +86 -5
- package/lib/sctp/src/sctp.js +354 -75
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +43 -0
- package/lib/webrtc/src/api/compatibilityOptions.js +43 -0
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
- package/lib/webrtc/src/api/peerConfig.d.ts +547 -36
- package/lib/webrtc/src/api/peerConfig.js +187 -26
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +87 -2
- package/lib/webrtc/src/api/peerConnectionEvents.js +105 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +122 -10
- package/lib/webrtc/src/dataChannel.js +214 -20
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/helper.d.ts +8 -0
- package/lib/webrtc/src/helper.js +40 -4
- package/lib/webrtc/src/helper.js.map +1 -1
- package/lib/webrtc/src/media/codecCompatibility.d.ts +87 -1
- package/lib/webrtc/src/media/codecCompatibility.js +338 -12
- package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
- package/lib/webrtc/src/media/domEventTarget.d.ts +55 -0
- package/lib/webrtc/src/media/domEventTarget.js +216 -0
- package/lib/webrtc/src/media/domEventTarget.js.map +1 -0
- package/lib/webrtc/src/media/index.d.ts +2 -0
- package/lib/webrtc/src/media/index.js +1 -0
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/parameters.d.ts +5 -0
- package/lib/webrtc/src/media/parameters.js +10 -0
- package/lib/webrtc/src/media/parameters.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
- package/lib/webrtc/src/media/receiver/nack.js +245 -88
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +10 -0
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +4 -10
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +245 -51
- package/lib/webrtc/src/media/router.js +702 -237
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/routing/pendingRoutes.d.ts +26 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js +48 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js.map +1 -0
- package/lib/webrtc/src/media/routing/ridRouting.d.ts +37 -0
- package/lib/webrtc/src/media/routing/ridRouting.js +74 -0
- package/lib/webrtc/src/media/routing/ridRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/routeTable.d.ts +60 -0
- package/lib/webrtc/src/media/routing/routeTable.js +95 -0
- package/lib/webrtc/src/media/routing/routeTable.js.map +1 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.d.ts +34 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js +165 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.d.ts +55 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js +117 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js.map +1 -0
- package/lib/webrtc/src/media/rtpReceiver.d.ts +277 -5
- package/lib/webrtc/src/media/rtpReceiver.js +826 -36
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +8 -1
- package/lib/webrtc/src/media/rtpSender.js +13 -6
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +47 -11
- package/lib/webrtc/src/media/rtpTransceiver.js +95 -11
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderReportHistory.d.ts +51 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js +111 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderStats.d.ts +6 -5
- package/lib/webrtc/src/media/sender/senderStats.js +14 -19
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -1
- package/lib/webrtc/src/media/stats.d.ts +13 -0
- package/lib/webrtc/src/media/stats.js.map +1 -1
- package/lib/webrtc/src/media/track.d.ts +112 -11
- package/lib/webrtc/src/media/track.js +250 -19
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/media/trackConstraints.d.ts +80 -0
- package/lib/webrtc/src/media/trackConstraints.js +141 -0
- package/lib/webrtc/src/media/trackConstraints.js.map +1 -0
- package/lib/webrtc/src/negotiation/internalState.d.ts +0 -4
- package/lib/webrtc/src/negotiation/internalState.js +0 -11
- package/lib/webrtc/src/negotiation/internalState.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.d.ts +20 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js +29 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +23 -6
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +46 -22
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
- package/lib/webrtc/src/negotiation/transceiverPairing.d.ts +1 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js +62 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +12 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +133 -11
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +57 -5
- package/lib/webrtc/src/negotiationTransaction.js +134 -10
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.d.ts +6 -0
- package/lib/webrtc/src/nonstandard/dummyMedia.js +14 -19
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.js +5 -1
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +6 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +31 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +16 -0
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js +25 -0
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.js +6 -13
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +106 -11
- package/lib/webrtc/src/peerConnection.js +370 -36
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/api.d.ts +2 -1
- package/lib/webrtc/src/polyfill/api.js +3 -3
- package/lib/webrtc/src/polyfill/api.js.map +1 -1
- package/lib/webrtc/src/polyfill/dom.d.ts +21 -7
- package/lib/webrtc/src/polyfill/dom.js +15 -0
- package/lib/webrtc/src/polyfill/dom.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +8 -3
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/index.d.ts +1 -1
- package/lib/webrtc/src/polyfill/index.js +1 -1
- package/lib/webrtc/src/polyfill/index.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.d.ts +5 -1
- package/lib/webrtc/src/polyfill/install.js +4 -2
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +28 -4
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/polyfill/peerConnectionConfig.d.ts +6 -0
- package/lib/webrtc/src/polyfill/peerConnectionConfig.js +15 -4
- package/lib/webrtc/src/polyfill/peerConnectionConfig.js.map +1 -1
- package/lib/webrtc/src/polyfill/selectSettings.d.ts +4 -14
- package/lib/webrtc/src/polyfill/selectSettings.js +10 -106
- package/lib/webrtc/src/polyfill/selectSettings.js.map +1 -1
- package/lib/webrtc/src/polyfill/sourceIo.d.ts +1 -2
- package/lib/webrtc/src/polyfill/sourceIo.js +6 -6
- package/lib/webrtc/src/polyfill/sourceIo.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +31 -18
- package/lib/webrtc/src/sctpManager.js +162 -38
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +107 -2
- package/lib/webrtc/src/sdp.js +223 -17
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +101 -10
- package/lib/webrtc/src/sdpManager.js +236 -14
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +49 -3
- package/lib/webrtc/src/secureTransportManager.js +166 -12
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +87 -6
- package/lib/webrtc/src/transceiverManager.js +272 -51
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls-application-gate.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-application-gate.js +143 -0
- package/lib/webrtc/src/transport/dtls-application-gate.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-attempt.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-attempt.js +79 -0
- package/lib/webrtc/src/transport/dtls-attempt.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-certificate.d.ts +24 -0
- package/lib/webrtc/src/transport/dtls-certificate.js +98 -0
- package/lib/webrtc/src/transport/dtls-certificate.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.d.ts +7 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.js +66 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.js +123 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-media-queue.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-media-queue.js +95 -0
- package/lib/webrtc/src/transport/dtls-media-queue.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-readiness.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-readiness.js +173 -0
- package/lib/webrtc/src/transport/dtls-readiness.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.js +146 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-srtp.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-srtp.js +133 -0
- package/lib/webrtc/src/transport/dtls-srtp.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-stats.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-stats.js +134 -0
- package/lib/webrtc/src/transport/dtls-stats.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-types.d.ts +23 -0
- package/lib/webrtc/src/transport/dtls-types.js +11 -0
- package/lib/webrtc/src/transport/dtls-types.js.map +1 -0
- package/lib/webrtc/src/transport/dtls.d.ts +236 -47
- package/lib/webrtc/src/transport/dtls.js +1198 -441
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +95 -5
- package/lib/webrtc/src/transport/ice.js +323 -21
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/iceCandidateAttribute.d.ts +4 -2
- package/lib/webrtc/src/transport/iceCandidateAttribute.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +149 -2
- package/lib/webrtc/src/transport/sctp.js +826 -128
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/transport/sped.d.ts +139 -0
- package/lib/webrtc/src/transport/sped.js +757 -0
- package/lib/webrtc/src/transport/sped.js.map +1 -0
- package/lib/webrtc/src/types/util.d.ts +6 -0
- package/lib/webrtc/src/types/util.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +34 -1
- package/lib/webrtc/src/utils.js +52 -3
- package/lib/webrtc/src/utils.js.map +1 -1
- package/lib/webrtc/src/webidl.d.ts +15 -0
- package/lib/webrtc/src/webidl.js +34 -0
- package/lib/webrtc/src/webidl.js.map +1 -0
- package/package.json +8 -3
- package/lib/webrtc/src/polyfill/rtcSessionDescription.d.ts +0 -18
- package/lib/webrtc/src/polyfill/rtcSessionDescription.js +0 -36
- package/lib/webrtc/src/polyfill/rtcSessionDescription.js.map +0 -1
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FailoverMonitor = exports.nextPingAt = exports.backupPingInterval = exports.isNotReceiving = exports.notReceivingSince = exports.isWeak = exports.isWritable = exports.isUnwritable = exports.resolveFailoverThresholds = exports.DEFAULT_FAILOVER_THRESHOLDS = void 0;
|
|
4
|
+
const iceBase_1 = require("./iceBase");
|
|
5
|
+
/** The defaults of {@link IceFailoverOptions} (libwebrtc's values). */
|
|
6
|
+
exports.DEFAULT_FAILOVER_THRESHOLDS = Object.freeze({
|
|
7
|
+
unwritableMinChecks: iceBase_1.CONNECTION_WRITE_CONNECT_FAILURES,
|
|
8
|
+
unwritableTimeout: iceBase_1.CONNECTION_WRITE_CONNECT_TIMEOUT,
|
|
9
|
+
receivingTimeout: iceBase_1.WEAK_CONNECTION_RECEIVE_TIMEOUT,
|
|
10
|
+
receivingSwitchingDelay: iceBase_1.RECEIVING_SWITCHING_DELAY,
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* {@link IceFailoverOptions} with its defaults: an unset or invalid value
|
|
14
|
+
* (not finite, out of range, a fractional check count) keeps the default.
|
|
15
|
+
*/
|
|
16
|
+
const resolveFailoverThresholds = (options) => {
|
|
17
|
+
const pick = (value, fallback, valid) => typeof value === "number" && Number.isFinite(value) && valid(value)
|
|
18
|
+
? value
|
|
19
|
+
: fallback;
|
|
20
|
+
const defaults = exports.DEFAULT_FAILOVER_THRESHOLDS;
|
|
21
|
+
return {
|
|
22
|
+
unwritableMinChecks: pick(options?.unwritableMinChecks, defaults.unwritableMinChecks, (value) => Number.isInteger(value) && value >= 1),
|
|
23
|
+
unwritableTimeout: pick(options?.unwritableTimeout, defaults.unwritableTimeout, (value) => value >= 0),
|
|
24
|
+
receivingTimeout: pick(options?.receivingTimeout, defaults.receivingTimeout, (value) => value > 0),
|
|
25
|
+
receivingSwitchingDelay: pick(options?.receivingSwitchingDelay, defaults.receivingSwitchingDelay, (value) => value >= 0),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.resolveFailoverThresholds = resolveFailoverThresholds;
|
|
29
|
+
/** The remote address of `pair`, as a key. */
|
|
30
|
+
const remoteKey = (pair) => `${pair.remoteAddr[0]}:${pair.remoteAddr[1]}`;
|
|
31
|
+
/** Ta: the minimum spacing (ms) between two backup checks, as the ordinary schedule. */
|
|
32
|
+
const PACING_MS = 20;
|
|
33
|
+
/**
|
|
34
|
+
* Delays before a socket whose backup pairs all failed starts again from its
|
|
35
|
+
* highest-priority pair, one per retry; after the last one it goes on every
|
|
36
|
+
* last delay (16 s) while the selection lasts.
|
|
37
|
+
*/
|
|
38
|
+
const BACKUP_RETRY_DELAYS_MS = [1000, 2000, 4000, 8000, 16000];
|
|
39
|
+
/**
|
|
40
|
+
* No longer writable: `unwritableMinChecks` (CONNECTION_WRITE_CONNECT_FAILURES)
|
|
41
|
+
* consecutive checks unanswered and `unwritableTimeout`
|
|
42
|
+
* (CONNECTION_WRITE_CONNECT_TIMEOUT) since the last response (or, for a pair
|
|
43
|
+
* never answered, since monitoring began); or the path is known to be gone
|
|
44
|
+
* (`broken`).
|
|
45
|
+
*/
|
|
46
|
+
const isUnwritable = (liveness, now, thresholds = exports.DEFAULT_FAILOVER_THRESHOLDS) => !!liveness.broken ||
|
|
47
|
+
(liveness.unanswered >= thresholds.unwritableMinChecks &&
|
|
48
|
+
now - (liveness.lastResponse ?? liveness.since) >=
|
|
49
|
+
thresholds.unwritableTimeout);
|
|
50
|
+
exports.isUnwritable = isUnwritable;
|
|
51
|
+
/** Answered since monitoring began and not unwritable. */
|
|
52
|
+
const isWritable = (liveness, now, thresholds = exports.DEFAULT_FAILOVER_THRESHOLDS) => liveness.lastResponse !== undefined &&
|
|
53
|
+
!(0, exports.isUnwritable)(liveness, now, thresholds);
|
|
54
|
+
exports.isWritable = isWritable;
|
|
55
|
+
/** The last check went unanswered, or nothing was received for `receivingTimeout` (WEAK_CONNECTION_RECEIVE_TIMEOUT). */
|
|
56
|
+
const isWeak = (liveness, now, thresholds = exports.DEFAULT_FAILOVER_THRESHOLDS) => liveness.unanswered > 0 ||
|
|
57
|
+
now - liveness.lastReceived >= thresholds.receivingTimeout;
|
|
58
|
+
exports.isWeak = isWeak;
|
|
59
|
+
/**
|
|
60
|
+
* Since when (ms) `pair` has not been receiving, undefined while it is: the
|
|
61
|
+
* later of `receivingTimeout` of silence (libwebrtc's `Connection::receiving`)
|
|
62
|
+
* and its first unanswered check. libwebrtc needs no unanswered check, as it
|
|
63
|
+
* pings a weak selection every 48 ms; werift checks it far less often.
|
|
64
|
+
* @see tests/ice/selection-controller.test.ts "silence alone (no unanswered check) is not 'not receiving'; a receiving selection beats a pair that is not"
|
|
65
|
+
* @see tests/ice/selection-controller.test.ts "a late unanswered check starts the hold at the check, and a recovery in the hold keeps the selection"
|
|
66
|
+
* @see tests/pbt/failoverRules/failoverRulesProperty.test.ts "a pair is not receiving exactly from the later of the silence and the unanswered check, plus the hold"
|
|
67
|
+
*/
|
|
68
|
+
const notReceivingSince = (pair, now, receivingTimeout = iceBase_1.WEAK_CONNECTION_RECEIVE_TIMEOUT) => {
|
|
69
|
+
const silentSince = pair.lastReceived + receivingTimeout;
|
|
70
|
+
if (now < silentSince || pair.missedSince === undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
return Math.max(silentSince, pair.missedSince);
|
|
73
|
+
};
|
|
74
|
+
exports.notReceivingSince = notReceivingSince;
|
|
75
|
+
/**
|
|
76
|
+
* Stopped receiving (libwebrtc's `receiving`, then
|
|
77
|
+
* `receiving_switching_delay`): `notReceivingSince` is
|
|
78
|
+
* `receivingSwitchingDelay` ago, the same time `SelectionController` switches
|
|
79
|
+
* at.
|
|
80
|
+
* @see tests/pbt/failoverRules/failoverRulesProperty.test.ts "a pair is not receiving exactly from the later of the silence and the unanswered check, plus the hold"
|
|
81
|
+
* @see tests/ice/selection-controller.test.ts "an RTT switch within the hold is not a failover: the old pair is not demoted"
|
|
82
|
+
*/
|
|
83
|
+
const isNotReceiving = (liveness, now, thresholds = exports.DEFAULT_FAILOVER_THRESHOLDS) => {
|
|
84
|
+
const since = (0, exports.notReceivingSince)(liveness, now, thresholds.receivingTimeout);
|
|
85
|
+
return (since !== undefined && now - since >= thresholds.receivingSwitchingDelay);
|
|
86
|
+
};
|
|
87
|
+
exports.isNotReceiving = isNotReceiving;
|
|
88
|
+
/**
|
|
89
|
+
* Interval (ms) to the next check of a backup pair: the weak / stabilizing
|
|
90
|
+
* one until it answered MIN_PINGS_AT_WEAK_PING_INTERVAL times and while its
|
|
91
|
+
* last check goes unanswered, else the stable one (0.8–1.2 times).
|
|
92
|
+
*/
|
|
93
|
+
const backupPingInterval = (liveness) => liveness.unanswered > 0 ||
|
|
94
|
+
liveness.responses < iceBase_1.MIN_PINGS_AT_WEAK_PING_INTERVAL
|
|
95
|
+
? iceBase_1.WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL
|
|
96
|
+
: iceBase_1.STABLE_WRITABLE_CONNECTION_PING_INTERVAL * (0.8 + 0.4 * Math.random());
|
|
97
|
+
exports.backupPingInterval = backupPingInterval;
|
|
98
|
+
/**
|
|
99
|
+
* When the next check of a monitored pair is due (ms), given when the last
|
|
100
|
+
* one was sent and the interval it uses while the pair is not weak (D3):
|
|
101
|
+
* - its last check went unanswered (weak), or its path is known to be gone
|
|
102
|
+
* (`broken`): WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL after it;
|
|
103
|
+
* - otherwise `stableInterval` after it, but no later than the moment the
|
|
104
|
+
* pair has received nothing for `receivingTimeout`
|
|
105
|
+
* (WEAK_CONNECTION_RECEIVE_TIMEOUT, weak by silence), and never sooner
|
|
106
|
+
* than the weak interval.
|
|
107
|
+
* Something received later only moves it later: a caller that wakes up at
|
|
108
|
+
* the time computed earlier computes it again.
|
|
109
|
+
*/
|
|
110
|
+
const nextPingAt = (liveness, lastSentAt, stableInterval, thresholds = exports.DEFAULT_FAILOVER_THRESHOLDS) => {
|
|
111
|
+
const weakAt = lastSentAt + iceBase_1.WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL;
|
|
112
|
+
if (liveness.unanswered > 0 || liveness.broken)
|
|
113
|
+
return weakAt;
|
|
114
|
+
return Math.max(weakAt, Math.min(lastSentAt + stableInterval, liveness.lastReceived + thresholds.receivingTimeout));
|
|
115
|
+
};
|
|
116
|
+
exports.nextPingAt = nextPingAt;
|
|
117
|
+
/**
|
|
118
|
+
* Failover of the selected pair without an ICE restart, as libwebrtc keeps
|
|
119
|
+
* pinging its connections after the selection.
|
|
120
|
+
*
|
|
121
|
+
* One backup pair is monitored per local socket other than the selected
|
|
122
|
+
* pair's (`CandidatePair.protocol`: a UDP socket, whose host and
|
|
123
|
+
* server-reflexive candidates share one path, or a TURN allocation): the
|
|
124
|
+
* highest-priority pair of the socket that did not fail. A backup that never
|
|
125
|
+
* answers (unwritable) or receives nothing for DEAD_CONNECTION_RECEIVE_TIMEOUT
|
|
126
|
+
* fails and the next pair of its socket follows, up to
|
|
127
|
+
* FAILOVER_BACKUP_ATTEMPTS pairs; then the socket starts again from its best
|
|
128
|
+
* pair after BACKUP_RETRY_DELAYS_MS, then every 16 s while the selection
|
|
129
|
+
* lasts. All checks run from one timer, paced by
|
|
130
|
+
* Ta, and stop with `halt()` / `reset()`.
|
|
131
|
+
*
|
|
132
|
+
* The selected pair is checked by the consent freshness checks (the agent
|
|
133
|
+
* reports their outcome with `responded` / `unanswered`); the monitor keeps
|
|
134
|
+
* its liveness beside the backups'.
|
|
135
|
+
*/
|
|
136
|
+
class FailoverMonitor {
|
|
137
|
+
constructor(host) {
|
|
138
|
+
Object.defineProperty(this, "liveness", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
configurable: true,
|
|
141
|
+
writable: true,
|
|
142
|
+
value: new WeakMap()
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(this, "backups", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
configurable: true,
|
|
147
|
+
writable: true,
|
|
148
|
+
value: new Map()
|
|
149
|
+
});
|
|
150
|
+
/** Pairs RFC 8445 §8.1.2 failed without a check: they may still become a backup. */
|
|
151
|
+
Object.defineProperty(this, "pruned", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
configurable: true,
|
|
154
|
+
writable: true,
|
|
155
|
+
value: new WeakSet()
|
|
156
|
+
});
|
|
157
|
+
/** Sockets the agent failed over from, until one of their pairs answered FAILOVER_RECOVERY_RESPONSES times in a row. */
|
|
158
|
+
Object.defineProperty(this, "demoted", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
configurable: true,
|
|
161
|
+
writable: true,
|
|
162
|
+
value: new Map()
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(this, "abort", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
configurable: true,
|
|
167
|
+
writable: true,
|
|
168
|
+
value: new AbortController()
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(this, "timer", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
configurable: true,
|
|
173
|
+
writable: true,
|
|
174
|
+
value: void 0
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(this, "lastSentAt", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
configurable: true,
|
|
179
|
+
writable: true,
|
|
180
|
+
value: Number.NEGATIVE_INFINITY
|
|
181
|
+
});
|
|
182
|
+
Object.defineProperty(this, "host", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
configurable: true,
|
|
185
|
+
writable: true,
|
|
186
|
+
value: void 0
|
|
187
|
+
});
|
|
188
|
+
this.host = host;
|
|
189
|
+
}
|
|
190
|
+
/** The liveness of `pair`, while it is monitored. */
|
|
191
|
+
livenessOf(pair) {
|
|
192
|
+
return this.liveness.get(pair);
|
|
193
|
+
}
|
|
194
|
+
/** The monitored backup pairs, one per socket. */
|
|
195
|
+
get backupPairs() {
|
|
196
|
+
const pairs = [];
|
|
197
|
+
for (const record of this.backups.values()) {
|
|
198
|
+
if (record.pair)
|
|
199
|
+
pairs.push(record.pair);
|
|
200
|
+
}
|
|
201
|
+
return pairs;
|
|
202
|
+
}
|
|
203
|
+
/** `pair` is monitored and writable. */
|
|
204
|
+
writable(pair, now = Date.now()) {
|
|
205
|
+
const liveness = this.liveness.get(pair);
|
|
206
|
+
return !!liveness && (0, exports.isWritable)(liveness, now, this.host.thresholds());
|
|
207
|
+
}
|
|
208
|
+
/** `pair` is monitored, answered since and is unwritable now. */
|
|
209
|
+
knownUnwritable(pair, now = Date.now()) {
|
|
210
|
+
const liveness = this.liveness.get(pair);
|
|
211
|
+
return (!!liveness &&
|
|
212
|
+
liveness.lastResponse !== undefined &&
|
|
213
|
+
(0, exports.isUnwritable)(liveness, now, this.host.thresholds()));
|
|
214
|
+
}
|
|
215
|
+
/** `pair` is monitored and stopped receiving (`isNotReceiving`). */
|
|
216
|
+
notReceiving(pair, now = Date.now()) {
|
|
217
|
+
const liveness = this.liveness.get(pair);
|
|
218
|
+
return !!liveness && (0, exports.isNotReceiving)(liveness, now, this.host.thresholds());
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* The path of the monitored pairs on `protocol` (to `remote` only, when
|
|
222
|
+
* given) is known to be gone (`PairLiveness.broken`). Returns whether a
|
|
223
|
+
* monitored pair was on it.
|
|
224
|
+
*/
|
|
225
|
+
broken(protocol, remote) {
|
|
226
|
+
const pairs = new Set(this.backupPairs);
|
|
227
|
+
const selected = this.host.selected();
|
|
228
|
+
if (selected)
|
|
229
|
+
pairs.add(selected);
|
|
230
|
+
let hit = false;
|
|
231
|
+
for (const pair of pairs) {
|
|
232
|
+
if (pair.protocol !== protocol)
|
|
233
|
+
continue;
|
|
234
|
+
if (remote &&
|
|
235
|
+
(pair.remoteAddr[0] !== remote[0] || pair.remoteAddr[1] !== remote[1])) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const liveness = this.liveness.get(pair);
|
|
239
|
+
if (!liveness)
|
|
240
|
+
continue;
|
|
241
|
+
liveness.broken = true;
|
|
242
|
+
liveness.consecutive = 0;
|
|
243
|
+
hit = true;
|
|
244
|
+
}
|
|
245
|
+
return hit;
|
|
246
|
+
}
|
|
247
|
+
/** A backup is writable. */
|
|
248
|
+
hasWritableBackup(now = Date.now()) {
|
|
249
|
+
return this.backupPairs.some((pair) => this.writable(pair, now));
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The backup to fail over to from an unwritable selection: the
|
|
253
|
+
* highest-priority writable one that is not weak, else the
|
|
254
|
+
* highest-priority writable one.
|
|
255
|
+
*/
|
|
256
|
+
target(now = Date.now()) {
|
|
257
|
+
const writable = this.backupPairs.filter((pair) => this.writable(pair, now));
|
|
258
|
+
const best = (pairs) => pairs.reduce((best, pair) => (!best || this.outranks(pair, best) ? pair : best), undefined);
|
|
259
|
+
const strong = best(writable.filter((pair) => !(0, exports.isWeak)(this.liveness.get(pair), now, this.host.thresholds())));
|
|
260
|
+
return strong ?? best(writable);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* `pair` may be nominated to move the selection up: its socket is not one
|
|
264
|
+
* the agent failed over from (until it recovered) and the pair is not known
|
|
265
|
+
* to be unwritable.
|
|
266
|
+
*/
|
|
267
|
+
allows(pair) {
|
|
268
|
+
return !this.isDemoted(pair) && !this.knownUnwritable(pair);
|
|
269
|
+
}
|
|
270
|
+
/** `pair` is on a path the agent failed over from (see `demote`). */
|
|
271
|
+
isDemoted(pair) {
|
|
272
|
+
if (!this.demoted.has(pair.protocol))
|
|
273
|
+
return false;
|
|
274
|
+
const path = this.demoted.get(pair.protocol);
|
|
275
|
+
return path === undefined || path === remoteKey(pair);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* `pair` was selected (first selection, or a replacement): its check was
|
|
279
|
+
* just answered. The monitor follows the new selection.
|
|
280
|
+
*/
|
|
281
|
+
selected(pair) {
|
|
282
|
+
if (!this.host.enabled())
|
|
283
|
+
return;
|
|
284
|
+
this.track(pair);
|
|
285
|
+
this.responded(pair);
|
|
286
|
+
this.refresh();
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* The agent failed over from `pair` (the new selection is already set):
|
|
290
|
+
* its path waits to recover before the selection may move back. A move to
|
|
291
|
+
* another socket demotes `pair`'s whole socket (its paths break together);
|
|
292
|
+
* a move to another remote address on the same socket demotes only the
|
|
293
|
+
* path to `pair`'s remote address.
|
|
294
|
+
*/
|
|
295
|
+
demote(pair) {
|
|
296
|
+
const selected = this.host.selected();
|
|
297
|
+
const path = selected && selected.protocol === pair.protocol
|
|
298
|
+
? remoteKey(pair)
|
|
299
|
+
: undefined;
|
|
300
|
+
// A whole socket demoted already stays so.
|
|
301
|
+
if (!this.demoted.has(pair.protocol) || this.demoted.get(pair.protocol)) {
|
|
302
|
+
this.demoted.set(pair.protocol, path);
|
|
303
|
+
}
|
|
304
|
+
const liveness = this.liveness.get(pair);
|
|
305
|
+
if (liveness)
|
|
306
|
+
liveness.consecutive = 0;
|
|
307
|
+
}
|
|
308
|
+
/** A check of monitored `pair` was answered. */
|
|
309
|
+
responded(pair, now = Date.now()) {
|
|
310
|
+
const liveness = this.liveness.get(pair);
|
|
311
|
+
if (!liveness)
|
|
312
|
+
return;
|
|
313
|
+
liveness.lastResponse = now;
|
|
314
|
+
liveness.lastReceived = now;
|
|
315
|
+
liveness.unanswered = 0;
|
|
316
|
+
liveness.missedSince = undefined;
|
|
317
|
+
liveness.broken = false;
|
|
318
|
+
liveness.responses++;
|
|
319
|
+
liveness.consecutive++;
|
|
320
|
+
}
|
|
321
|
+
/** A check of monitored `pair` went unanswered. */
|
|
322
|
+
unanswered(pair, now = Date.now()) {
|
|
323
|
+
const liveness = this.liveness.get(pair);
|
|
324
|
+
if (!liveness)
|
|
325
|
+
return;
|
|
326
|
+
if (liveness.unanswered === 0)
|
|
327
|
+
liveness.missedSince = now;
|
|
328
|
+
liveness.unanswered++;
|
|
329
|
+
liveness.consecutive = 0;
|
|
330
|
+
}
|
|
331
|
+
/** Something (a request, application data) arrived on monitored `pair`. */
|
|
332
|
+
received(pair, now = Date.now()) {
|
|
333
|
+
const liveness = this.liveness.get(pair);
|
|
334
|
+
if (liveness)
|
|
335
|
+
liveness.lastReceived = now;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* The pairs RFC 8445 §8.1.2 must keep for the current selection: the
|
|
339
|
+
* backup of each other socket (the monitored one, or the one it would
|
|
340
|
+
* monitor next).
|
|
341
|
+
*/
|
|
342
|
+
keeps() {
|
|
343
|
+
const keeps = new Set();
|
|
344
|
+
const selected = this.host.selected();
|
|
345
|
+
if (!selected || !this.host.enabled())
|
|
346
|
+
return keeps;
|
|
347
|
+
for (const protocol of this.backupProtocols(selected)) {
|
|
348
|
+
const record = this.backups.get(protocol);
|
|
349
|
+
const pair = record?.pair ?? this.candidateFor(protocol, record);
|
|
350
|
+
if (pair)
|
|
351
|
+
keeps.add(pair);
|
|
352
|
+
}
|
|
353
|
+
return keeps;
|
|
354
|
+
}
|
|
355
|
+
/** RFC 8445 §8.1.2 failed `pair` without a check: it may still become a backup. */
|
|
356
|
+
prunedWithoutCheck(pair) {
|
|
357
|
+
this.pruned.add(pair);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Bring the backups in line with the selection and the checklist (a new
|
|
361
|
+
* selection, a pair added, a backup that failed) and arm the timer.
|
|
362
|
+
*/
|
|
363
|
+
refresh() {
|
|
364
|
+
const selected = this.host.selected();
|
|
365
|
+
if (!selected || !this.host.enabled()) {
|
|
366
|
+
this.halt();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const now = Date.now();
|
|
370
|
+
const protocols = this.backupProtocols(selected);
|
|
371
|
+
for (const [protocol, record] of this.backups) {
|
|
372
|
+
if (protocols.has(protocol))
|
|
373
|
+
continue;
|
|
374
|
+
this.dropRecord(record);
|
|
375
|
+
this.backups.delete(protocol);
|
|
376
|
+
}
|
|
377
|
+
const pairs = this.host.pairs();
|
|
378
|
+
for (const protocol of protocols) {
|
|
379
|
+
let record = this.backups.get(protocol);
|
|
380
|
+
if (!record) {
|
|
381
|
+
record = {
|
|
382
|
+
nextAt: now,
|
|
383
|
+
stableInterval: 0,
|
|
384
|
+
inFlight: 0,
|
|
385
|
+
failed: new Set(),
|
|
386
|
+
retries: 0,
|
|
387
|
+
};
|
|
388
|
+
this.backups.set(protocol, record);
|
|
389
|
+
}
|
|
390
|
+
// The backup became the selection (or the selection moved to its
|
|
391
|
+
// remote address on this socket): it is released, not failed.
|
|
392
|
+
if (record.pair && !this.backupEligible(record.pair, selected)) {
|
|
393
|
+
if (this.host.eligible(record.pair)) {
|
|
394
|
+
this.replace(record, record.pair);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const current = record.pair;
|
|
398
|
+
if (current &&
|
|
399
|
+
(!pairs.includes(current) ||
|
|
400
|
+
!this.host.eligible(current) ||
|
|
401
|
+
// Failed by another check (a nomination that went unanswered).
|
|
402
|
+
(current.state === iceBase_1.CandidatePairState.FAILED &&
|
|
403
|
+
record.inFlight === 0))) {
|
|
404
|
+
this.fail(record, current, false);
|
|
405
|
+
}
|
|
406
|
+
// A higher-priority pair of the socket appeared (a candidate trickled
|
|
407
|
+
// or gathered later): it becomes the backup instead (D2).
|
|
408
|
+
if (record.pair && !record.retryTimer) {
|
|
409
|
+
const best = this.candidateFor(protocol, record);
|
|
410
|
+
if (best && best !== record.pair && this.outranks(best, record.pair)) {
|
|
411
|
+
this.replace(record, record.pair);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (record.pair || record.retryTimer)
|
|
415
|
+
continue;
|
|
416
|
+
const next = record.failed.size < iceBase_1.FAILOVER_BACKUP_ATTEMPTS
|
|
417
|
+
? this.candidateFor(protocol, record)
|
|
418
|
+
: undefined;
|
|
419
|
+
if (next) {
|
|
420
|
+
this.adopt(record, next, now);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
this.scheduleRetry(protocol, record);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
this.arm();
|
|
427
|
+
}
|
|
428
|
+
/** Stop the checks and timers; the liveness of the pairs stays (a role change). */
|
|
429
|
+
halt() {
|
|
430
|
+
this.abort.abort();
|
|
431
|
+
this.abort = new AbortController();
|
|
432
|
+
if (this.timer !== undefined)
|
|
433
|
+
clearTimeout(this.timer);
|
|
434
|
+
this.timer = undefined;
|
|
435
|
+
for (const record of this.backups.values())
|
|
436
|
+
this.dropRecord(record);
|
|
437
|
+
this.backups.clear();
|
|
438
|
+
}
|
|
439
|
+
/** Stop everything and forget every pair (restart, close, a selection reset). */
|
|
440
|
+
reset() {
|
|
441
|
+
this.halt();
|
|
442
|
+
this.demoted.clear();
|
|
443
|
+
this.liveness = new WeakMap();
|
|
444
|
+
this.pruned = new WeakSet();
|
|
445
|
+
this.lastSentAt = Number.NEGATIVE_INFINITY;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* The sockets that keep a backup: every socket of an eligible pair; the
|
|
449
|
+
* selected pair's own socket only through a lower pair to another remote
|
|
450
|
+
* address (the remote side of the selected path may break alone: the
|
|
451
|
+
* peer's host candidate goes away while its relay still answers).
|
|
452
|
+
*/
|
|
453
|
+
backupProtocols(selected) {
|
|
454
|
+
const protocols = new Set();
|
|
455
|
+
for (const pair of this.host.pairs()) {
|
|
456
|
+
if (!this.backupEligible(pair, selected))
|
|
457
|
+
continue;
|
|
458
|
+
protocols.add(pair.protocol);
|
|
459
|
+
}
|
|
460
|
+
return protocols;
|
|
461
|
+
}
|
|
462
|
+
/** `pair` may be a backup beside `selected`. */
|
|
463
|
+
backupEligible(pair, selected) {
|
|
464
|
+
if (!this.host.eligible(pair))
|
|
465
|
+
return false;
|
|
466
|
+
if (pair.protocol !== selected.protocol)
|
|
467
|
+
return true;
|
|
468
|
+
// On the selected pair's socket: any other remote address. Only an
|
|
469
|
+
// agent that moves the selection up by itself (controlling) leaves the
|
|
470
|
+
// pairs that outrank the selection to `SelectionReplacement` (checked
|
|
471
|
+
// and retried there), except the path it failed over from (monitored
|
|
472
|
+
// until it recovers, see `demote`). A controlled agent monitors them,
|
|
473
|
+
// so the peer's nomination finds a path known to work.
|
|
474
|
+
if (remoteKey(pair) === remoteKey(selected))
|
|
475
|
+
return false;
|
|
476
|
+
return (!this.outranks(pair, selected) ||
|
|
477
|
+
this.isDemoted(pair) ||
|
|
478
|
+
!this.host.movesSelectionUp());
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* The next backup of `protocol`: its highest-priority eligible pair that
|
|
482
|
+
* did not fail in this round. A pair a check failed is skipped in the first
|
|
483
|
+
* round (one RFC 8445 §8.1.2 failed unchecked is not); a retry round takes
|
|
484
|
+
* every pair again.
|
|
485
|
+
*/
|
|
486
|
+
candidateFor(protocol, record) {
|
|
487
|
+
const retrying = (record?.retries ?? 0) > 0;
|
|
488
|
+
const selected = this.host.selected();
|
|
489
|
+
return this.host
|
|
490
|
+
.pairs()
|
|
491
|
+
.find((pair) => pair.protocol === protocol &&
|
|
492
|
+
(selected ? this.backupEligible(pair, selected) : true) &&
|
|
493
|
+
!record?.failed.has(pair) &&
|
|
494
|
+
(pair.state !== iceBase_1.CandidatePairState.FAILED ||
|
|
495
|
+
this.pruned.has(pair) ||
|
|
496
|
+
retrying));
|
|
497
|
+
}
|
|
498
|
+
adopt(record, pair, now) {
|
|
499
|
+
record.pair = pair;
|
|
500
|
+
record.nextAt = now;
|
|
501
|
+
record.sentAt = undefined;
|
|
502
|
+
record.inFlight = 0;
|
|
503
|
+
this.pruned.delete(pair);
|
|
504
|
+
this.track(pair, now);
|
|
505
|
+
// The monitor checks it now: the ordinary schedule and the checks of
|
|
506
|
+
// pairs that outrank the selection (Waiting / Frozen) leave it alone.
|
|
507
|
+
if (pair.state !== iceBase_1.CandidatePairState.SUCCEEDED) {
|
|
508
|
+
pair.updateState(iceBase_1.CandidatePairState.IN_PROGRESS);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
track(pair, now = Date.now()) {
|
|
512
|
+
if (this.liveness.has(pair))
|
|
513
|
+
return;
|
|
514
|
+
this.liveness.set(pair, {
|
|
515
|
+
since: now,
|
|
516
|
+
lastReceived: now,
|
|
517
|
+
unanswered: 0,
|
|
518
|
+
responses: 0,
|
|
519
|
+
consecutive: 0,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
/** `pair` failed as the backup of `record`; with `notify` the agent marks it Failed. */
|
|
523
|
+
fail(record, pair, notify) {
|
|
524
|
+
record.failed.add(pair);
|
|
525
|
+
record.pair = undefined;
|
|
526
|
+
record.inFlight = 0;
|
|
527
|
+
if (this.host.selected() !== pair)
|
|
528
|
+
this.liveness.delete(pair);
|
|
529
|
+
if (notify)
|
|
530
|
+
this.host.dropped(pair);
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* A better pair takes over as the backup of `record`: `pair` is no longer
|
|
534
|
+
* monitored but did not fail. One the monitor was still validating goes
|
|
535
|
+
* back to Failed-without-check, so it may become the backup again.
|
|
536
|
+
*/
|
|
537
|
+
replace(record, pair) {
|
|
538
|
+
record.pair = undefined;
|
|
539
|
+
record.inFlight = 0;
|
|
540
|
+
if (this.host.selected() !== pair)
|
|
541
|
+
this.liveness.delete(pair);
|
|
542
|
+
if (pair.state === iceBase_1.CandidatePairState.IN_PROGRESS) {
|
|
543
|
+
pair.updateState(iceBase_1.CandidatePairState.FAILED);
|
|
544
|
+
this.pruned.add(pair);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* The socket's backups all failed: start again from its best pair after
|
|
549
|
+
* BACKUP_RETRY_DELAYS_MS, then every last delay (16 s) for as long as the
|
|
550
|
+
* selection lasts, so a path that comes back after a long outage is found
|
|
551
|
+
* again (and is there when the selected pair breaks).
|
|
552
|
+
*/
|
|
553
|
+
scheduleRetry(protocol, record) {
|
|
554
|
+
if (record.retryTimer)
|
|
555
|
+
return;
|
|
556
|
+
const delay = BACKUP_RETRY_DELAYS_MS[Math.min(record.retries, BACKUP_RETRY_DELAYS_MS.length - 1)];
|
|
557
|
+
record.retryTimer = setTimeout(() => {
|
|
558
|
+
record.retryTimer = undefined;
|
|
559
|
+
if (this.backups.get(protocol) !== record)
|
|
560
|
+
return;
|
|
561
|
+
record.retries++;
|
|
562
|
+
record.failed.clear();
|
|
563
|
+
this.refresh();
|
|
564
|
+
}, delay);
|
|
565
|
+
}
|
|
566
|
+
dropRecord(record) {
|
|
567
|
+
if (record.retryTimer !== undefined)
|
|
568
|
+
clearTimeout(record.retryTimer);
|
|
569
|
+
record.retryTimer = undefined;
|
|
570
|
+
record.pair = undefined;
|
|
571
|
+
record.inFlight = 0;
|
|
572
|
+
}
|
|
573
|
+
/** One timer for every backup: the earliest check due, Ta after the last one sent. */
|
|
574
|
+
arm() {
|
|
575
|
+
if (this.timer !== undefined)
|
|
576
|
+
clearTimeout(this.timer);
|
|
577
|
+
this.timer = undefined;
|
|
578
|
+
let at = Number.POSITIVE_INFINITY;
|
|
579
|
+
for (const record of this.backups.values()) {
|
|
580
|
+
if (record.pair)
|
|
581
|
+
at = Math.min(at, record.nextAt);
|
|
582
|
+
}
|
|
583
|
+
if (at === Number.POSITIVE_INFINITY)
|
|
584
|
+
return;
|
|
585
|
+
at = Math.max(at, this.lastSentAt + PACING_MS);
|
|
586
|
+
this.timer = setTimeout(() => {
|
|
587
|
+
this.timer = undefined;
|
|
588
|
+
this.tick();
|
|
589
|
+
}, Math.max(0, at - Date.now()));
|
|
590
|
+
}
|
|
591
|
+
tick() {
|
|
592
|
+
const now = Date.now();
|
|
593
|
+
let due;
|
|
594
|
+
for (const entry of this.backups) {
|
|
595
|
+
const [, record] = entry;
|
|
596
|
+
if (!record.pair || record.nextAt > now)
|
|
597
|
+
continue;
|
|
598
|
+
// Something received since moves it later (nextPingAt).
|
|
599
|
+
if (record.sentAt !== undefined) {
|
|
600
|
+
const liveness = this.liveness.get(record.pair);
|
|
601
|
+
if (liveness) {
|
|
602
|
+
record.nextAt = (0, exports.nextPingAt)(liveness, record.sentAt, record.stableInterval, this.host.thresholds());
|
|
603
|
+
if (record.nextAt > now)
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (!due || record.nextAt < due[1].nextAt)
|
|
608
|
+
due = entry;
|
|
609
|
+
}
|
|
610
|
+
if (due) {
|
|
611
|
+
this.lastSentAt = now;
|
|
612
|
+
void this.check(due[0], due[1], due[1].pair);
|
|
613
|
+
}
|
|
614
|
+
this.arm();
|
|
615
|
+
}
|
|
616
|
+
async check(protocol, record, pair) {
|
|
617
|
+
const signal = this.abort.signal;
|
|
618
|
+
const liveness = this.liveness.get(pair);
|
|
619
|
+
const sentAt = Date.now();
|
|
620
|
+
// Checks keep their pacing: the next one does not wait for this one's
|
|
621
|
+
// outcome (its response timeout may exceed the interval).
|
|
622
|
+
record.inFlight++;
|
|
623
|
+
record.sentAt = sentAt;
|
|
624
|
+
record.stableInterval = (0, exports.backupPingInterval)(liveness);
|
|
625
|
+
const thresholds = this.host.thresholds();
|
|
626
|
+
record.nextAt = (0, exports.nextPingAt)(liveness, sentAt, record.stableInterval, thresholds);
|
|
627
|
+
let answered = false;
|
|
628
|
+
try {
|
|
629
|
+
answered = await this.host.ping(pair, signal);
|
|
630
|
+
}
|
|
631
|
+
catch {
|
|
632
|
+
answered = false;
|
|
633
|
+
}
|
|
634
|
+
if (signal.aborted ||
|
|
635
|
+
this.backups.get(protocol) !== record ||
|
|
636
|
+
record.pair !== pair) {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
record.inFlight = Math.max(0, record.inFlight - 1);
|
|
640
|
+
const now = Date.now();
|
|
641
|
+
if (answered) {
|
|
642
|
+
this.responded(pair, now);
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
this.unanswered(pair);
|
|
646
|
+
}
|
|
647
|
+
// The outcome decides the interval (stabilizing, weak or stable).
|
|
648
|
+
record.stableInterval = (0, exports.backupPingInterval)(liveness);
|
|
649
|
+
record.nextAt = Math.max(now, (0, exports.nextPingAt)(liveness, sentAt, record.stableInterval, thresholds));
|
|
650
|
+
if (answered && pair.state !== iceBase_1.CandidatePairState.SUCCEEDED) {
|
|
651
|
+
this.host.validated(pair);
|
|
652
|
+
}
|
|
653
|
+
if (!answered &&
|
|
654
|
+
((liveness.lastResponse === undefined &&
|
|
655
|
+
(0, exports.isUnwritable)(liveness, now, thresholds)) ||
|
|
656
|
+
now - liveness.lastReceived >= iceBase_1.DEAD_CONNECTION_RECEIVE_TIMEOUT)) {
|
|
657
|
+
this.fail(record, pair, true);
|
|
658
|
+
this.refresh();
|
|
659
|
+
}
|
|
660
|
+
if (answered &&
|
|
661
|
+
this.isDemoted(pair) &&
|
|
662
|
+
liveness.consecutive >= iceBase_1.FAILOVER_RECOVERY_RESPONSES) {
|
|
663
|
+
this.demoted.delete(protocol);
|
|
664
|
+
this.host.recovered();
|
|
665
|
+
}
|
|
666
|
+
this.host.changed();
|
|
667
|
+
this.arm();
|
|
668
|
+
}
|
|
669
|
+
outranks(pair, other) {
|
|
670
|
+
return ((0, iceBase_1.compareCandidatePairPriority)(pair.localCandidate, pair.remoteCandidate, other.localCandidate, other.remoteCandidate, this.host.iceControlling()) > 0);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
exports.FailoverMonitor = FailoverMonitor;
|
|
674
|
+
//# sourceMappingURL=failover.js.map
|