{"id":19217818,"url":"https://github.com/homebridge/ciao","last_synced_at":"2025-04-05T17:06:49.359Z","repository":{"id":39974371,"uuid":"261618666","full_name":"homebridge/ciao","owner":"homebridge","description":"RFC 6762 and RFC 6763 compliant mdns service discovery library written in Typescript","archived":false,"fork":false,"pushed_at":"2024-04-10T20:43:04.000Z","size":2034,"stargazers_count":78,"open_issues_count":9,"forks_count":5,"subscribers_count":11,"default_branch":"latest","last_synced_at":"2024-04-14T05:06:29.139Z","etag":null,"topics":["bonjour","ciao","dns-sd","mdns","mdns-sd","multicast-dns","responder","rfc-6762","rfc-6763","service-discovery","zero-configuration","zeroconf"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/homebridge.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-06T01:05:02.000Z","updated_at":"2024-06-18T15:17:33.658Z","dependencies_parsed_at":"2023-11-27T20:21:35.493Z","dependency_job_id":"1fcb7b45-ea20-4f8c-adc9-098fb42f5319","html_url":"https://github.com/homebridge/ciao","commit_stats":{"total_commits":349,"total_committers":6,"mean_commits":"58.166666666666664","dds":"0.025787965616045794","last_synced_commit":"657dfcc5a54d9ec5614300ff84e4e025320751c0"},"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/homebridge%2Fciao","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/homebridge%2Fciao/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/homebridge%2Fciao/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/homebridge%2Fciao/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/homebridge","download_url":"https://codeload.github.com/homebridge/ciao/tar.gz/refs/heads/latest","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bonjour","ciao","dns-sd","mdns","mdns-sd","multicast-dns","responder","rfc-6762","rfc-6763","service-discovery","zero-configuration","zeroconf"],"created_at":"2024-11-09T14:23:57.094Z","updated_at":"2025-04-05T17:06:49.332Z","avatar_url":"https://github.com/homebridge.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://homebridge.io\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/homebridge/branding/latest/logos/homebridge-color-round-stylized.png\" height=\"140\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cspan align=\"center\"\u003e\n\n# Ciao\n\n[![NPM-Version](https://badgen.net/npm/v/@homebridge/ciao)](https://www.npmjs.org/package/@homebridge/ciao)\n[![NPM-Version Beta](https://badgen.net/npm/v/@homebridge/ciao/beta)](https://www.npmjs.org/package/@homebridge/ciao)\n[![NPM-Downloads](https://badgen.net/npm/dt/@homebridge/ciao)](https://www.npmjs.org/package/@homebridge/ciao)\n[![Node Build](https://github.com/homebridge/ciao/actions/workflows/build.yml/badge.svg)](https://github.com/homebridge/ciao/actions/workflows/build.yml)\n[![Coverage Status](https://coveralls.io/repos/github/homebridge/ciao/badge.svg?branch=latest)](https://coveralls.io/github/homebridge/ciao?branch=latest)\n\n\u003c/span\u003e\n\n`ciao` is a [RFC 6763](https://tools.ietf.org/html/rfc6763) compliant `dns-sd` library,\nadvertising on multicast dns ([RFC 6762](https://tools.ietf.org/html/rfc6762))\nimplemented in plain Typescript/JavaScript.\n\nIt is used in [HAP-NodeJS](https://github.com/homebridge/HAP-NodeJS) and is the successor of the \n[bonjour-hap](https://github.com/homebridge/bonjour) (and [bonjour](https://github.com/watson/bonjour)) library, \naiming to be more robust, more maintainable and RFC compliant (read [Notice](https://github.com/homebridge/bonjour#notice)).\n\n`ciao` features a multicast dns responder to publish service on the local network.\nIt will eventually gain browsing functionality in the future to also discover services on the local network\n(There is currently no schedule when discover functionality will arrive. \nA possible querier implementation is limited as explained in [RFC 6762 15.1.](https://tools.ietf.org/html/rfc6762#section-15.1)\nas it can't receive unicast responses).\n\n`ciao` [passes](BCT-Results-CIAO-PI-en0.txt) the [Bonjour Conformance Test](https://developer.apple.com/bonjour/)\nas defined and required by Apple.\n\nThe full documentation can be found [here](https://developers.homebridge.io/ciao/modules.html).\n\n## Installation\n\nAdd `ciao` as a dependency to your project by running the following command:\n\n```\nnpm install --save @homebridge/ciao\n```\n\n## Example\n\n```ts\nconst ciao = require(\"@homebridge/ciao\");\n\nconst responder = ciao.getResponder();\n\n// create a service defining a web server running on port 3000\nconst service = responder.createService({\n    name: 'My Web Server',\n    type: 'http',\n    port: 3000, // optional, can also be set via updatePort() before advertising\n    txt: { // optional\n      key: \"value\",\n    }\n})\n\n\nservice.advertise().then(() =\u003e {\n  // stuff you do when the service is published\n  console.log(\"Service is published :)\");\n});\n\n// ....\n\nservice.updateTxt({ // replaces current txt\n    newKey: \"newValue\",\n});\n\n// ....\n\nservice.end().then(() =\u003e {\n  // service is now UNANNOUNCED and can be published again\n});\n\n// ....\n\n// frees the service objects (and calls end() if still announced).\n// The service object cannot be used again afterwards.\nservice.destroy();\n```\n\n## Documentation \n\nThe full documentation can be found [here](https://developers.homebridge.io/ciao/modules.html).\n\n### API overview\n\nThis section links to the most important aspects of the documentation as used in the example above.\n\nFirst of all the [getResponder](https://developers.homebridge.io/ciao/functions/getResponder.html) function \nshould be used to get a reference to a [Responder](https://developers.homebridge.io/ciao/classes/Responder.html) object.\nThe function takes some optional [options](https://developers.homebridge.io/ciao/interfaces/MDNSServerOptions.html)\nto configure the underlying mdns server.\n\nThe [createService](https://developers.homebridge.io/ciao/classes/Responder.html#createService) method of the `Responder`\nobject can now be used to create a new [CiaoService](https://developers.homebridge.io/ciao/classes/CiaoService.html) \nsupplying the desired [configuration](https://developers.homebridge.io/ciao/interfaces/ServiceOptions.html)\nas the first parameter. You might have a look at the \n_[restrictedAddresses](https://developers.homebridge.io/ciao/interfaces/ServiceOptions.html#restrictedAddresses)_\n(and _[disabledIpv6](https://developers.homebridge.io/ciao/interfaces/ServiceOptions.html#disabledIpv6)_) configuration\nif you don't want to advertise on all available addresses/network interfaces.\n\nThe [advertise](https://developers.homebridge.io/ciao/classes/CiaoService.html#advertise) method can now be called\non the `service` object to start advertising the service on the network.\nAn application should ideally listen to the [NAME_CHANGED](https://developers.homebridge.io/ciao/enums/ServiceEvent.html#NAME_CHANGED)\nevent, in oder to persist any changes happening to the service name resulting of the conflict resolution algorithm.\nThe method [updateTxt](https://developers.homebridge.io/ciao/classes/CiaoService.html#updateTxt) can be used\nto update the contest of the txt exposed by the service.\n\nAny application SHOULD hook up a listener on events like SIGTERM or SIGINT and call the \n[shutdown](https://developers.homebridge.io/ciao/classes/Responder.html#shutdown) method of the responder object.\nThis will ensure, that goodbye packets are sent out on all connected network interfaces and all hosts\non the network get instantly notified of the shutdown.\nOtherwise, stale data will remain in the caches of surrounding mdns browsers. \n\n### MTU\n\nAs of [RFC 6762 17. Multicast DNS Message Size](https://tools.ietf.org/html/rfc6762#section-17) DNS packets must avoid\nIP Fragmentation and ensure that all sent packets are smaller than the Maximum Transmission Unit (MTU) defined by\nthe network interface. The MTU defaults to 1500 Bytes on pretty much all network cards for Ethernet and Wi-Fi.\n`ciao` can't reliable detect modifications made to this default MTU size.\nThus , we rely on a hardcoded value, which is `1440` for the **UDP Payload Size** (Remember: the MTU defines the amount\nof bytes Ethernet or Wi-Fi can transport on the local link. There is additional overhead caused by the IP Header \nand the UDP Header. So the amount of bytes we are able to fit into a single UDP packet is smaller).  \nIf you know, that the MTU differs on your machine, you can set the true **UDP Payload Size** in bytes\nusing the `CIAO_UPS` environment variable. \n\n### Notice on native mDNS responders\n\nAs described in [RFC 6762 15.](https://tools.ietf.org/html/rfc6762#section-15):\n_\"It is possible to have more than one Multicast DNS responder and/or\nquerier implementation coexist on the same machine, but there are some known issues.\"_\n\nThe RFC lists three possible issues:\n * [15.1.](https://tools.ietf.org/html/rfc6762#section-15.1) **Receiving Unicast Responses:**  \n    As multiple sockets (from multiple responders) are bound to the port 5353, only one can receive unicast responses.\n    Unicast responses is a way to reduce traffic on the multicast address, as answers to a particular question can be\n    sent directly to the querier. As ciao does not hold the primary socket on port 5353, it can't receive unicast responses\n    and thus must sent any queries without setting the QU (unicast response) flag. Any responses to our questions are \n    sent on multicast and thus increase the load on the network.  \n    This currently isn't really a problem, as the only time we send queries is in the probing step before we \n    advertise a new service (Future query functionality is much more affected).\n * [15.2.](https://tools.ietf.org/html/rfc6762#section-15.2) **Multipacket Known-Answer lists:**  \n    When the known-answer list of a query is too large to fit into a single dns packet, a querier can split those\n    records into multiple packets (and setting the truncation flag).\n    A responder will then reassemble those packets, which are identified by their originating ip address.  \n    Thus, known-answer lists could be messed up when two queriers are sending at the same time.\n    Again ciao currently only sends queries when probing, so the probability of this happening is pretty low. \n * [15.3.](https://tools.ietf.org/html/rfc6762#section-15.3) **Efficiency:**  \n    The last point is pretty simple. Two independently running responders use twice the memory and twice the computing power.\n    It doesn't improve the situation that this is running using an interpreted language.  \n    So yes, it's probably not very efficient. \n \nAs the RFC also states in [15.4](https://tools.ietf.org/html/rfc6762#section-15.4), it is recommended to use \na single mDNS implementation where possible. It is recommended to use the [mdns](https://www.npmjs.com/package/mdns)\nlibrary where possible, as the library is pretty much a binding for existing mDNS implementations running on your\nsystem (like `mDNSResponder` on macOS or `avahi` on most linux based systems).  \nThe one downside with the `mdns` library is that running it on Windows is not really straight forward.\nGenerally we experienced with `homebridge` that many users run into problems when trying to install `mdns`.\nThus `bonjour-hap` and then `ciao` was created to provide a much easier to set up system.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhomebridge%2Fciao","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhomebridge%2Fciao","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhomebridge%2Fciao/lists"}