werift 0.17.6 → 0.18.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/lib/common/src/binary.d.ts +1 -0
- package/lib/common/src/binary.js +74 -21
- package/lib/common/src/binary.js.map +1 -1
- package/lib/common/src/log.js +18 -0
- package/lib/common/src/log.js.map +1 -1
- package/lib/common/src/network.d.ts +1 -1
- package/lib/common/src/network.js +1 -0
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/promise.js +22 -7
- package/lib/common/src/promise.js.map +1 -1
- package/lib/common/src/type.d.ts +1 -1
- package/lib/dtls/src/cipher/const.d.ts +7 -7
- package/lib/dtls/src/cipher/key-exchange.js +24 -1
- package/lib/dtls/src/cipher/key-exchange.js.map +1 -1
- package/lib/dtls/src/cipher/suites/abstract.d.ts +2 -2
- package/lib/dtls/src/cipher/suites/abstract.js +36 -2
- package/lib/dtls/src/cipher/suites/abstract.js.map +1 -1
- package/lib/dtls/src/cipher/suites/aead.js +60 -6
- package/lib/dtls/src/cipher/suites/aead.js.map +1 -1
- package/lib/dtls/src/client.js +62 -51
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/cipher.js +151 -59
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/dtls.js +90 -14
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/srtp.d.ts +1 -1
- package/lib/dtls/src/context/srtp.js +8 -0
- package/lib/dtls/src/context/srtp.js.map +1 -1
- package/lib/dtls/src/context/transport.js +14 -2
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight1.js +6 -1
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +12 -2
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +1 -1
- package/lib/dtls/src/flight/flight.js +42 -7
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight2.js +4 -2
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.js +12 -2
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +6 -1
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/ellipticCurves.js +27 -7
- package/lib/dtls/src/handshake/extensions/ellipticCurves.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/extendedMasterSecret.js +6 -1
- package/lib/dtls/src/handshake/extensions/extendedMasterSecret.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/renegotiationIndication.js +27 -7
- package/lib/dtls/src/handshake/extensions/renegotiationIndication.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/signature.js +27 -7
- package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/useSrtp.js +39 -9
- package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.js +21 -6
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.js +26 -5
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +14 -4
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +33 -7
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js +68 -18
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js +26 -5
- package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/message/finished.js +18 -2
- package/lib/dtls/src/handshake/message/finished.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +40 -9
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.js +60 -14
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js +18 -2
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +33 -7
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.js +75 -19
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.js +21 -6
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/record/builder.d.ts +1 -1
- package/lib/dtls/src/record/message/fragment.js +49 -14
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.js +84 -24
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.js +21 -6
- package/lib/dtls/src/record/message/plaintext.js.map +1 -1
- package/lib/dtls/src/server.js +59 -42
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.js +153 -64
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/dtls/src/transport.js +38 -11
- package/lib/dtls/src/transport.js.map +1 -1
- package/lib/dtls/src/typings/domain.d.ts +4 -4
- package/lib/ice/src/candidate.js +66 -11
- package/lib/ice/src/candidate.js.map +1 -1
- package/lib/ice/src/dns/lookup.js +12 -1
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.js +27 -2
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/helper.d.ts +1 -1
- package/lib/ice/src/helper.js +12 -2
- package/lib/ice/src/helper.js.map +1 -1
- package/lib/ice/src/ice.d.ts +9 -3
- package/lib/ice/src/ice.js +407 -155
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/stun/attributes.d.ts +3 -3
- package/lib/ice/src/stun/attributes.js +6 -1
- package/lib/ice/src/stun/attributes.js.map +1 -1
- package/lib/ice/src/stun/message.d.ts +4 -0
- package/lib/ice/src/stun/message.js +24 -3
- package/lib/ice/src/stun/message.js.map +1 -1
- package/lib/ice/src/stun/protocol.js +64 -15
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.js +99 -36
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/transport.js +57 -21
- package/lib/ice/src/transport.js.map +1 -1
- package/lib/ice/src/turn/protocol.js +176 -40
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +1 -1
- package/lib/rtp/src/codec/av1.d.ts +1 -1
- package/lib/rtp/src/codec/av1.js +118 -30
- package/lib/rtp/src/codec/av1.js.map +1 -1
- package/lib/rtp/src/codec/base.js +8 -0
- package/lib/rtp/src/codec/base.js.map +1 -1
- package/lib/rtp/src/codec/h264.js +55 -0
- package/lib/rtp/src/codec/h264.js.map +1 -1
- package/lib/rtp/src/codec/index.d.ts +2 -0
- package/lib/rtp/src/codec/index.js +12 -2
- package/lib/rtp/src/codec/index.js.map +1 -1
- package/lib/rtp/src/codec/opus.js +8 -0
- package/lib/rtp/src/codec/opus.js.map +1 -1
- package/lib/rtp/src/codec/vp8.js +102 -3
- package/lib/rtp/src/codec/vp8.js.map +1 -1
- package/lib/rtp/src/codec/vp9.js +164 -7
- package/lib/rtp/src/codec/vp9.js.map +1 -1
- package/lib/rtp/src/container/ebml/ebml.js +30 -3
- package/lib/rtp/src/container/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/container/webm.d.ts +1 -1
- package/lib/rtp/src/container/webm.js +44 -13
- package/lib/rtp/src/container/webm.js.map +1 -1
- package/lib/rtp/src/processor/depacketizer.d.ts +16 -8
- package/lib/rtp/src/processor/depacketizer.js +59 -22
- package/lib/rtp/src/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/processor/depacketizerCallback.js +24 -8
- package/lib/rtp/src/processor/depacketizerCallback.js.map +1 -1
- package/lib/rtp/src/processor/depacketizerTransformer.d.ts +2 -2
- package/lib/rtp/src/processor/depacketizerTransformer.js +6 -0
- package/lib/rtp/src/processor/depacketizerTransformer.js.map +1 -1
- package/lib/rtp/src/processor/index.d.ts +4 -2
- package/lib/rtp/src/processor/index.js +4 -2
- package/lib/rtp/src/processor/index.js.map +1 -1
- package/lib/rtp/src/processor/interface.d.ts +4 -0
- package/lib/rtp/src/processor/interface.js.map +1 -1
- package/lib/rtp/src/processor/jitterBuffer.d.ts +2 -1
- package/lib/rtp/src/processor/jitterBuffer.js +40 -8
- package/lib/rtp/src/processor/jitterBuffer.js.map +1 -1
- package/lib/rtp/src/processor/jitterBufferCallback.js +30 -9
- package/lib/rtp/src/processor/jitterBufferCallback.js.map +1 -1
- package/lib/rtp/src/processor/jitterBufferTransformer.js +12 -1
- package/lib/rtp/src/processor/jitterBufferTransformer.js.map +1 -1
- package/lib/rtp/src/processor/lipsync.d.ts +42 -0
- package/lib/rtp/src/processor/lipsync.js +178 -0
- package/lib/rtp/src/processor/lipsync.js.map +1 -0
- package/lib/rtp/src/processor/lipsyncCallback.d.ts +10 -0
- package/lib/rtp/src/processor/lipsyncCallback.js +59 -0
- package/lib/rtp/src/processor/lipsyncCallback.js.map +1 -0
- package/lib/rtp/src/processor/ntpTime.d.ts +24 -0
- package/lib/rtp/src/processor/ntpTime.js +91 -0
- package/lib/rtp/src/processor/ntpTime.js.map +1 -0
- package/lib/rtp/src/processor/ntpTimeCallback.d.ts +7 -0
- package/lib/rtp/src/processor/ntpTimeCallback.js +36 -0
- package/lib/rtp/src/processor/ntpTimeCallback.js.map +1 -0
- package/lib/rtp/src/processor/source/index.d.ts +1 -0
- package/lib/rtp/src/processor/source/index.js +1 -0
- package/lib/rtp/src/processor/source/index.js.map +1 -1
- package/lib/rtp/src/processor/source/rtcpCallback.d.ts +12 -0
- package/lib/rtp/src/processor/source/rtcpCallback.js +33 -0
- package/lib/rtp/src/processor/source/rtcpCallback.js.map +1 -0
- package/lib/rtp/src/processor/source/rtpCallback.js +28 -12
- package/lib/rtp/src/processor/source/rtpCallback.js.map +1 -1
- package/lib/rtp/src/processor/source/rtpStream.js +38 -10
- package/lib/rtp/src/processor/source/rtpStream.js.map +1 -1
- package/lib/rtp/src/processor/webm.d.ts +11 -4
- package/lib/rtp/src/processor/webm.js +169 -46
- package/lib/rtp/src/processor/webm.js.map +1 -1
- package/lib/rtp/src/processor/webmCallback.d.ts +5 -3
- package/lib/rtp/src/processor/webmCallback.js +52 -8
- package/lib/rtp/src/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/processor/webmStream.d.ts +2 -2
- package/lib/rtp/src/processor/webmStream.js +24 -0
- package/lib/rtp/src/processor/webmStream.js.map +1 -1
- package/lib/rtp/src/processor_old/base.d.ts +18 -0
- package/lib/rtp/src/processor_old/base.js +51 -0
- package/lib/rtp/src/processor_old/base.js.map +1 -0
- package/lib/rtp/src/processor_old/lipsync.d.ts +30 -0
- package/lib/rtp/src/processor_old/lipsync.js +119 -0
- package/lib/rtp/src/processor_old/lipsync.js.map +1 -0
- package/lib/rtp/src/rtcp/header.js +30 -5
- package/lib/rtp/src/rtcp/header.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +30 -3
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/index.d.ts +1 -1
- package/lib/rtp/src/rtcp/psfb/index.js +18 -2
- package/lib/rtp/src/rtcp/psfb/index.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/pictureLossIndication.js +30 -3
- package/lib/rtp/src/rtcp/psfb/pictureLossIndication.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/remb.js +66 -5
- package/lib/rtp/src/rtcp/psfb/remb.js.map +1 -1
- package/lib/rtp/src/rtcp/rr.js +68 -4
- package/lib/rtp/src/rtcp/rr.js.map +1 -1
- package/lib/rtp/src/rtcp/rtcp.d.ts +1 -1
- package/lib/rtp/src/rtcp/rtpfb/index.d.ts +1 -1
- package/lib/rtp/src/rtcp/rtpfb/index.js +24 -2
- package/lib/rtp/src/rtcp/rtpfb/index.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/nack.d.ts +5 -0
- package/lib/rtp/src/rtcp/rtpfb/nack.js +43 -3
- package/lib/rtp/src/rtcp/rtpfb/nack.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/twcc.js +154 -11
- package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
- package/lib/rtp/src/rtcp/sdes.js +42 -4
- package/lib/rtp/src/rtcp/sdes.js.map +1 -1
- package/lib/rtp/src/rtcp/sr.js +56 -5
- package/lib/rtp/src/rtcp/sr.js.map +1 -1
- package/lib/rtp/src/rtp/red/encoder.js +18 -3
- package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
- package/lib/rtp/src/rtp/red/handler.js +12 -2
- package/lib/rtp/src/rtp/red/handler.js.map +1 -1
- package/lib/rtp/src/rtp/red/packet.js +18 -2
- package/lib/rtp/src/rtp/red/packet.js.map +1 -1
- package/lib/rtp/src/rtp/rtp.d.ts +3 -3
- package/lib/rtp/src/rtp/rtp.js +104 -17
- package/lib/rtp/src/rtp/rtp.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/ctr.js +26 -10
- package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.d.ts +3 -0
- package/lib/rtp/src/srtp/cipher/gcm.js +40 -20
- package/lib/rtp/src/srtp/cipher/gcm.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/index.js +24 -4
- package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
- package/lib/rtp/src/srtp/const.d.ts +1 -1
- package/lib/rtp/src/srtp/context/context.d.ts +1 -1
- package/lib/rtp/src/srtp/context/context.js +84 -5
- package/lib/rtp/src/srtp/context/context.js.map +1 -1
- package/lib/rtp/src/srtp/session.d.ts +2 -2
- package/lib/rtp/src/srtp/session.js +24 -1
- package/lib/rtp/src/srtp/session.js.map +1 -1
- package/lib/rtp/src/srtp/srtcp.js +15 -5
- package/lib/rtp/src/srtp/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/srtp.js +15 -5
- package/lib/rtp/src/srtp/srtp.js.map +1 -1
- package/lib/sctp/src/chunk.js +349 -69
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/helper.d.ts +1 -1
- package/lib/sctp/src/param.d.ts +3 -3
- package/lib/sctp/src/param.js +66 -11
- package/lib/sctp/src/param.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +1 -1
- package/lib/sctp/src/sctp.js +479 -138
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/sctp/src/transport.js +31 -10
- package/lib/sctp/src/transport.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +1 -1
- package/lib/webrtc/src/dataChannel.js +145 -15
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/helper.js +37 -12
- package/lib/webrtc/src/helper.js.map +1 -1
- package/lib/webrtc/src/media/parameters.d.ts +1 -1
- package/lib/webrtc/src/media/parameters.js +124 -3
- package/lib/webrtc/src/media/parameters.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +4 -4
- package/lib/webrtc/src/media/receiver/nack.js +85 -33
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +42 -6
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/receiver/statistics.js +61 -5
- package/lib/webrtc/src/media/receiver/statistics.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +1 -1
- package/lib/webrtc/src/media/router.js +108 -83
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/rtpReceiver.js +188 -33
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.js +279 -42
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +2 -2
- package/lib/webrtc/src/media/rtpTransceiver.js +102 -18
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/cumulativeResult.js +36 -6
- package/lib/webrtc/src/media/sender/cumulativeResult.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderBWE.js +57 -12
- package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
- package/lib/webrtc/src/media/track.js +135 -24
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.d.ts +7 -4
- package/lib/webrtc/src/nonstandard/recorder/index.js +50 -6
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js +12 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +39 -35
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.js +158 -56
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +2 -2
- package/lib/webrtc/src/peerConnection.js +260 -58
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/sdp.js +287 -24
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +3 -3
- package/lib/webrtc/src/transport/dtls.js +185 -30
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +2 -2
- package/lib/webrtc/src/transport/ice.js +193 -25
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.js +193 -101
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/types/domain.d.ts +3 -3
- package/lib/webrtc/src/types/util.d.ts +2 -2
- package/lib/webrtc/src/utils.js +12 -2
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +15 -15
- package/src/dataChannel.ts +3 -1
- package/src/media/receiver/nack.ts +23 -19
- package/src/media/rtpReceiver.ts +5 -0
- package/src/media/rtpSender.ts +22 -19
- package/src/nonstandard/recorder/index.ts +12 -4
- package/src/nonstandard/recorder/writer/webm.ts +42 -50
- package/src/transport/dtls.ts +7 -3
- package/src/transport/ice.ts +6 -3
- package/src/transport/sctp.ts +3 -1
- package/lib/rtp/src/processor/avBuffer.d.ts +0 -36
- package/lib/rtp/src/processor/avBuffer.js +0 -107
- package/lib/rtp/src/processor/avBuffer.js.map +0 -1
- package/lib/rtp/src/processor/avBufferCallback.d.ts +0 -10
- package/lib/rtp/src/processor/avBufferCallback.js +0 -27
- package/lib/rtp/src/processor/avBufferCallback.js.map +0 -1
package/lib/ice/src/ice.js
CHANGED
|
@@ -48,160 +48,353 @@ const protocol_2 = require("./turn/protocol");
|
|
|
48
48
|
const utils_1 = require("./utils");
|
|
49
49
|
const log = (0, debug_1.default)("werift-ice : packages/ice/src/ice.ts : log");
|
|
50
50
|
class Connection {
|
|
51
|
+
get nominatedKeys() {
|
|
52
|
+
return Object.keys(this.nominated).map((v) => v.toString());
|
|
53
|
+
}
|
|
51
54
|
constructor(iceControlling, options) {
|
|
52
|
-
this
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
Object.defineProperty(this, "iceControlling", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: iceControlling
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(this, "localUserName", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
writable: true,
|
|
65
|
+
value: (0, helper_1.randomString)(4)
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(this, "localPassword", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true,
|
|
71
|
+
value: (0, helper_1.randomString)(22)
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(this, "remotePassword", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
value: ""
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(this, "remoteUsername", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
value: ""
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(this, "remoteIsLite", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
configurable: true,
|
|
88
|
+
writable: true,
|
|
89
|
+
value: false
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(this, "checkList", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
configurable: true,
|
|
94
|
+
writable: true,
|
|
95
|
+
value: []
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(this, "localCandidates", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: []
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(this, "stunServer", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: void 0
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(this, "turnServer", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
configurable: true,
|
|
112
|
+
writable: true,
|
|
113
|
+
value: void 0
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(this, "useIpv4", {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
configurable: true,
|
|
118
|
+
writable: true,
|
|
119
|
+
value: void 0
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(this, "useIpv6", {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
configurable: true,
|
|
124
|
+
writable: true,
|
|
125
|
+
value: void 0
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(this, "options", {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
configurable: true,
|
|
130
|
+
writable: true,
|
|
131
|
+
value: void 0
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(this, "remoteCandidatesEnd", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
configurable: true,
|
|
136
|
+
writable: true,
|
|
137
|
+
value: false
|
|
138
|
+
});
|
|
139
|
+
/**コンポーネントはデータストリームの一部です. データストリームには複数のコンポーネントが必要な場合があり、
|
|
140
|
+
* データストリーム全体が機能するには、それぞれが機能する必要があります.
|
|
141
|
+
* RTP / RTCPデータストリームの場合、RTPとRTCPが同じポートで多重化されていない限り、データストリームごとに2つのコンポーネントがあります.
|
|
142
|
+
* 1つはRTP用、もう1つはRTCP用です. コンポーネントには候補ペアがあり、他のコンポーネントでは使用できません. */
|
|
143
|
+
Object.defineProperty(this, "_components", {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
configurable: true,
|
|
146
|
+
writable: true,
|
|
147
|
+
value: void 0
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(this, "_localCandidatesEnd", {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
configurable: true,
|
|
152
|
+
writable: true,
|
|
153
|
+
value: false
|
|
154
|
+
});
|
|
155
|
+
Object.defineProperty(this, "_tieBreaker", {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
configurable: true,
|
|
158
|
+
writable: true,
|
|
159
|
+
value: BigInt(new int64_buffer_1.Uint64BE((0, crypto_1.randomBytes)(64)).toString())
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(this, "state", {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
configurable: true,
|
|
164
|
+
writable: true,
|
|
165
|
+
value: "new"
|
|
166
|
+
});
|
|
167
|
+
Object.defineProperty(this, "dnsLookup", {
|
|
168
|
+
enumerable: true,
|
|
169
|
+
configurable: true,
|
|
170
|
+
writable: true,
|
|
171
|
+
value: void 0
|
|
172
|
+
});
|
|
173
|
+
Object.defineProperty(this, "onData", {
|
|
174
|
+
enumerable: true,
|
|
175
|
+
configurable: true,
|
|
176
|
+
writable: true,
|
|
177
|
+
value: new rx_mini_1.Event()
|
|
178
|
+
});
|
|
179
|
+
Object.defineProperty(this, "stateChanged", {
|
|
180
|
+
enumerable: true,
|
|
181
|
+
configurable: true,
|
|
182
|
+
writable: true,
|
|
183
|
+
value: new rx_mini_1.Event()
|
|
184
|
+
});
|
|
185
|
+
Object.defineProperty(this, "_remoteCandidates", {
|
|
186
|
+
enumerable: true,
|
|
187
|
+
configurable: true,
|
|
188
|
+
writable: true,
|
|
189
|
+
value: []
|
|
190
|
+
});
|
|
67
191
|
// P2P接続完了したソケット
|
|
68
|
-
this
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this
|
|
192
|
+
Object.defineProperty(this, "nominated", {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
configurable: true,
|
|
195
|
+
writable: true,
|
|
196
|
+
value: {}
|
|
197
|
+
});
|
|
198
|
+
Object.defineProperty(this, "nominating", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
configurable: true,
|
|
201
|
+
writable: true,
|
|
202
|
+
value: new Set()
|
|
203
|
+
});
|
|
204
|
+
Object.defineProperty(this, "checkListDone", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
configurable: true,
|
|
207
|
+
writable: true,
|
|
208
|
+
value: false
|
|
209
|
+
});
|
|
210
|
+
Object.defineProperty(this, "checkListState", {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
configurable: true,
|
|
213
|
+
writable: true,
|
|
214
|
+
value: new helper_1.PQueue()
|
|
215
|
+
});
|
|
216
|
+
Object.defineProperty(this, "earlyChecks", {
|
|
217
|
+
enumerable: true,
|
|
218
|
+
configurable: true,
|
|
219
|
+
writable: true,
|
|
220
|
+
value: []
|
|
221
|
+
});
|
|
222
|
+
Object.defineProperty(this, "localCandidatesStart", {
|
|
223
|
+
enumerable: true,
|
|
224
|
+
configurable: true,
|
|
225
|
+
writable: true,
|
|
226
|
+
value: false
|
|
227
|
+
});
|
|
228
|
+
Object.defineProperty(this, "protocols", {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
configurable: true,
|
|
231
|
+
writable: true,
|
|
232
|
+
value: []
|
|
233
|
+
});
|
|
234
|
+
Object.defineProperty(this, "queryConsentHandle", {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
configurable: true,
|
|
237
|
+
writable: true,
|
|
238
|
+
value: void 0
|
|
239
|
+
});
|
|
240
|
+
Object.defineProperty(this, "promiseGatherCandidates", {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
configurable: true,
|
|
243
|
+
writable: true,
|
|
244
|
+
value: void 0
|
|
245
|
+
});
|
|
75
246
|
// 4.1.1.4 ? 生存確認 life check
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
247
|
+
Object.defineProperty(this, "queryConsent", {
|
|
248
|
+
enumerable: true,
|
|
249
|
+
configurable: true,
|
|
250
|
+
writable: true,
|
|
251
|
+
value: () => new p_cancelable_1.default(async (r, f, onCancel) => {
|
|
252
|
+
let failures = 0;
|
|
253
|
+
const cancelEvent = new AbortController();
|
|
254
|
+
onCancel(() => {
|
|
255
|
+
failures += CONSENT_FAILURES;
|
|
256
|
+
cancelEvent.abort();
|
|
257
|
+
f("cancel");
|
|
258
|
+
});
|
|
259
|
+
// """
|
|
260
|
+
// Periodically check consent (RFC 7675).
|
|
261
|
+
// """
|
|
262
|
+
try {
|
|
263
|
+
while (!this.remoteIsLite && this.state !== "closed") {
|
|
264
|
+
// # randomize between 0.8 and 1.2 times CONSENT_INTERVAL
|
|
265
|
+
await promises_1.default.setTimeout(CONSENT_INTERVAL * (0.8 + 0.4 * Math.random()) * 1000, undefined, { signal: cancelEvent.signal });
|
|
266
|
+
for (const key of this.nominatedKeys) {
|
|
267
|
+
const pair = this.nominated[Number(key)];
|
|
268
|
+
const request = this.buildRequest(pair, false);
|
|
269
|
+
try {
|
|
270
|
+
const [msg, addr] = await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"), 0);
|
|
271
|
+
failures = 0;
|
|
272
|
+
if (this.state === "disconnected") {
|
|
273
|
+
this.setState("connected");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
log("no stun response");
|
|
278
|
+
failures++;
|
|
279
|
+
this.setState("disconnected");
|
|
280
|
+
}
|
|
281
|
+
if (failures >= CONSENT_FAILURES) {
|
|
282
|
+
log("Consent to send expired");
|
|
283
|
+
this.queryConsentHandle = undefined;
|
|
284
|
+
// 切断検知
|
|
285
|
+
r(await this.close());
|
|
286
|
+
return;
|
|
99
287
|
}
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
log("no stun response");
|
|
103
|
-
failures++;
|
|
104
|
-
this.setState("disconnected");
|
|
105
|
-
}
|
|
106
|
-
if (failures >= CONSENT_FAILURES) {
|
|
107
|
-
log("Consent to send expired");
|
|
108
|
-
this.queryConsentHandle = undefined;
|
|
109
|
-
// 切断検知
|
|
110
|
-
r(await this.close());
|
|
111
|
-
return;
|
|
112
288
|
}
|
|
113
289
|
}
|
|
114
290
|
}
|
|
291
|
+
catch (error) { }
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
Object.defineProperty(this, "send", {
|
|
295
|
+
enumerable: true,
|
|
296
|
+
configurable: true,
|
|
297
|
+
writable: true,
|
|
298
|
+
value: async (data) => {
|
|
299
|
+
// """
|
|
300
|
+
// Send a datagram on the first component.
|
|
301
|
+
// If the connection is not established, a `ConnectionError` is raised.
|
|
302
|
+
// :param data: The data to be sent.
|
|
303
|
+
// """
|
|
304
|
+
await this.sendTo(data, 1);
|
|
115
305
|
}
|
|
116
|
-
catch (error) { }
|
|
117
306
|
});
|
|
118
|
-
this.send = async (data) => {
|
|
119
|
-
// """
|
|
120
|
-
// Send a datagram on the first component.
|
|
121
|
-
// If the connection is not established, a `ConnectionError` is raised.
|
|
122
|
-
// :param data: The data to be sent.
|
|
123
|
-
// """
|
|
124
|
-
await this.sendTo(data, 1);
|
|
125
|
-
};
|
|
126
307
|
// 3. Terminology : Check
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
result
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
308
|
+
Object.defineProperty(this, "checkStart", {
|
|
309
|
+
enumerable: true,
|
|
310
|
+
configurable: true,
|
|
311
|
+
writable: true,
|
|
312
|
+
value: (pair) => new p_cancelable_1.default(async (r, f, onCancel) => {
|
|
313
|
+
onCancel(() => f("cancel"));
|
|
314
|
+
// """
|
|
315
|
+
// Starts a check.
|
|
316
|
+
// """
|
|
317
|
+
log("check start", pair.toJSON());
|
|
318
|
+
this.setPairState(pair, CandidatePairState.IN_PROGRESS);
|
|
319
|
+
const nominate = this.iceControlling && !this.remoteIsLite;
|
|
320
|
+
const request = this.buildRequest(pair, nominate);
|
|
321
|
+
const result = {};
|
|
322
|
+
try {
|
|
323
|
+
const [response, addr] = await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"), 4);
|
|
324
|
+
log("response", response, addr);
|
|
325
|
+
result.response = response;
|
|
326
|
+
result.addr = addr;
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
const exc = error;
|
|
330
|
+
// 7.1.3.1. Failure Cases
|
|
331
|
+
log("failure case", exc.response);
|
|
332
|
+
if (exc.response?.getAttributeValue("ERROR-CODE")[0] === 487) {
|
|
333
|
+
if (request.attributesKeys.includes("ICE-CONTROLLED")) {
|
|
334
|
+
this.switchRole(true);
|
|
335
|
+
}
|
|
336
|
+
else if (request.attributesKeys.includes("ICE-CONTROLLING")) {
|
|
337
|
+
this.switchRole(false);
|
|
338
|
+
}
|
|
339
|
+
await this.checkStart(pair);
|
|
340
|
+
r();
|
|
341
|
+
return;
|
|
150
342
|
}
|
|
151
|
-
else
|
|
152
|
-
|
|
343
|
+
else {
|
|
344
|
+
// timeout
|
|
345
|
+
log("CandidatePairState.FAILED", pair.toJSON());
|
|
346
|
+
this.setPairState(pair, CandidatePairState.FAILED);
|
|
347
|
+
this.checkComplete(pair);
|
|
348
|
+
r();
|
|
349
|
+
return;
|
|
153
350
|
}
|
|
154
|
-
await this.checkStart(pair);
|
|
155
|
-
r();
|
|
156
|
-
return;
|
|
157
351
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.
|
|
352
|
+
// # check remote address matches
|
|
353
|
+
if (!(0, isEqual_1.default)(result.addr, pair.remoteAddr)) {
|
|
354
|
+
this.setPairState(pair, CandidatePairState.FAILED);
|
|
161
355
|
this.checkComplete(pair);
|
|
162
356
|
r();
|
|
163
357
|
return;
|
|
164
358
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
this.checkComplete(pair);
|
|
170
|
-
r();
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
// # success
|
|
174
|
-
if (nominate || pair.remoteNominated) {
|
|
175
|
-
// # nominated by agressive nomination or the remote party
|
|
176
|
-
pair.nominated = true;
|
|
177
|
-
}
|
|
178
|
-
else if (this.iceControlling && !this.nominating.has(pair.component)) {
|
|
179
|
-
// # perform regular nomination
|
|
180
|
-
this.nominating.add(pair.component);
|
|
181
|
-
const request = this.buildRequest(pair, true);
|
|
182
|
-
try {
|
|
183
|
-
await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"));
|
|
359
|
+
// # success
|
|
360
|
+
if (nominate || pair.remoteNominated) {
|
|
361
|
+
// # nominated by agressive nomination or the remote party
|
|
362
|
+
pair.nominated = true;
|
|
184
363
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
this.
|
|
188
|
-
|
|
364
|
+
else if (this.iceControlling && !this.nominating.has(pair.component)) {
|
|
365
|
+
// # perform regular nomination
|
|
366
|
+
this.nominating.add(pair.component);
|
|
367
|
+
const request = this.buildRequest(pair, true);
|
|
368
|
+
try {
|
|
369
|
+
await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"));
|
|
370
|
+
}
|
|
371
|
+
catch (error) {
|
|
372
|
+
this.setPairState(pair, CandidatePairState.FAILED);
|
|
373
|
+
this.checkComplete(pair);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
pair.nominated = true;
|
|
189
377
|
}
|
|
190
|
-
pair.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
r();
|
|
378
|
+
this.setPairState(pair, CandidatePairState.SUCCEEDED);
|
|
379
|
+
this.checkComplete(pair);
|
|
380
|
+
r();
|
|
381
|
+
})
|
|
195
382
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
383
|
+
Object.defineProperty(this, "pairRemoteCandidate", {
|
|
384
|
+
enumerable: true,
|
|
385
|
+
configurable: true,
|
|
386
|
+
writable: true,
|
|
387
|
+
value: (remoteCandidate) => {
|
|
388
|
+
for (const protocol of this.protocols) {
|
|
389
|
+
if (protocol.localCandidate?.canPairWith(remoteCandidate) &&
|
|
390
|
+
!this.findPair(protocol, remoteCandidate)) {
|
|
391
|
+
const pair = new CandidatePair(protocol, remoteCandidate);
|
|
392
|
+
this.checkList.push(pair);
|
|
393
|
+
this.setPairState(pair, CandidatePairState.WAITING);
|
|
394
|
+
}
|
|
202
395
|
}
|
|
203
396
|
}
|
|
204
|
-
};
|
|
397
|
+
});
|
|
205
398
|
this.options = {
|
|
206
399
|
...defaultOptions,
|
|
207
400
|
...options,
|
|
@@ -213,10 +406,8 @@ class Connection {
|
|
|
213
406
|
this.useIpv6 = useIpv6;
|
|
214
407
|
this._components = new Set((0, range_1.default)(1, components + 1));
|
|
215
408
|
}
|
|
216
|
-
get nominatedKeys() {
|
|
217
|
-
return Object.keys(this.nominated).map((v) => v.toString());
|
|
218
|
-
}
|
|
219
409
|
setRemoteParams({ iceLite, usernameFragment, password, }) {
|
|
410
|
+
log("setRemoteParams", { iceLite, usernameFragment, password });
|
|
220
411
|
this.remoteIsLite = iceLite;
|
|
221
412
|
this.remoteUsername = usernameFragment;
|
|
222
413
|
this.remotePassword = password;
|
|
@@ -353,7 +544,7 @@ class Connection {
|
|
|
353
544
|
if (!firstPair)
|
|
354
545
|
return;
|
|
355
546
|
if (firstPair.state === CandidatePairState.FROZEN) {
|
|
356
|
-
this.
|
|
547
|
+
this.setPairState(firstPair, CandidatePairState.WAITING);
|
|
357
548
|
}
|
|
358
549
|
// # unfreeze pairs with same component but different foundations
|
|
359
550
|
const seenFoundations = new Set(firstPair.localCandidate.foundation);
|
|
@@ -361,7 +552,7 @@ class Connection {
|
|
|
361
552
|
if (pair.component === firstPair.component &&
|
|
362
553
|
!seenFoundations.has(pair.localCandidate.foundation) &&
|
|
363
554
|
pair.state === CandidatePairState.FROZEN) {
|
|
364
|
-
this.
|
|
555
|
+
this.setPairState(pair, CandidatePairState.WAITING);
|
|
365
556
|
seenFoundations.add(pair.localCandidate.foundation);
|
|
366
557
|
}
|
|
367
558
|
}
|
|
@@ -438,8 +629,6 @@ class Connection {
|
|
|
438
629
|
// To signal end-of-candidates, pass `None`.
|
|
439
630
|
// :param remote_candidate: A :class:`Candidate` instance or `None`.
|
|
440
631
|
// """
|
|
441
|
-
if (this.remoteCandidatesEnd)
|
|
442
|
-
throw new Error("Cannot add remote candidate after end-of-candidates.");
|
|
443
632
|
if (!remoteCandidate) {
|
|
444
633
|
this.pruneComponents();
|
|
445
634
|
this.remoteCandidatesEnd = true;
|
|
@@ -501,8 +690,9 @@ class Connection {
|
|
|
501
690
|
(0, message_1.parseMessage)(rawData, Buffer.from(this.localPassword, "utf8"));
|
|
502
691
|
if (!this.remoteUsername) {
|
|
503
692
|
const rxUsername = `${this.localUserName}:${this.remoteUsername}`;
|
|
504
|
-
if (message.getAttributeValue("USERNAME") != rxUsername)
|
|
693
|
+
if (message.getAttributeValue("USERNAME") != rxUsername) {
|
|
505
694
|
throw new Error("Wrong username");
|
|
695
|
+
}
|
|
506
696
|
}
|
|
507
697
|
}
|
|
508
698
|
catch (error) {
|
|
@@ -549,7 +739,12 @@ class Connection {
|
|
|
549
739
|
// }
|
|
550
740
|
}
|
|
551
741
|
dataReceived(data, component) {
|
|
552
|
-
|
|
742
|
+
try {
|
|
743
|
+
this.onData.execute(data, component);
|
|
744
|
+
}
|
|
745
|
+
catch (error) {
|
|
746
|
+
log("dataReceived", error);
|
|
747
|
+
}
|
|
553
748
|
}
|
|
554
749
|
// for test only
|
|
555
750
|
set remoteCandidates(value) {
|
|
@@ -586,8 +781,9 @@ class Connection {
|
|
|
586
781
|
(0, isEqual_1.default)(pair.remoteCandidate, remoteCandidate));
|
|
587
782
|
return pair;
|
|
588
783
|
}
|
|
589
|
-
|
|
590
|
-
pair.
|
|
784
|
+
setPairState(pair, state) {
|
|
785
|
+
log("setPairState", pair.toJSON(), CandidatePairState[state]);
|
|
786
|
+
pair.updateState(state);
|
|
591
787
|
}
|
|
592
788
|
switchRole(iceControlling) {
|
|
593
789
|
log("switch role", iceControlling);
|
|
@@ -595,6 +791,7 @@ class Connection {
|
|
|
595
791
|
this.sortCheckList();
|
|
596
792
|
}
|
|
597
793
|
resetNominatedPair() {
|
|
794
|
+
log("resetNominatedPair");
|
|
598
795
|
this.nominated = {};
|
|
599
796
|
this.nominating.clear();
|
|
600
797
|
}
|
|
@@ -607,6 +804,7 @@ class Connection {
|
|
|
607
804
|
// concludes the ICE processing for that component. See Section 8.
|
|
608
805
|
// So disallow overwriting of the pair nominated for that component
|
|
609
806
|
if (pair.nominated && this.nominated[pair.component] == undefined) {
|
|
807
|
+
log("nominated", pair.toJSON());
|
|
610
808
|
this.nominated[pair.component] = pair;
|
|
611
809
|
this.nominating.delete(pair.component);
|
|
612
810
|
// 8.1.2. Updating States
|
|
@@ -616,7 +814,7 @@ class Connection {
|
|
|
616
814
|
for (const p of this.checkList) {
|
|
617
815
|
if (p.component === pair.component &&
|
|
618
816
|
[CandidatePairState.WAITING, CandidatePairState.FROZEN].includes(p.state)) {
|
|
619
|
-
this.
|
|
817
|
+
this.setPairState(p, CandidatePairState.FAILED);
|
|
620
818
|
}
|
|
621
819
|
}
|
|
622
820
|
}
|
|
@@ -635,7 +833,7 @@ class Connection {
|
|
|
635
833
|
for (const p of this.checkList) {
|
|
636
834
|
if (p.localCandidate.foundation === pair.localCandidate.foundation &&
|
|
637
835
|
p.state === CandidatePairState.FROZEN) {
|
|
638
|
-
this.
|
|
836
|
+
this.setPairState(p, CandidatePairState.WAITING);
|
|
639
837
|
}
|
|
640
838
|
}
|
|
641
839
|
}
|
|
@@ -661,20 +859,23 @@ class Connection {
|
|
|
661
859
|
// 7.2. STUN Server Procedures
|
|
662
860
|
// 7.2.1.3、7.2.1.4、および7.2.1.5
|
|
663
861
|
checkIncoming(message, addr, protocol) {
|
|
862
|
+
// log("checkIncoming", message.toJSON(), addr);
|
|
664
863
|
// """
|
|
665
864
|
// Handle a successful incoming check.
|
|
666
865
|
// """
|
|
667
866
|
const component = protocol.localCandidate?.component;
|
|
668
|
-
if (component == undefined)
|
|
669
|
-
throw new Error();
|
|
867
|
+
if (component == undefined) {
|
|
868
|
+
throw new Error("component not exist");
|
|
869
|
+
}
|
|
670
870
|
// find remote candidate
|
|
671
871
|
let remoteCandidate;
|
|
672
872
|
const [host, port] = addr;
|
|
673
873
|
for (const c of this.remoteCandidates) {
|
|
674
874
|
if (c.host === host && c.port === port) {
|
|
675
875
|
remoteCandidate = c;
|
|
676
|
-
if (remoteCandidate.component !== component)
|
|
876
|
+
if (remoteCandidate.component !== component) {
|
|
677
877
|
throw new Error("checkIncoming");
|
|
878
|
+
}
|
|
678
879
|
break;
|
|
679
880
|
}
|
|
680
881
|
}
|
|
@@ -687,7 +888,7 @@ class Connection {
|
|
|
687
888
|
let pair = this.findPair(protocol, remoteCandidate);
|
|
688
889
|
if (!pair) {
|
|
689
890
|
pair = new CandidatePair(protocol, remoteCandidate);
|
|
690
|
-
pair
|
|
891
|
+
this.setPairState(pair, CandidatePairState.WAITING);
|
|
691
892
|
this.checkList.push(pair);
|
|
692
893
|
this.sortCheckList();
|
|
693
894
|
}
|
|
@@ -695,6 +896,9 @@ class Connection {
|
|
|
695
896
|
if ([CandidatePairState.WAITING, CandidatePairState.FAILED].includes(pair.state)) {
|
|
696
897
|
pair.handle = (0, helper_1.future)(this.checkStart(pair));
|
|
697
898
|
}
|
|
899
|
+
else {
|
|
900
|
+
pair;
|
|
901
|
+
}
|
|
698
902
|
// 7.2.1.5. Updating the Nominated Flag
|
|
699
903
|
if (message.attributesKeys.includes("USE-CANDIDATE") &&
|
|
700
904
|
!this.iceControlling) {
|
|
@@ -733,13 +937,56 @@ class Connection {
|
|
|
733
937
|
}
|
|
734
938
|
exports.Connection = Connection;
|
|
735
939
|
class CandidatePair {
|
|
940
|
+
get state() {
|
|
941
|
+
return this._state;
|
|
942
|
+
}
|
|
943
|
+
toJSON() {
|
|
944
|
+
return {
|
|
945
|
+
protocol: this.protocol.type,
|
|
946
|
+
remoteAddr: this.remoteAddr,
|
|
947
|
+
};
|
|
948
|
+
}
|
|
736
949
|
constructor(protocol, remoteCandidate) {
|
|
737
|
-
this
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
950
|
+
Object.defineProperty(this, "protocol", {
|
|
951
|
+
enumerable: true,
|
|
952
|
+
configurable: true,
|
|
953
|
+
writable: true,
|
|
954
|
+
value: protocol
|
|
955
|
+
});
|
|
956
|
+
Object.defineProperty(this, "remoteCandidate", {
|
|
957
|
+
enumerable: true,
|
|
958
|
+
configurable: true,
|
|
959
|
+
writable: true,
|
|
960
|
+
value: remoteCandidate
|
|
961
|
+
});
|
|
962
|
+
Object.defineProperty(this, "handle", {
|
|
963
|
+
enumerable: true,
|
|
964
|
+
configurable: true,
|
|
965
|
+
writable: true,
|
|
966
|
+
value: void 0
|
|
967
|
+
});
|
|
968
|
+
Object.defineProperty(this, "nominated", {
|
|
969
|
+
enumerable: true,
|
|
970
|
+
configurable: true,
|
|
971
|
+
writable: true,
|
|
972
|
+
value: false
|
|
973
|
+
});
|
|
974
|
+
Object.defineProperty(this, "remoteNominated", {
|
|
975
|
+
enumerable: true,
|
|
976
|
+
configurable: true,
|
|
977
|
+
writable: true,
|
|
978
|
+
value: false
|
|
979
|
+
});
|
|
741
980
|
// 5.7.4. Computing States
|
|
742
|
-
this
|
|
981
|
+
Object.defineProperty(this, "_state", {
|
|
982
|
+
enumerable: true,
|
|
983
|
+
configurable: true,
|
|
984
|
+
writable: true,
|
|
985
|
+
value: CandidatePairState.FROZEN
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
updateState(state) {
|
|
989
|
+
this._state = state;
|
|
743
990
|
}
|
|
744
991
|
get localCandidate() {
|
|
745
992
|
if (!this.protocol.localCandidate)
|
|
@@ -793,6 +1040,10 @@ function candidatePairPriority(local, remote, iceControlling) {
|
|
|
793
1040
|
return (1 << 32) * Math.min(G, D) + 2 * Math.max(G, D) + (G > D ? 1 : 0);
|
|
794
1041
|
}
|
|
795
1042
|
exports.candidatePairPriority = candidatePairPriority;
|
|
1043
|
+
function isAutoconfigurationAddress(info) {
|
|
1044
|
+
return ((0, utils_1.normalizeFamilyNodeV18)(info.family) === 4 &&
|
|
1045
|
+
info.address?.startsWith("169.254."));
|
|
1046
|
+
}
|
|
796
1047
|
function nodeIpAddress(family) {
|
|
797
1048
|
// https://chromium.googlesource.com/external/webrtc/+/master/rtc_base/network.cc#236
|
|
798
1049
|
const costlyNetworks = ["ipsec", "tun", "utun", "tap"];
|
|
@@ -809,7 +1060,8 @@ function nodeIpAddress(family) {
|
|
|
809
1060
|
}
|
|
810
1061
|
}
|
|
811
1062
|
const addresses = interfaces[nic].filter((details) => (0, utils_1.normalizeFamilyNodeV18)(details.family) === family &&
|
|
812
|
-
!nodeIp.isLoopback(details.address)
|
|
1063
|
+
!nodeIp.isLoopback(details.address) &&
|
|
1064
|
+
!isAutoconfigurationAddress(details));
|
|
813
1065
|
return {
|
|
814
1066
|
nic,
|
|
815
1067
|
addresses: addresses.map((address) => address.address),
|