@matter/protocol 0.18.0 → 0.18.1-alpha.0-20261111-b84c5d1bc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/action/Val.d.ts +8 -0
- package/dist/cjs/action/Val.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.js +45 -32
- package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
- package/dist/cjs/action/client/ClientRequest.d.ts +14 -0
- package/dist/cjs/action/client/ClientRequest.d.ts.map +1 -1
- package/dist/cjs/action/client/InputChunk.js +39 -2
- package/dist/cjs/action/client/InputChunk.js.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscription.d.ts +2 -0
- package/dist/cjs/action/client/subscription/ClientSubscription.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscription.js +4 -0
- package/dist/cjs/action/client/subscription/ClientSubscription.js.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js +14 -0
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/cjs/action/client/subscription/PeerSubscription.d.ts +32 -0
- package/dist/cjs/action/client/subscription/PeerSubscription.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/PeerSubscription.js +61 -0
- package/dist/cjs/action/client/subscription/PeerSubscription.js.map +1 -1
- package/dist/cjs/action/errors.d.ts +3 -1
- package/dist/cjs/action/errors.d.ts.map +1 -1
- package/dist/cjs/action/errors.js +7 -2
- package/dist/cjs/action/errors.js.map +1 -1
- package/dist/cjs/action/protocols.d.ts +6 -1
- package/dist/cjs/action/protocols.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.d.ts +24 -1
- package/dist/cjs/action/request/Invoke.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.js +40 -12
- package/dist/cjs/action/request/Invoke.js.map +1 -1
- package/dist/cjs/action/request/Write.d.ts.map +1 -1
- package/dist/cjs/action/request/Write.js +6 -5
- package/dist/cjs/action/request/Write.js.map +1 -1
- package/dist/cjs/action/response/InvokeResult.d.ts +8 -2
- package/dist/cjs/action/response/InvokeResult.d.ts.map +1 -1
- package/dist/cjs/action/response/InvokeResult.js +28 -0
- package/dist/cjs/action/response/InvokeResult.js.map +2 -2
- package/dist/cjs/action/response/ReadResult.d.ts +14 -5
- package/dist/cjs/action/response/ReadResult.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.js +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.js.map +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.js +4 -2
- package/dist/cjs/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/cjs/action/server/EventReadResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/EventReadResponse.js +1 -0
- package/dist/cjs/action/server/EventReadResponse.js.map +1 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertisement.d.ts +1 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertisement.d.ts.map +1 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertisement.js +7 -7
- package/dist/cjs/advertisement/mdns/MdnsAdvertisement.js.map +1 -1
- package/dist/cjs/ble/Ble.d.ts +2 -0
- package/dist/cjs/ble/Ble.d.ts.map +1 -1
- package/dist/cjs/ble/Ble.js +4 -0
- package/dist/cjs/ble/Ble.js.map +1 -1
- package/dist/cjs/certificate/CdSigners.d.ts +52 -0
- package/dist/cjs/certificate/CdSigners.d.ts.map +1 -0
- package/dist/cjs/certificate/CdSigners.js +111 -0
- package/dist/cjs/certificate/CdSigners.js.map +6 -0
- package/dist/cjs/certificate/CertificateAuthority.d.ts +1 -1
- package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceAttestationValidator.d.ts +59 -7
- package/dist/cjs/certificate/DeviceAttestationValidator.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceAttestationValidator.js +122 -42
- package/dist/cjs/certificate/DeviceAttestationValidator.js.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.js +5 -2
- package/dist/cjs/certificate/DeviceCertification.js.map +1 -1
- package/dist/cjs/certificate/NocsrValidator.d.ts +57 -0
- package/dist/cjs/certificate/NocsrValidator.d.ts.map +1 -0
- package/dist/cjs/certificate/NocsrValidator.js +109 -0
- package/dist/cjs/certificate/NocsrValidator.js.map +6 -0
- package/dist/cjs/certificate/PeerData.d.ts +12 -0
- package/dist/cjs/certificate/PeerData.d.ts.map +1 -0
- package/dist/cjs/certificate/PeerData.js +33 -0
- package/dist/cjs/certificate/PeerData.js.map +6 -0
- package/dist/cjs/certificate/index.d.ts +2 -0
- package/dist/cjs/certificate/index.d.ts.map +1 -1
- package/dist/cjs/certificate/index.js +2 -0
- package/dist/cjs/certificate/index.js.map +1 -1
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts +42 -6
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/AttestationCertificates.js +110 -13
- package/dist/cjs/certificate/kinds/AttestationCertificates.js.map +1 -1
- package/dist/cjs/certificate/kinds/Certificate.d.ts +13 -7
- package/dist/cjs/certificate/kinds/Certificate.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Certificate.js +146 -240
- package/dist/cjs/certificate/kinds/Certificate.js.map +2 -2
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts +21 -3
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/CertificationDeclaration.js +76 -20
- package/dist/cjs/certificate/kinds/CertificationDeclaration.js.map +1 -1
- package/dist/cjs/certificate/kinds/DistinguishedName.d.ts +190 -0
- package/dist/cjs/certificate/kinds/DistinguishedName.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/DistinguishedName.js +417 -0
- package/dist/cjs/certificate/kinds/DistinguishedName.js.map +6 -0
- package/dist/cjs/certificate/kinds/Icac.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Icac.js +5 -10
- package/dist/cjs/certificate/kinds/Icac.js.map +1 -1
- package/dist/cjs/certificate/kinds/Noc.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Noc.js +5 -4
- package/dist/cjs/certificate/kinds/Noc.js.map +1 -1
- package/dist/cjs/certificate/kinds/OperationalBase.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/OperationalBase.js +4 -2
- package/dist/cjs/certificate/kinds/OperationalBase.js.map +1 -1
- package/dist/cjs/certificate/kinds/Rcac.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Rcac.js +5 -10
- package/dist/cjs/certificate/kinds/Rcac.js.map +1 -1
- package/dist/cjs/certificate/kinds/Vvsc.d.ts +3 -3
- package/dist/cjs/certificate/kinds/Vvsc.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Vvsc.js +19 -14
- package/dist/cjs/certificate/kinds/Vvsc.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/asn.d.ts +1 -1
- package/dist/cjs/certificate/kinds/definitions/asn.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/asn.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/attestation.d.ts +15 -15
- package/dist/cjs/certificate/kinds/definitions/attestation.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/base.d.ts +33 -0
- package/dist/cjs/certificate/kinds/definitions/base.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/base.js +8 -1
- package/dist/cjs/certificate/kinds/definitions/base.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/operational.d.ts +24 -20
- package/dist/cjs/certificate/kinds/definitions/operational.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/operational.js +5 -3
- package/dist/cjs/certificate/kinds/definitions/operational.js.map +1 -1
- package/dist/cjs/codec/MessageCodec.d.ts +27 -2
- package/dist/cjs/codec/MessageCodec.d.ts.map +1 -1
- package/dist/cjs/codec/MessageCodec.js +81 -74
- package/dist/cjs/codec/MessageCodec.js.map +1 -1
- package/dist/cjs/common/OperationalCredentialsTypes.d.ts +6 -0
- package/dist/cjs/common/OperationalCredentialsTypes.d.ts.map +1 -1
- package/dist/cjs/common/OperationalCredentialsTypes.js +2 -0
- package/dist/cjs/common/OperationalCredentialsTypes.js.map +1 -1
- package/dist/cjs/dcl/DclCertificateService.d.ts +28 -7
- package/dist/cjs/dcl/DclCertificateService.d.ts.map +1 -1
- package/dist/cjs/dcl/DclCertificateService.js +103 -30
- package/dist/cjs/dcl/DclCertificateService.js.map +1 -1
- package/dist/cjs/fabric/Fabric.d.ts +10 -5
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +12 -5
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/fabric/FabricManager.d.ts +2 -2
- package/dist/cjs/fabric/FabricManager.js +2 -2
- package/dist/cjs/groups/FabricGroups.d.ts +2 -0
- package/dist/cjs/groups/FabricGroups.d.ts.map +1 -1
- package/dist/cjs/groups/FabricGroups.js +4 -0
- package/dist/cjs/groups/FabricGroups.js.map +1 -1
- package/dist/cjs/groups/Groups.d.ts +7 -0
- package/dist/cjs/groups/Groups.d.ts.map +1 -1
- package/dist/cjs/groups/Groups.js +11 -2
- package/dist/cjs/groups/Groups.js.map +1 -1
- package/dist/cjs/groups/KeySets.d.ts +3 -3
- package/dist/cjs/groups/KeySets.js +3 -3
- package/dist/cjs/interaction/InteractionMessenger.d.ts +18 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +49 -19
- package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
- package/dist/cjs/mdns/InterfaceResponder.d.ts +137 -0
- package/dist/cjs/mdns/InterfaceResponder.d.ts.map +1 -0
- package/dist/cjs/mdns/InterfaceResponder.js +799 -0
- package/dist/cjs/mdns/InterfaceResponder.js.map +6 -0
- package/dist/cjs/mdns/MdnsServer.d.ts +82 -9
- package/dist/cjs/mdns/MdnsServer.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsServer.js +337 -267
- package/dist/cjs/mdns/MdnsServer.js.map +2 -2
- package/dist/cjs/mdns/MdnsService.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsService.js +3 -1
- package/dist/cjs/mdns/MdnsService.js.map +1 -1
- package/dist/cjs/peer/AdministratorCommands.d.ts +26 -0
- package/dist/cjs/peer/AdministratorCommands.d.ts.map +1 -0
- package/dist/cjs/peer/AdministratorCommands.js +40 -0
- package/dist/cjs/peer/AdministratorCommands.js.map +6 -0
- package/dist/cjs/peer/CommissioningConnection.d.ts.map +1 -1
- package/dist/cjs/peer/CommissioningConnection.js +4 -2
- package/dist/cjs/peer/CommissioningConnection.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.d.ts +9 -0
- package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js +59 -13
- package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts +7 -7
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +124 -67
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/peer/OperationalCertificateUpdate.d.ts +181 -0
- package/dist/cjs/peer/OperationalCertificateUpdate.d.ts.map +1 -0
- package/dist/cjs/peer/OperationalCertificateUpdate.js +553 -0
- package/dist/cjs/peer/OperationalCertificateUpdate.js.map +6 -0
- package/dist/cjs/peer/Peer.d.ts +5 -0
- package/dist/cjs/peer/Peer.d.ts.map +1 -1
- package/dist/cjs/peer/Peer.js +29 -1
- package/dist/cjs/peer/Peer.js.map +1 -1
- package/dist/cjs/peer/PeerAddressStore.d.ts +37 -0
- package/dist/cjs/peer/PeerAddressStore.d.ts.map +1 -0
- package/dist/cjs/peer/PeerAddressStore.js +114 -0
- package/dist/cjs/peer/PeerAddressStore.js.map +6 -0
- package/dist/cjs/peer/PeerConnection.d.ts.map +1 -1
- package/dist/cjs/peer/PeerConnection.js +0 -1
- package/dist/cjs/peer/PeerConnection.js.map +1 -1
- package/dist/cjs/peer/PeerDescriptor.d.ts +3 -4
- package/dist/cjs/peer/PeerDescriptor.d.ts.map +1 -1
- package/dist/cjs/peer/PeerDescriptor.js.map +1 -1
- package/dist/cjs/peer/PeerExchangeProvider.d.ts.map +1 -1
- package/dist/cjs/peer/PeerExchangeProvider.js +2 -1
- package/dist/cjs/peer/PeerExchangeProvider.js.map +1 -1
- package/dist/cjs/peer/PeerLossContext.d.ts +10 -2
- package/dist/cjs/peer/PeerLossContext.d.ts.map +1 -1
- package/dist/cjs/peer/PhysicalDeviceProperties.d.ts +13 -0
- package/dist/cjs/peer/PhysicalDeviceProperties.d.ts.map +1 -1
- package/dist/cjs/peer/PhysicalDeviceProperties.js +3 -2
- package/dist/cjs/peer/PhysicalDeviceProperties.js.map +1 -1
- package/dist/cjs/peer/RebootResubscribeArmer.d.ts +3 -3
- package/dist/cjs/peer/RebootResubscribeArmer.d.ts.map +1 -1
- package/dist/cjs/peer/RebootResubscribeArmer.js +21 -9
- package/dist/cjs/peer/RebootResubscribeArmer.js.map +1 -1
- package/dist/cjs/peer/index.d.ts +2 -0
- package/dist/cjs/peer/index.d.ts.map +1 -1
- package/dist/cjs/peer/index.js +2 -0
- package/dist/cjs/peer/index.js.map +1 -1
- package/dist/cjs/protocol/DeviceAdvertiser.d.ts.map +1 -1
- package/dist/cjs/protocol/DeviceAdvertiser.js +1 -1
- package/dist/cjs/protocol/DeviceAdvertiser.js.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.d.ts +0 -1
- package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.js +136 -64
- package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
- package/dist/cjs/protocol/ExchangeProvider.d.ts +3 -2
- package/dist/cjs/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeProvider.js.map +1 -1
- package/dist/cjs/protocol/MessageExchange.d.ts +13 -0
- package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/cjs/protocol/MessageExchange.js +23 -7
- package/dist/cjs/protocol/MessageExchange.js.map +1 -1
- package/dist/cjs/protocol/MessageReceptionState.d.ts +1 -1
- package/dist/cjs/protocol/errors.d.ts +7 -1
- package/dist/cjs/protocol/errors.d.ts.map +1 -1
- package/dist/cjs/protocol/errors.js +3 -0
- package/dist/cjs/protocol/errors.js.map +1 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.d.ts +6 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.d.ts.map +1 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.js +27 -12
- package/dist/cjs/securechannel/SecureChannelMessenger.js.map +1 -1
- package/dist/cjs/session/GroupSession.d.ts +58 -15
- package/dist/cjs/session/GroupSession.d.ts.map +1 -1
- package/dist/cjs/session/GroupSession.js +97 -102
- package/dist/cjs/session/GroupSession.js.map +2 -2
- package/dist/cjs/session/NodeSession.d.ts +50 -1
- package/dist/cjs/session/NodeSession.d.ts.map +1 -1
- package/dist/cjs/session/NodeSession.js +80 -4
- package/dist/cjs/session/NodeSession.js.map +1 -1
- package/dist/cjs/session/SecureSession.d.ts +9 -0
- package/dist/cjs/session/SecureSession.d.ts.map +1 -1
- package/dist/cjs/session/SecureSession.js +12 -0
- package/dist/cjs/session/SecureSession.js.map +1 -1
- package/dist/cjs/session/Session.d.ts +2 -2
- package/dist/cjs/session/Session.d.ts.map +1 -1
- package/dist/cjs/session/Session.js +1 -1
- package/dist/cjs/session/SessionManager.d.ts +76 -28
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +316 -153
- package/dist/cjs/session/SessionManager.js.map +2 -2
- package/dist/cjs/session/UnsecuredSession.d.ts +0 -1
- package/dist/cjs/session/UnsecuredSession.d.ts.map +1 -1
- package/dist/cjs/session/UnsecuredSession.js +2 -4
- package/dist/cjs/session/UnsecuredSession.js.map +1 -1
- package/dist/cjs/session/case/CaseClient.d.ts +5 -0
- package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseClient.js +12 -11
- package/dist/cjs/session/case/CaseClient.js.map +2 -2
- package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseServer.js +31 -11
- package/dist/cjs/session/case/CaseServer.js.map +1 -1
- package/dist/esm/action/Val.d.ts +8 -0
- package/dist/esm/action/Val.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.js +45 -32
- package/dist/esm/action/client/ClientInteraction.js.map +1 -1
- package/dist/esm/action/client/ClientRequest.d.ts +14 -0
- package/dist/esm/action/client/ClientRequest.d.ts.map +1 -1
- package/dist/esm/action/client/InputChunk.js +39 -2
- package/dist/esm/action/client/InputChunk.js.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscription.d.ts +2 -0
- package/dist/esm/action/client/subscription/ClientSubscription.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscription.js +4 -0
- package/dist/esm/action/client/subscription/ClientSubscription.js.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js +14 -0
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/esm/action/client/subscription/PeerSubscription.d.ts +32 -0
- package/dist/esm/action/client/subscription/PeerSubscription.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/PeerSubscription.js +61 -0
- package/dist/esm/action/client/subscription/PeerSubscription.js.map +1 -1
- package/dist/esm/action/errors.d.ts +3 -1
- package/dist/esm/action/errors.d.ts.map +1 -1
- package/dist/esm/action/errors.js +7 -2
- package/dist/esm/action/errors.js.map +1 -1
- package/dist/esm/action/protocols.d.ts +6 -1
- package/dist/esm/action/protocols.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.d.ts +24 -1
- package/dist/esm/action/request/Invoke.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.js +41 -13
- package/dist/esm/action/request/Invoke.js.map +1 -1
- package/dist/esm/action/request/Write.d.ts.map +1 -1
- package/dist/esm/action/request/Write.js +7 -6
- package/dist/esm/action/request/Write.js.map +1 -1
- package/dist/esm/action/response/InvokeResult.d.ts +8 -2
- package/dist/esm/action/response/InvokeResult.d.ts.map +1 -1
- package/dist/esm/action/response/InvokeResult.js +26 -0
- package/dist/esm/action/response/InvokeResult.js.map +2 -2
- package/dist/esm/action/response/ReadResult.d.ts +14 -5
- package/dist/esm/action/response/ReadResult.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.js +2 -2
- package/dist/esm/action/server/AttributeReadResponse.js.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.js +11 -3
- package/dist/esm/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/esm/action/server/EventReadResponse.d.ts.map +1 -1
- package/dist/esm/action/server/EventReadResponse.js +1 -0
- package/dist/esm/action/server/EventReadResponse.js.map +1 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertisement.d.ts +1 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertisement.d.ts.map +1 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertisement.js +7 -7
- package/dist/esm/advertisement/mdns/MdnsAdvertisement.js.map +1 -1
- package/dist/esm/ble/Ble.d.ts +2 -0
- package/dist/esm/ble/Ble.d.ts.map +1 -1
- package/dist/esm/ble/Ble.js +4 -0
- package/dist/esm/ble/Ble.js.map +1 -1
- package/dist/esm/certificate/CdSigners.d.ts +52 -0
- package/dist/esm/certificate/CdSigners.d.ts.map +1 -0
- package/dist/esm/certificate/CdSigners.js +91 -0
- package/dist/esm/certificate/CdSigners.js.map +6 -0
- package/dist/esm/certificate/CertificateAuthority.d.ts +1 -1
- package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceAttestationValidator.d.ts +59 -7
- package/dist/esm/certificate/DeviceAttestationValidator.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceAttestationValidator.js +124 -45
- package/dist/esm/certificate/DeviceAttestationValidator.js.map +1 -1
- package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceCertification.js +5 -2
- package/dist/esm/certificate/DeviceCertification.js.map +1 -1
- package/dist/esm/certificate/NocsrValidator.d.ts +57 -0
- package/dist/esm/certificate/NocsrValidator.d.ts.map +1 -0
- package/dist/esm/certificate/NocsrValidator.js +89 -0
- package/dist/esm/certificate/NocsrValidator.js.map +6 -0
- package/dist/esm/certificate/PeerData.d.ts +12 -0
- package/dist/esm/certificate/PeerData.d.ts.map +1 -0
- package/dist/esm/certificate/PeerData.js +13 -0
- package/dist/esm/certificate/PeerData.js.map +6 -0
- package/dist/esm/certificate/index.d.ts +2 -0
- package/dist/esm/certificate/index.d.ts.map +1 -1
- package/dist/esm/certificate/index.js +2 -0
- package/dist/esm/certificate/index.js.map +1 -1
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts +42 -6
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/AttestationCertificates.js +112 -15
- package/dist/esm/certificate/kinds/AttestationCertificates.js.map +1 -1
- package/dist/esm/certificate/kinds/Certificate.d.ts +13 -7
- package/dist/esm/certificate/kinds/Certificate.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Certificate.js +153 -256
- package/dist/esm/certificate/kinds/Certificate.js.map +2 -2
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts +21 -3
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/CertificationDeclaration.js +79 -20
- package/dist/esm/certificate/kinds/CertificationDeclaration.js.map +1 -1
- package/dist/esm/certificate/kinds/DistinguishedName.d.ts +190 -0
- package/dist/esm/certificate/kinds/DistinguishedName.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/DistinguishedName.js +422 -0
- package/dist/esm/certificate/kinds/DistinguishedName.js.map +6 -0
- package/dist/esm/certificate/kinds/Icac.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Icac.js +6 -11
- package/dist/esm/certificate/kinds/Icac.js.map +1 -1
- package/dist/esm/certificate/kinds/Noc.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Noc.js +5 -4
- package/dist/esm/certificate/kinds/Noc.js.map +1 -1
- package/dist/esm/certificate/kinds/OperationalBase.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/OperationalBase.js +4 -2
- package/dist/esm/certificate/kinds/OperationalBase.js.map +1 -1
- package/dist/esm/certificate/kinds/Rcac.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Rcac.js +6 -11
- package/dist/esm/certificate/kinds/Rcac.js.map +1 -1
- package/dist/esm/certificate/kinds/Vvsc.d.ts +3 -3
- package/dist/esm/certificate/kinds/Vvsc.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Vvsc.js +20 -15
- package/dist/esm/certificate/kinds/Vvsc.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/asn.d.ts +1 -1
- package/dist/esm/certificate/kinds/definitions/asn.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/definitions/asn.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/attestation.d.ts +15 -15
- package/dist/esm/certificate/kinds/definitions/attestation.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/definitions/base.d.ts +33 -0
- package/dist/esm/certificate/kinds/definitions/base.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/definitions/base.js +9 -2
- package/dist/esm/certificate/kinds/definitions/base.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/operational.d.ts +24 -20
- package/dist/esm/certificate/kinds/definitions/operational.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/definitions/operational.js +5 -3
- package/dist/esm/certificate/kinds/definitions/operational.js.map +1 -1
- package/dist/esm/codec/MessageCodec.d.ts +27 -2
- package/dist/esm/codec/MessageCodec.d.ts.map +1 -1
- package/dist/esm/codec/MessageCodec.js +82 -75
- package/dist/esm/codec/MessageCodec.js.map +1 -1
- package/dist/esm/common/OperationalCredentialsTypes.d.ts +6 -0
- package/dist/esm/common/OperationalCredentialsTypes.d.ts.map +1 -1
- package/dist/esm/common/OperationalCredentialsTypes.js +2 -0
- package/dist/esm/common/OperationalCredentialsTypes.js.map +1 -1
- package/dist/esm/dcl/DclCertificateService.d.ts +28 -7
- package/dist/esm/dcl/DclCertificateService.d.ts.map +1 -1
- package/dist/esm/dcl/DclCertificateService.js +108 -31
- package/dist/esm/dcl/DclCertificateService.js.map +1 -1
- package/dist/esm/fabric/Fabric.d.ts +10 -5
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +12 -5
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/fabric/FabricManager.d.ts +2 -2
- package/dist/esm/fabric/FabricManager.js +2 -2
- package/dist/esm/groups/FabricGroups.d.ts +2 -0
- package/dist/esm/groups/FabricGroups.d.ts.map +1 -1
- package/dist/esm/groups/FabricGroups.js +4 -0
- package/dist/esm/groups/FabricGroups.js.map +1 -1
- package/dist/esm/groups/Groups.d.ts +7 -0
- package/dist/esm/groups/Groups.d.ts.map +1 -1
- package/dist/esm/groups/Groups.js +11 -2
- package/dist/esm/groups/Groups.js.map +1 -1
- package/dist/esm/groups/KeySets.d.ts +3 -3
- package/dist/esm/groups/KeySets.js +3 -3
- package/dist/esm/interaction/InteractionMessenger.d.ts +18 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +50 -20
- package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
- package/dist/esm/mdns/InterfaceResponder.d.ts +137 -0
- package/dist/esm/mdns/InterfaceResponder.d.ts.map +1 -0
- package/dist/esm/mdns/InterfaceResponder.js +794 -0
- package/dist/esm/mdns/InterfaceResponder.js.map +6 -0
- package/dist/esm/mdns/MdnsServer.d.ts +82 -9
- package/dist/esm/mdns/MdnsServer.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsServer.js +341 -273
- package/dist/esm/mdns/MdnsServer.js.map +2 -2
- package/dist/esm/mdns/MdnsService.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsService.js +3 -1
- package/dist/esm/mdns/MdnsService.js.map +1 -1
- package/dist/esm/peer/AdministratorCommands.d.ts +26 -0
- package/dist/esm/peer/AdministratorCommands.d.ts.map +1 -0
- package/dist/esm/peer/AdministratorCommands.js +20 -0
- package/dist/esm/peer/AdministratorCommands.js.map +6 -0
- package/dist/esm/peer/CommissioningConnection.d.ts.map +1 -1
- package/dist/esm/peer/CommissioningConnection.js +4 -2
- package/dist/esm/peer/CommissioningConnection.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.d.ts +9 -0
- package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js +59 -13
- package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts +7 -7
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +125 -70
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/peer/OperationalCertificateUpdate.d.ts +181 -0
- package/dist/esm/peer/OperationalCertificateUpdate.d.ts.map +1 -0
- package/dist/esm/peer/OperationalCertificateUpdate.js +553 -0
- package/dist/esm/peer/OperationalCertificateUpdate.js.map +6 -0
- package/dist/esm/peer/Peer.d.ts +5 -0
- package/dist/esm/peer/Peer.d.ts.map +1 -1
- package/dist/esm/peer/Peer.js +29 -1
- package/dist/esm/peer/Peer.js.map +1 -1
- package/dist/esm/peer/PeerAddressStore.d.ts +37 -0
- package/dist/esm/peer/PeerAddressStore.d.ts.map +1 -0
- package/dist/esm/peer/PeerAddressStore.js +94 -0
- package/dist/esm/peer/PeerAddressStore.js.map +6 -0
- package/dist/esm/peer/PeerConnection.d.ts.map +1 -1
- package/dist/esm/peer/PeerConnection.js +0 -1
- package/dist/esm/peer/PeerConnection.js.map +1 -1
- package/dist/esm/peer/PeerDescriptor.d.ts +3 -4
- package/dist/esm/peer/PeerDescriptor.d.ts.map +1 -1
- package/dist/esm/peer/PeerDescriptor.js.map +1 -1
- package/dist/esm/peer/PeerExchangeProvider.d.ts.map +1 -1
- package/dist/esm/peer/PeerExchangeProvider.js +3 -2
- package/dist/esm/peer/PeerExchangeProvider.js.map +1 -1
- package/dist/esm/peer/PeerLossContext.d.ts +10 -2
- package/dist/esm/peer/PeerLossContext.d.ts.map +1 -1
- package/dist/esm/peer/PhysicalDeviceProperties.d.ts +13 -0
- package/dist/esm/peer/PhysicalDeviceProperties.d.ts.map +1 -1
- package/dist/esm/peer/PhysicalDeviceProperties.js +3 -2
- package/dist/esm/peer/PhysicalDeviceProperties.js.map +1 -1
- package/dist/esm/peer/RebootResubscribeArmer.d.ts +3 -3
- package/dist/esm/peer/RebootResubscribeArmer.d.ts.map +1 -1
- package/dist/esm/peer/RebootResubscribeArmer.js +21 -9
- package/dist/esm/peer/RebootResubscribeArmer.js.map +1 -1
- package/dist/esm/peer/index.d.ts +2 -0
- package/dist/esm/peer/index.d.ts.map +1 -1
- package/dist/esm/peer/index.js +2 -0
- package/dist/esm/peer/index.js.map +1 -1
- package/dist/esm/protocol/DeviceAdvertiser.d.ts.map +1 -1
- package/dist/esm/protocol/DeviceAdvertiser.js +1 -1
- package/dist/esm/protocol/DeviceAdvertiser.js.map +1 -1
- package/dist/esm/protocol/ExchangeManager.d.ts +0 -1
- package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeManager.js +145 -67
- package/dist/esm/protocol/ExchangeManager.js.map +1 -1
- package/dist/esm/protocol/ExchangeProvider.d.ts +3 -2
- package/dist/esm/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeProvider.js.map +1 -1
- package/dist/esm/protocol/MessageExchange.d.ts +13 -0
- package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/esm/protocol/MessageExchange.js +23 -7
- package/dist/esm/protocol/MessageExchange.js.map +1 -1
- package/dist/esm/protocol/MessageReceptionState.d.ts +1 -1
- package/dist/esm/protocol/errors.d.ts +7 -1
- package/dist/esm/protocol/errors.d.ts.map +1 -1
- package/dist/esm/protocol/errors.js +4 -1
- package/dist/esm/protocol/errors.js.map +1 -1
- package/dist/esm/securechannel/SecureChannelMessenger.d.ts +6 -1
- package/dist/esm/securechannel/SecureChannelMessenger.d.ts.map +1 -1
- package/dist/esm/securechannel/SecureChannelMessenger.js +27 -12
- package/dist/esm/securechannel/SecureChannelMessenger.js.map +1 -1
- package/dist/esm/session/GroupSession.d.ts +58 -15
- package/dist/esm/session/GroupSession.d.ts.map +1 -1
- package/dist/esm/session/GroupSession.js +97 -102
- package/dist/esm/session/GroupSession.js.map +2 -2
- package/dist/esm/session/NodeSession.d.ts +50 -1
- package/dist/esm/session/NodeSession.d.ts.map +1 -1
- package/dist/esm/session/NodeSession.js +83 -5
- package/dist/esm/session/NodeSession.js.map +1 -1
- package/dist/esm/session/SecureSession.d.ts +9 -0
- package/dist/esm/session/SecureSession.d.ts.map +1 -1
- package/dist/esm/session/SecureSession.js +18 -1
- package/dist/esm/session/SecureSession.js.map +1 -1
- package/dist/esm/session/Session.d.ts +2 -2
- package/dist/esm/session/Session.d.ts.map +1 -1
- package/dist/esm/session/Session.js +1 -1
- package/dist/esm/session/SessionManager.d.ts +76 -28
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +319 -156
- package/dist/esm/session/SessionManager.js.map +2 -2
- package/dist/esm/session/UnsecuredSession.d.ts +0 -1
- package/dist/esm/session/UnsecuredSession.d.ts.map +1 -1
- package/dist/esm/session/UnsecuredSession.js +5 -3
- package/dist/esm/session/UnsecuredSession.js.map +1 -1
- package/dist/esm/session/case/CaseClient.d.ts +5 -0
- package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
- package/dist/esm/session/case/CaseClient.js +12 -11
- package/dist/esm/session/case/CaseClient.js.map +2 -2
- package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
- package/dist/esm/session/case/CaseServer.js +31 -11
- package/dist/esm/session/case/CaseServer.js.map +1 -1
- package/package.json +5 -5
- package/src/action/Val.ts +8 -0
- package/src/action/client/ClientInteraction.ts +57 -33
- package/src/action/client/ClientRequest.ts +15 -0
- package/src/action/client/InputChunk.ts +57 -2
- package/src/action/client/subscription/ClientSubscription.ts +5 -0
- package/src/action/client/subscription/ClientSubscriptionHandler.ts +15 -0
- package/src/action/client/subscription/PeerSubscription.ts +73 -0
- package/src/action/errors.ts +10 -3
- package/src/action/protocols.ts +7 -1
- package/src/action/request/Invoke.ts +60 -15
- package/src/action/request/Write.ts +7 -6
- package/src/action/response/InvokeResult.ts +32 -2
- package/src/action/response/ReadResult.ts +15 -5
- package/src/action/server/AttributeReadResponse.ts +3 -2
- package/src/action/server/AttributeWriteResponse.ts +14 -3
- package/src/action/server/EventReadResponse.ts +1 -0
- package/src/advertisement/mdns/MdnsAdvertisement.ts +9 -9
- package/src/ble/Ble.ts +5 -0
- package/src/certificate/CdSigners.ts +137 -0
- package/src/certificate/CertificateAuthority.ts +1 -1
- package/src/certificate/DeviceAttestationValidator.ts +213 -56
- package/src/certificate/DeviceCertification.ts +6 -2
- package/src/certificate/NocsrValidator.ts +140 -0
- package/src/certificate/PeerData.ts +15 -0
- package/src/certificate/index.ts +2 -0
- package/src/certificate/kinds/AttestationCertificates.ts +183 -15
- package/src/certificate/kinds/Certificate.ts +203 -308
- package/src/certificate/kinds/CertificationDeclaration.ts +100 -46
- package/src/certificate/kinds/DistinguishedName.ts +677 -0
- package/src/certificate/kinds/Icac.ts +7 -12
- package/src/certificate/kinds/Noc.ts +12 -8
- package/src/certificate/kinds/OperationalBase.ts +5 -2
- package/src/certificate/kinds/Rcac.ts +7 -12
- package/src/certificate/kinds/Vvsc.ts +24 -15
- package/src/certificate/kinds/definitions/asn.ts +1 -1
- package/src/certificate/kinds/definitions/attestation.ts +15 -15
- package/src/certificate/kinds/definitions/base.ts +43 -1
- package/src/certificate/kinds/definitions/operational.ts +4 -3
- package/src/codec/MessageCodec.ts +92 -81
- package/src/common/OperationalCredentialsTypes.ts +7 -0
- package/src/dcl/DclCertificateService.ts +135 -36
- package/src/fabric/Fabric.ts +13 -6
- package/src/fabric/FabricManager.ts +2 -2
- package/src/groups/FabricGroups.ts +5 -0
- package/src/groups/Groups.ts +12 -3
- package/src/groups/KeySets.ts +3 -3
- package/src/interaction/InteractionMessenger.ts +58 -20
- package/src/mdns/InterfaceResponder.ts +1031 -0
- package/src/mdns/MdnsServer.ts +400 -360
- package/src/mdns/MdnsService.ts +2 -0
- package/src/peer/AdministratorCommands.ts +37 -0
- package/src/peer/CommissioningConnection.ts +5 -1
- package/src/peer/ControllerCommissioner.ts +69 -19
- package/src/peer/ControllerCommissioningFlow.ts +149 -99
- package/src/peer/OperationalCertificateUpdate.ts +922 -0
- package/src/peer/Peer.ts +31 -16
- package/src/peer/PeerAddressStore.ts +119 -0
- package/src/peer/PeerConnection.ts +0 -1
- package/src/peer/PeerDescriptor.ts +3 -4
- package/src/peer/PeerExchangeProvider.ts +4 -6
- package/src/peer/PeerLossContext.ts +11 -2
- package/src/peer/PhysicalDeviceProperties.ts +25 -12
- package/src/peer/RebootResubscribeArmer.ts +37 -16
- package/src/peer/index.ts +2 -0
- package/src/protocol/DeviceAdvertiser.ts +5 -1
- package/src/protocol/ExchangeManager.ts +162 -88
- package/src/protocol/ExchangeProvider.ts +3 -2
- package/src/protocol/MessageExchange.ts +29 -7
- package/src/protocol/MessageReceptionState.ts +2 -2
- package/src/protocol/errors.ts +7 -1
- package/src/securechannel/SecureChannelMessenger.ts +26 -13
- package/src/session/GroupSession.ts +147 -111
- package/src/session/NodeSession.ts +89 -4
- package/src/session/SecureSession.ts +27 -1
- package/src/session/Session.ts +2 -2
- package/src/session/SessionManager.ts +429 -189
- package/src/session/UnsecuredSession.ts +9 -3
- package/src/session/case/CaseClient.ts +15 -10
- package/src/session/case/CaseServer.ts +41 -17
|
@@ -49,66 +49,64 @@ var __callDispose = (stack, error, hasError) => {
|
|
|
49
49
|
* SPDX-License-Identifier: Apache-2.0
|
|
50
50
|
*/
|
|
51
51
|
import {
|
|
52
|
-
|
|
52
|
+
ClosedError,
|
|
53
53
|
describeList,
|
|
54
54
|
Diagnostic,
|
|
55
55
|
DnsMessageType,
|
|
56
56
|
DnsMessageTypeFlag,
|
|
57
|
-
DnsRecordType,
|
|
58
|
-
Instant,
|
|
59
|
-
isDeepEqual,
|
|
60
57
|
Lifetime,
|
|
61
58
|
Logger,
|
|
62
|
-
|
|
59
|
+
MaybePromise,
|
|
63
60
|
Millis,
|
|
64
|
-
|
|
61
|
+
Mutex,
|
|
65
62
|
ObserverGroup,
|
|
63
|
+
Seconds,
|
|
66
64
|
Time
|
|
67
65
|
} from "@matter/general";
|
|
66
|
+
import { InterfaceResponder } from "./InterfaceResponder.js";
|
|
68
67
|
const logger = Logger.get("MdnsServer");
|
|
69
68
|
const RESPONDER_NAMES_OWNER = "mdns-responder";
|
|
70
|
-
const
|
|
69
|
+
const CHANGE_REPEAT_INTERVAL = Seconds(1);
|
|
71
70
|
class MdnsServer {
|
|
72
71
|
#lifetime;
|
|
73
72
|
#observers = new ObserverGroup();
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
#
|
|
73
|
+
#registrations = /* @__PURE__ */ new Map();
|
|
74
|
+
#generation = 0;
|
|
75
|
+
#responders = /* @__PURE__ */ new Map();
|
|
76
|
+
#owner;
|
|
77
|
+
#hostnameChoice = new Mutex(this);
|
|
78
|
+
#closing;
|
|
79
|
+
#pendingAnnouncement;
|
|
79
80
|
#hostname;
|
|
80
|
-
#recordLastSentAsMulticastAnswer = /* @__PURE__ */ new Map();
|
|
81
81
|
#truncatedQueryCache = /* @__PURE__ */ new Map();
|
|
82
|
-
|
|
83
|
-
#
|
|
82
|
+
#interfacesChangedObserver = (names) => this.#handleInterfacesChanged(names);
|
|
83
|
+
#isFollowingInterfaces = false;
|
|
84
|
+
/** The interfaces to publish on again when {@link #changeRepeat} fires */
|
|
85
|
+
#repeatOn;
|
|
86
|
+
#changeRepeat;
|
|
84
87
|
#socket;
|
|
85
88
|
constructor(socket, lifetime = Lifetime.process) {
|
|
86
89
|
this.#socket = socket;
|
|
87
90
|
this.#lifetime = lifetime.join("mdns server");
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const addrs = await this.network.getIpMac(multicastInterface);
|
|
95
|
-
if (addrs === void 0) {
|
|
96
|
-
return { byService, ownedNames };
|
|
97
|
-
}
|
|
98
|
-
const hostname = this.#hostname ?? hostnameForMac(addrs.mac);
|
|
99
|
-
for (const [service, generator] of this.#recordsGenerator) {
|
|
100
|
-
const records = generator(multicastInterface, addrs, hostname);
|
|
101
|
-
byService.set(service, records);
|
|
102
|
-
for (const record of records) {
|
|
103
|
-
ownedNames.add(record.name.toLowerCase());
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
this.#registerResponderNames(ownedNames);
|
|
107
|
-
return { byService, ownedNames };
|
|
91
|
+
const server = this;
|
|
92
|
+
this.#owner = {
|
|
93
|
+
socket,
|
|
94
|
+
registrations: this.#registrations,
|
|
95
|
+
get generation() {
|
|
96
|
+
return server.#generation;
|
|
108
97
|
},
|
|
109
|
-
|
|
110
|
-
|
|
98
|
+
hostnameFor: (details) => this.#hostname ?? hostnameForMac(details.mac),
|
|
99
|
+
viewChanged: () => this.#updateNames()
|
|
100
|
+
};
|
|
111
101
|
this.#observers.on(this.#socket.receipt, this.#handleMessage.bind(this));
|
|
102
|
+
this.#changeRepeat = Time.getTimer(
|
|
103
|
+
"mDNS interface change repeat",
|
|
104
|
+
CHANGE_REPEAT_INTERVAL,
|
|
105
|
+
() => this.#repeatChange()
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
toString() {
|
|
109
|
+
return "mDNS server";
|
|
112
110
|
}
|
|
113
111
|
get network() {
|
|
114
112
|
return this.#socket.network;
|
|
@@ -116,207 +114,356 @@ class MdnsServer {
|
|
|
116
114
|
get supportsIpv4() {
|
|
117
115
|
return this.#socket.supportsIpv4;
|
|
118
116
|
}
|
|
119
|
-
buildDnsRecordKey(record, netInterface, unicastTarget) {
|
|
120
|
-
return `${record.name.toLowerCase()}-${record.recordClass}-${record.recordType}-${netInterface}-${unicastTarget}`;
|
|
121
|
-
}
|
|
122
117
|
async #handleMessage(incomingMessage) {
|
|
123
118
|
var _stack = [];
|
|
124
119
|
try {
|
|
125
120
|
const _processing = __using(_stack, this.#lifetime.join("processing message"));
|
|
126
|
-
|
|
127
|
-
if (byService.size === 0) {
|
|
121
|
+
if (this.#registrations.size === 0) {
|
|
128
122
|
return;
|
|
129
123
|
}
|
|
130
124
|
const message = this.#prepareMessage(incomingMessage);
|
|
131
125
|
if (message === void 0) {
|
|
132
126
|
return;
|
|
133
127
|
}
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
let responder;
|
|
129
|
+
try {
|
|
130
|
+
responder = await this.#withCurrentDetails(message.sourceIntf);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
this.#detailsUnavailable(`Cannot answer a query on interface ${message.sourceIntf}`, error);
|
|
136
133
|
return;
|
|
137
134
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
sourceIntf,
|
|
194
|
-
uniCastResponse ? sourceIp : void 0
|
|
195
|
-
).catch((error) => {
|
|
196
|
-
logger.warn(`Failed to send mDNS response to ${sourceIp}`, error);
|
|
197
|
-
});
|
|
198
|
-
sentPreviousPacket = true;
|
|
135
|
+
await responder.answer(message);
|
|
136
|
+
} catch (_) {
|
|
137
|
+
var _error = _, _hasError = true;
|
|
138
|
+
} finally {
|
|
139
|
+
__callDispose(_stack, _error, _hasError);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Register the records that {@link generator} produces for {@link service}, replacing the registration under that
|
|
144
|
+
* name. The server answers queries for them from now on, but announces nothing until a {@link broadcast}. A
|
|
145
|
+
* broadcast or withdrawal of another service, or a goodbye retry, announces it too when its records replace
|
|
146
|
+
* records peers cache, see {@link InterfaceResponder.publish}. The registration is in place before the first
|
|
147
|
+
* await; resolves once the host name is chosen again.
|
|
148
|
+
*
|
|
149
|
+
* Use the returned handle to call the generator again or to withdraw the service. A replaced registration's
|
|
150
|
+
* handle does nothing. Once {@link close} started, also while this runs, the handle is inert and nothing stays
|
|
151
|
+
* registered. If {@link generator} throws while an interface has details, the registration is removed again and
|
|
152
|
+
* the error is rethrown; without details the generator first runs at the next answer or announcement.
|
|
153
|
+
*/
|
|
154
|
+
async register(service, generator) {
|
|
155
|
+
const registration = {
|
|
156
|
+
service,
|
|
157
|
+
refresh: () => this.#refresh(registration),
|
|
158
|
+
withdraw: () => this.#withdraw(registration),
|
|
159
|
+
[Symbol.asyncDispose]: () => registration.withdraw()
|
|
160
|
+
};
|
|
161
|
+
this.#registrations.set(service, { registration, generator });
|
|
162
|
+
this.#registrationsChanged();
|
|
163
|
+
try {
|
|
164
|
+
await this.#updateHost();
|
|
165
|
+
} catch (error) {
|
|
166
|
+
this.#unregister(registration);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
if (this.#closing !== void 0) {
|
|
170
|
+
logger.debug(`Not registering ${service}, ${this} is closed`);
|
|
171
|
+
this.#unregister(registration);
|
|
172
|
+
}
|
|
173
|
+
return registration;
|
|
174
|
+
}
|
|
175
|
+
async #refresh(registration) {
|
|
176
|
+
if (!this.#isRegistered(registration)) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.#registrationsChanged();
|
|
180
|
+
await this.#updateHost();
|
|
181
|
+
}
|
|
182
|
+
async #withdraw(registration) {
|
|
183
|
+
var _stack = [];
|
|
184
|
+
try {
|
|
185
|
+
const { service } = registration;
|
|
186
|
+
const _withdrawing = __using(_stack, this.#lifetime.join("withdrawing", Diagnostic.strong(service)));
|
|
187
|
+
if (!this.#unregister(registration)) {
|
|
188
|
+
return;
|
|
199
189
|
}
|
|
190
|
+
await Promise.all(
|
|
191
|
+
this.#currentResponders().map(
|
|
192
|
+
(responder) => responder.publish([]).catch((error) => this.#logPublishFailure(`Goodbye for ${service}`, responder, error))
|
|
193
|
+
)
|
|
194
|
+
);
|
|
200
195
|
} catch (_) {
|
|
201
196
|
var _error = _, _hasError = true;
|
|
202
197
|
} finally {
|
|
203
198
|
__callDispose(_stack, _error, _hasError);
|
|
204
199
|
}
|
|
205
200
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
);
|
|
201
|
+
/** Remove {@link registration} if it is the current one for its service; returns whether it was. */
|
|
202
|
+
#unregister(registration) {
|
|
203
|
+
if (!this.#isRegistered(registration)) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
this.#registrations.delete(registration.service);
|
|
207
|
+
this.#registrationsChanged();
|
|
208
|
+
this.#updateNames();
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
#logPublishFailure(what, responder, error) {
|
|
212
|
+
if (this.#lifetime.isClosing || !responder.isListed) {
|
|
213
|
+
logger.debug(`${what} not sent on interface ${responder.name}`, error);
|
|
214
|
+
} else {
|
|
215
|
+
logger.warn(`${what} not sent on interface ${responder.name}`, error);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** A failed details read is logged by the responder, see {@link InterfaceResponder.readDetails}. */
|
|
219
|
+
#detailsUnavailable(what, error) {
|
|
220
|
+
if (error instanceof ClosedError) {
|
|
221
|
+
logger.debug(`${what}, ${this} is closed`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
#isRegistered(registration) {
|
|
225
|
+
return this.#registrations.get(registration.service)?.registration === registration;
|
|
214
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Announce the named services, or all registered services if none are named, on every multicast interface.
|
|
229
|
+
* Requests made before the event loop turns are sent together, in one message per interface, split into
|
|
230
|
+
* datagrams by size, that also says goodbye to records that left; so advertisements that announce in the same
|
|
231
|
+
* turn share one announcement with each shared record once. An announcement is never held by the one-second rule
|
|
232
|
+
* of RFC 6762 §6. A service whose records replace records that get a goodbye is announced too, as after a change
|
|
233
|
+
* of the host name, see {@link InterfaceResponder.publish}.
|
|
234
|
+
*
|
|
235
|
+
* Logs and does not throw on failure.
|
|
236
|
+
*/
|
|
215
237
|
async broadcast(...services) {
|
|
216
238
|
var _stack = [];
|
|
217
239
|
try {
|
|
218
240
|
const _broadcasting = __using(_stack, this.#lifetime.join("broadcasting", Diagnostic.strong(describeList("and", ...services))));
|
|
219
|
-
await
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
241
|
+
await this.#announce(services.length ? services : "all");
|
|
242
|
+
} catch (_) {
|
|
243
|
+
var _error = _, _hasError = true;
|
|
244
|
+
} finally {
|
|
245
|
+
__callDispose(_stack, _error, _hasError);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Join the pending announcement, or start one that goes out in the next macrotask. A macrotask, not a timer:
|
|
250
|
+
* advertisements that start together register and broadcast within one event-loop turn, because the interface
|
|
251
|
+
* lookups behind registration are synchronous on Node.js, and a longer window would delay every announcement.
|
|
252
|
+
*/
|
|
253
|
+
#announce(services) {
|
|
254
|
+
const pending = this.#pendingAnnouncement ??= this.#startAnnouncement();
|
|
255
|
+
if (services === "all") {
|
|
256
|
+
pending.all = true;
|
|
257
|
+
} else {
|
|
258
|
+
for (const service of services) {
|
|
259
|
+
pending.services.add(service);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return pending.done;
|
|
263
|
+
}
|
|
264
|
+
#startAnnouncement() {
|
|
265
|
+
const request = { services: /* @__PURE__ */ new Set(), all: false };
|
|
266
|
+
return Object.assign(request, { done: Time.macrotask.then(() => this.#sendAnnouncement(request)) });
|
|
267
|
+
}
|
|
268
|
+
async #sendAnnouncement(request) {
|
|
269
|
+
if (this.#pendingAnnouncement === request) {
|
|
270
|
+
this.#pendingAnnouncement = void 0;
|
|
271
|
+
}
|
|
272
|
+
await this.#publishOnListedInterfaces(request.all ? "all" : [...request.services]);
|
|
273
|
+
}
|
|
274
|
+
/** Publish on each listed interface, or only on those in {@link only}. */
|
|
275
|
+
async #publishOnListedInterfaces(services, only) {
|
|
276
|
+
try {
|
|
277
|
+
const listed = await this.#listInterfaces();
|
|
278
|
+
await Promise.all(
|
|
279
|
+
listed.map(async ({ name }) => {
|
|
280
|
+
if (only !== void 0 && !only.has(name)) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const responder = this.#interfaceFor(name);
|
|
284
|
+
try {
|
|
285
|
+
await this.#withCurrentDetails(name);
|
|
286
|
+
} catch (error) {
|
|
287
|
+
this.#detailsUnavailable(`Announcement not sent on interface ${name}`, error);
|
|
288
|
+
return;
|
|
230
289
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
290
|
+
try {
|
|
291
|
+
await responder.publish(services);
|
|
292
|
+
} catch (error) {
|
|
293
|
+
this.#logPublishFailure("Announcement", responder, error);
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
);
|
|
297
|
+
} catch (error) {
|
|
298
|
+
if (this.#lifetime.isClosing) {
|
|
299
|
+
logger.debug("Error announcing MDNS messages while closing", error);
|
|
300
|
+
} else {
|
|
301
|
+
logger.warn("Error announcing MDNS messages", error);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
#registrationsChanged() {
|
|
306
|
+
this.#generation++;
|
|
307
|
+
this.#followInterfaces(this.#registrations.size > 0 && this.#closing === void 0);
|
|
308
|
+
}
|
|
309
|
+
/** Interface changes matter only while services are registered, and observing them starts the periodic checks. */
|
|
310
|
+
#followInterfaces(follow) {
|
|
311
|
+
if (follow === this.#isFollowingInterfaces) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
this.#isFollowingInterfaces = follow;
|
|
315
|
+
if (follow) {
|
|
316
|
+
this.network.interfacesChanged.on(this.#interfacesChangedObserver);
|
|
317
|
+
} else {
|
|
318
|
+
this.network.interfacesChanged.off(this.#interfacesChangedObserver);
|
|
319
|
+
this.#changeRepeat.stop();
|
|
320
|
+
this.#repeatOn = void 0;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/** Logs and does not throw, so the other observers of {@link Network.interfacesChanged} still run. */
|
|
324
|
+
async #handleInterfacesChanged(names) {
|
|
325
|
+
var _stack = [];
|
|
326
|
+
try {
|
|
327
|
+
const _changing = __using(_stack, this.#lifetime.join("interface change", Diagnostic.strong(describeList("and", ...names))));
|
|
328
|
+
logger.debug(`Interfaces ${describeList("and", ...names)} changed, publishing the current records`);
|
|
329
|
+
try {
|
|
330
|
+
await this.#publishChange(names);
|
|
331
|
+
} catch (error) {
|
|
234
332
|
if (this.#lifetime.isClosing) {
|
|
235
|
-
logger.debug("
|
|
333
|
+
logger.debug("mDNS records not published after an interface change, the server closed", error);
|
|
236
334
|
} else {
|
|
237
|
-
logger.
|
|
335
|
+
logger.warn("Cannot publish the mDNS records after an interface change", error);
|
|
238
336
|
}
|
|
239
|
-
}
|
|
337
|
+
}
|
|
240
338
|
} catch (_) {
|
|
241
339
|
var _error = _, _hasError = true;
|
|
242
340
|
} finally {
|
|
243
341
|
__callDispose(_stack, _error, _hasError);
|
|
244
342
|
}
|
|
245
343
|
}
|
|
246
|
-
async
|
|
344
|
+
async #publishChange(names) {
|
|
345
|
+
const previousHostname = this.#hostname;
|
|
346
|
+
for (const name of names) {
|
|
347
|
+
this.#responders.get(name)?.detailsChanged();
|
|
348
|
+
}
|
|
349
|
+
await this.#updateHost();
|
|
350
|
+
if (!this.#isFollowingInterfaces) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const changed = this.#hostname === previousHostname ? new Set(names) : void 0;
|
|
354
|
+
if (changed === void 0 || this.#repeatOn === "all") {
|
|
355
|
+
this.#repeatOn = "all";
|
|
356
|
+
} else {
|
|
357
|
+
this.#repeatOn = /* @__PURE__ */ new Set([...this.#repeatOn ?? [], ...changed]);
|
|
358
|
+
}
|
|
359
|
+
this.#changeRepeat.stop().start();
|
|
360
|
+
await this.#publishOnListedInterfaces("all", changed);
|
|
361
|
+
}
|
|
362
|
+
async #repeatChange() {
|
|
247
363
|
var _stack = [];
|
|
248
364
|
try {
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
serviceRecords.forEach((record) => {
|
|
257
|
-
record.ttl = Instant;
|
|
258
|
-
});
|
|
259
|
-
if (sentPreviousPacket) {
|
|
260
|
-
await Time.sleep("MDNS delay", Millis(20 + Math.floor(Math.random() * 100)));
|
|
261
|
-
}
|
|
262
|
-
await this.#announceRecordsForInterface(netInterface, serviceRecords);
|
|
263
|
-
this.#recordsGenerator.delete(service);
|
|
264
|
-
sentPreviousPacket = true;
|
|
265
|
-
}
|
|
266
|
-
}),
|
|
267
|
-
"Error happened when expiring MDNS announcements"
|
|
268
|
-
).catch((error) => {
|
|
269
|
-
if (this.#lifetime.isClosing) {
|
|
270
|
-
logger.debug("Error happened when expiring MDNS announcements while closing", error);
|
|
271
|
-
} else {
|
|
272
|
-
logger.warn("Error happened when expiring MDNS announcements", error);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
await this.#resetServices();
|
|
365
|
+
const _repeating = __using(_stack, this.#lifetime.join("repeating interface change"));
|
|
366
|
+
const repeatOn = this.#repeatOn;
|
|
367
|
+
if (repeatOn === void 0) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
this.#repeatOn = void 0;
|
|
371
|
+
await this.#publishOnListedInterfaces("all", repeatOn === "all" ? void 0 : repeatOn);
|
|
276
372
|
} catch (_) {
|
|
277
373
|
var _error = _, _hasError = true;
|
|
278
374
|
} finally {
|
|
279
375
|
__callDispose(_stack, _error, _hasError);
|
|
280
376
|
}
|
|
281
377
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
await this.#
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
378
|
+
/** Read the interface details, choose the host name again and update the socket names. */
|
|
379
|
+
async #updateHost() {
|
|
380
|
+
await this.#hostnameChoice.produce(() => this.#chooseHostname());
|
|
381
|
+
this.#updateNames();
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Tell the socket the names of the records the current views publish, so it keeps queries for them before
|
|
385
|
+
* decoding. Runs on every registration change and every rebuild of a view. While no interface has details yet,
|
|
386
|
+
* the socket keeps the previous names; after the last withdrawal it keeps none, and once close started this does
|
|
387
|
+
* nothing, as close removed them.
|
|
388
|
+
*/
|
|
389
|
+
#updateNames() {
|
|
390
|
+
if (this.#closing !== void 0) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const names = /* @__PURE__ */ new Set();
|
|
394
|
+
for (const responder of this.#responders.values()) {
|
|
395
|
+
for (const name of responder.names()) {
|
|
396
|
+
names.add(name);
|
|
301
397
|
}
|
|
302
398
|
}
|
|
303
|
-
if (
|
|
304
|
-
|
|
399
|
+
if (!names.size && this.#registrations.size) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (names.size) {
|
|
403
|
+
this.#socket.registerRelevantNames(RESPONDER_NAMES_OWNER, names);
|
|
404
|
+
} else {
|
|
405
|
+
this.#socket.unregisterRelevantNames(RESPONDER_NAMES_OWNER);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
#interfaceFor(name) {
|
|
409
|
+
if (this.#closing !== void 0) {
|
|
410
|
+
throw new ClosedError(`${this} is closed, cannot use interface ${name}`);
|
|
411
|
+
}
|
|
412
|
+
let responder = this.#responders.get(name);
|
|
413
|
+
if (responder === void 0) {
|
|
414
|
+
responder = new InterfaceResponder(name, this.#owner);
|
|
415
|
+
this.#responders.set(name, responder);
|
|
305
416
|
}
|
|
417
|
+
return responder;
|
|
306
418
|
}
|
|
307
|
-
|
|
419
|
+
/** The responder of interface {@link name} with details read within their lifetime; reads them first if not. */
|
|
420
|
+
#withCurrentDetails(name) {
|
|
421
|
+
const responder = this.#interfaceFor(name);
|
|
422
|
+
if (!responder.needsDetailsRead) {
|
|
423
|
+
return responder;
|
|
424
|
+
}
|
|
425
|
+
return MaybePromise.then(responder.readDetails(), () => responder);
|
|
426
|
+
}
|
|
427
|
+
/** The responders, after dropping those whose state expired. */
|
|
428
|
+
#currentResponders() {
|
|
429
|
+
for (const responder of this.#responders.values()) {
|
|
430
|
+
if (responder.prune()) {
|
|
431
|
+
this.#responders.delete(responder.name);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return [...this.#responders.values()];
|
|
435
|
+
}
|
|
436
|
+
/** List the multicast interfaces and note on each responder whether its interface is listed. */
|
|
437
|
+
async #listInterfaces() {
|
|
438
|
+
const listed = await this.#getMulticastInterfacesForAnnounce();
|
|
439
|
+
const names = new Set(listed.map(({ name }) => name));
|
|
440
|
+
for (const responder of this.#currentResponders()) {
|
|
441
|
+
responder.isListed = names.has(responder.name);
|
|
442
|
+
}
|
|
443
|
+
return listed;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Stop answering and announcing. The goodbyes of a withdrawal that waits for its interface still go out. A
|
|
447
|
+
* service withdrawn after this started gets no goodbye, and neither do the records a refresh removed while the
|
|
448
|
+
* {@link broadcast} that would carry their goodbye still waits for its event-loop turn. Settles once the sends in
|
|
449
|
+
* flight settled; may be called again.
|
|
450
|
+
*/
|
|
451
|
+
close() {
|
|
452
|
+
this.#closing ??= this.#close();
|
|
453
|
+
return this.#closing;
|
|
454
|
+
}
|
|
455
|
+
async #close() {
|
|
308
456
|
var _stack = [];
|
|
309
457
|
try {
|
|
310
458
|
const _closing = __using(_stack, this.#lifetime.closing());
|
|
311
459
|
this.#observers.close();
|
|
460
|
+
this.#followInterfaces(false);
|
|
312
461
|
this.#socket.unregisterRelevantNames(RESPONDER_NAMES_OWNER);
|
|
313
|
-
await this.#records.close();
|
|
314
462
|
for (const { timer } of this.#truncatedQueryCache.values()) {
|
|
315
463
|
timer.stop();
|
|
316
464
|
}
|
|
317
465
|
this.#truncatedQueryCache.clear();
|
|
318
|
-
this.#
|
|
319
|
-
this.#recentlyAnsweredQueries.clear();
|
|
466
|
+
await Promise.all([...this.#responders.values()].map((responder) => responder.close()));
|
|
320
467
|
} catch (_) {
|
|
321
468
|
var _error = _, _hasError = true;
|
|
322
469
|
} finally {
|
|
@@ -333,14 +480,14 @@ class MdnsServer {
|
|
|
333
480
|
async #chooseHostname() {
|
|
334
481
|
try {
|
|
335
482
|
const candidates = new Array();
|
|
336
|
-
for (const { name } of await this.#
|
|
337
|
-
|
|
483
|
+
for (const { name } of await this.#listInterfaces()) {
|
|
484
|
+
const responder = this.#interfaceFor(name);
|
|
338
485
|
try {
|
|
339
|
-
|
|
340
|
-
} catch
|
|
341
|
-
logger.debug(`Interface ${name} skipped for the mDNS host name`, error);
|
|
486
|
+
await responder.readDetails();
|
|
487
|
+
} catch {
|
|
342
488
|
continue;
|
|
343
489
|
}
|
|
490
|
+
const { details } = responder;
|
|
344
491
|
if (details?.ipV4.length || details?.ipV6.length) {
|
|
345
492
|
if (/[1-9a-f]/i.test(details.mac)) {
|
|
346
493
|
candidates.push(hostnameForMac(details.mac));
|
|
@@ -351,68 +498,17 @@ class MdnsServer {
|
|
|
351
498
|
this.#hostname = candidates[0];
|
|
352
499
|
}
|
|
353
500
|
} catch (error) {
|
|
354
|
-
|
|
501
|
+
if (error instanceof ClosedError) {
|
|
502
|
+
logger.debug("mDNS host name not chosen, the server closed", error);
|
|
503
|
+
} else {
|
|
504
|
+
logger.warn("Cannot list network interfaces to choose the mDNS host name", error);
|
|
505
|
+
}
|
|
355
506
|
}
|
|
356
507
|
}
|
|
357
508
|
#getMulticastInterfacesForAnnounce() {
|
|
358
509
|
const { netInterface } = this.#socket;
|
|
359
510
|
return netInterface === void 0 ? this.network.getNetInterfaces() : [{ name: netInterface }];
|
|
360
511
|
}
|
|
361
|
-
/**
|
|
362
|
-
* Whether a querier's known answer already carries {@link record}.
|
|
363
|
-
*
|
|
364
|
-
* A record is identified by its name, type, class and value; the cache-flush bit is framing, meaningful only in a
|
|
365
|
-
* response. A known answer suppresses only while more than half its lifetime remains.
|
|
366
|
-
*
|
|
367
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc6762#section-7.1} RFC 6762 §7.1
|
|
368
|
-
*/
|
|
369
|
-
#suppressedByKnownAnswer(record, knownAnswer) {
|
|
370
|
-
return record.recordType === knownAnswer.recordType && record.recordClass === knownAnswer.recordClass && knownAnswer.ttl > record.ttl / 2 && sameName(record.name, knownAnswer.name) && isDeepEqual(record.value, knownAnswer.value);
|
|
371
|
-
}
|
|
372
|
-
#queryRecords({ name, recordType }, records) {
|
|
373
|
-
const queryName = name.toLowerCase();
|
|
374
|
-
if (recordType === DnsRecordType.ANY) {
|
|
375
|
-
return records.filter((record) => record.name.toLowerCase() === queryName);
|
|
376
|
-
} else {
|
|
377
|
-
return records.filter(
|
|
378
|
-
(record) => record.name.toLowerCase() === queryName && record.recordType === recordType
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* RFC 6762 §7.3 - Checks if we should suppress a response because another responder
|
|
384
|
-
* has recently answered the same question with answers that cover what we'd send.
|
|
385
|
-
* Also, lazily cleans up expired entries from the cache.
|
|
386
|
-
*/
|
|
387
|
-
#shouldSuppressResponse(queries, knownAnswers, sourceIntf, answers) {
|
|
388
|
-
const now = Time.nowMs;
|
|
389
|
-
for (const [key, entry] of this.#recentlyAnsweredQueries) {
|
|
390
|
-
if (now - entry.timestamp >= QUESTION_SUPPRESSION_WINDOW) {
|
|
391
|
-
this.#recentlyAnsweredQueries.delete(key);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
const queryKey = queries.map((q) => `${q.name.toLowerCase()}-${q.recordType}`).sort().join("|") + `-${sourceIntf}`;
|
|
395
|
-
const cached = this.#recentlyAnsweredQueries.get(queryKey);
|
|
396
|
-
if (cached && now - cached.timestamp < QUESTION_SUPPRESSION_WINDOW) {
|
|
397
|
-
const answerHashes = answers.map((a) => this.buildDnsRecordKey(a, sourceIntf));
|
|
398
|
-
const allAnswersKnown = answerHashes.every((h) => cached.knownAnswerHashes.has(h));
|
|
399
|
-
if (allAnswersKnown) {
|
|
400
|
-
return true;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
const knownAnswerHashes = /* @__PURE__ */ new Set();
|
|
404
|
-
for (const answer of knownAnswers) {
|
|
405
|
-
knownAnswerHashes.add(this.buildDnsRecordKey(answer, sourceIntf));
|
|
406
|
-
}
|
|
407
|
-
for (const answer of answers) {
|
|
408
|
-
knownAnswerHashes.add(this.buildDnsRecordKey(answer, sourceIntf));
|
|
409
|
-
}
|
|
410
|
-
this.#recentlyAnsweredQueries.set(queryKey, {
|
|
411
|
-
knownAnswerHashes,
|
|
412
|
-
timestamp: now
|
|
413
|
-
});
|
|
414
|
-
return false;
|
|
415
|
-
}
|
|
416
512
|
async #processTruncatedQuery(key) {
|
|
417
513
|
const { message, timer } = this.#truncatedQueryCache.get(key) ?? {};
|
|
418
514
|
this.#truncatedQueryCache.delete(key);
|
|
@@ -464,35 +560,7 @@ class MdnsServer {
|
|
|
464
560
|
function hostnameForMac(mac) {
|
|
465
561
|
return `${mac.replace(/:/g, "").toUpperCase()}0000.local`;
|
|
466
562
|
}
|
|
467
|
-
function sendable(sent, complete, isUnicast) {
|
|
468
|
-
if (isUnicast) {
|
|
469
|
-
return sent.map((record) => record.flushCache ? { ...record, flushCache: false } : record);
|
|
470
|
-
}
|
|
471
|
-
if (!sent.some((record) => record.flushCache)) {
|
|
472
|
-
return sent;
|
|
473
|
-
}
|
|
474
|
-
const sentSizes = setSizes(sent);
|
|
475
|
-
const completeSizes = setSizes(complete);
|
|
476
|
-
return sent.map(
|
|
477
|
-
(record) => record.flushCache && (sentSizes.get(setKeyOf(record)) ?? 0) < (completeSizes.get(setKeyOf(record)) ?? 0) ? { ...record, flushCache: false } : record
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
function setKeyOf(record) {
|
|
481
|
-
return `${record.recordType}-${record.recordClass}-${record.name.toLowerCase()}`;
|
|
482
|
-
}
|
|
483
|
-
function setSizes(records) {
|
|
484
|
-
const sizes = /* @__PURE__ */ new Map();
|
|
485
|
-
for (const record of records) {
|
|
486
|
-
const key = setKeyOf(record);
|
|
487
|
-
sizes.set(key, (sizes.get(key) ?? 0) + 1);
|
|
488
|
-
}
|
|
489
|
-
return sizes;
|
|
490
|
-
}
|
|
491
|
-
function sameName(a, b) {
|
|
492
|
-
return a === b || a.toLowerCase() === b.toLowerCase();
|
|
493
|
-
}
|
|
494
563
|
export {
|
|
495
|
-
MdnsServer
|
|
496
|
-
QUESTION_SUPPRESSION_WINDOW
|
|
564
|
+
MdnsServer
|
|
497
565
|
};
|
|
498
566
|
//# sourceMappingURL=MdnsServer.js.map
|