{"name":"@libp2p/mdns","version":"11.0.4","keywords":["IPFS"],"license":"Apache-2.0 OR MIT","_id":"@libp2p/mdns@11.0.4","homepage":"https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns#readme","bugs":{"url":"https://github.com/libp2p/js-libp2p/issues"},"dist":{"shasum":"78f299bceeb9d063bc84aff8b75f3f3465ce8138","tarball":"http://registry-npm.ywwl.com/@libp2p/mdns/download/@libp2p/mdns-11.0.4.tgz","fileCount":25,"integrity":"sha512-wClqAtQRc/p7sP3E4FAgsPh3D6Rb4fHi4xpH7DUbl6l1gPVDG3FVLKi9cirCuc/g9TNUbZsEI7pdLs0aGWJ8aw==","signatures":[{"sig":"MEUCIHwwrCAQcArMtuRjEyP5lm2wlk4vV+bixXSb9YLFnu86AiEAmjsNFfimplcH3u2n5zeNqZq1AmNtwkF3qNbPtttgieQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@libp2p%2fmdns@11.0.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":171500,"size":52984,"noattachment":false,"key":"/@libp2p/mdns/-/@libp2p/mdns-11.0.4.tgz"},"type":"module","types":"./dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"4cc316c2bfb8757c9b1e4896941445331ebdcc8a","scripts":{"lint":"aegir lint","test":"aegir test -t node","build":"aegir build","clean":"aegir clean","dep-check":"aegir dep-check","doc-check":"aegir doc-check","test:node":"aegir test -t node --cov","test:electron-main":"aegir test -t electron-main"},"_npmUser":{"name":"npm-service-account-libp2p","email":"npm-service-account+libp2p@ipfs.tech"},"repository":{"url":"git+https://github.com/libp2p/js-libp2p.git","type":"git"},"_npmVersion":"10.8.3","description":"Node.js libp2p mDNS discovery implementation for peer discovery","directories":{},"sideEffects":false,"_nodeVersion":"20.17.0","dependencies":{"dns-packet":"^5.6.1","@libp2p/utils":"^6.0.4","multicast-dns":"^7.2.5","@libp2p/peer-id":"^5.0.4","@libp2p/interface":"^2.1.2","@types/multicast-dns":"^7.2.4","@multiformats/multiaddr":"^12.2.3","@libp2p/interface-internal":"^2.0.4"},"eslintConfig":{"extends":"ipfs","parserOptions":{"project":true,"sourceType":"module"}},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"aegir":"^44.0.1","sinon-ts":"^2.0.0","p-wait-for":"^5.0.2","@libp2p/crypto":"^5.0.4","@libp2p/logger":"^5.0.4","@libp2p/interface-compliance-tests":"^6.1.2"},"_npmOperationalInternal":{"tmp":"tmp/mdns_11.0.4_1727194975183_0.1512296098134931","host":"s3://npm-registry-packages"},"readme":"# @libp2p/mdns\n\n[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)\n[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)\n[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)\n[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=main\\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain)\n\n> Node.js libp2p mDNS discovery implementation for peer discovery\n\n# About\n\n<!--\n\n!IMPORTANT!\n\nEverything in this README between \"# About\" and \"# Install\" is automatically\ngenerated and will be overwritten the next time the doc generator is run.\n\nTo make changes to this section, please update the @packageDocumentation section\nof src/index.js or src/index.ts\n\nTo experiment with formatting, please run \"npm run docs\" from the root of this\nrepo and examine the changes made.\n\n-->\n\nA peer discover mechanism that uses [mDNS](https://datatracker.ietf.org/doc/html/rfc6762) to discover peers on the local network.\n\n## Example - Use with libp2p\n\n```TypeScript\nimport { createLibp2p } from 'libp2p'\nimport { mdns } from '@libp2p/mdns'\n\nconst libp2p = await createLibp2p({\n  peerDiscovery: [\n    mdns()\n  ]\n})\n\nlibp2p.addEventListener('peer:discovery', (evt) => {\n  console.log('found peer: ', evt.detail.toString())\n})\n```\n\n## MDNS messages\n\nA query is sent to discover the libp2p nodes on the local network\n\n```JSON\n{\n   \"type\": \"query\",\n   \"questions\": [{\n     \"name\": \"_p2p._udp.local\",\n     \"type\": \"PTR\"\n   }]\n}\n```\n\nWhen a query is detected, each libp2p node sends an answer about itself\n\n```JSON\n[{\n  \"name\": \"_p2p._udp.local\",\n  \"type\": \"PTR\",\n  \"class\": \"IN\",\n  \"ttl\": 120,\n  \"data\": \"QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local\"\n}, {\n  \"name\": \"QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local\",\n  \"type\": \"SRV\",\n  \"class\": \"IN\",\n  \"ttl\": 120,\n  \"data\": {\n    \"priority\": 10,\n    \"weight\": 1,\n    \"port\": \"20002\",\n    \"target\": \"LAPTOP-G5LJ7VN9\"\n  }\n}, {\n  \"name\": \"QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local\",\n  \"type\": \"TXT\",\n  \"class\": \"IN\",\n  \"ttl\": 120,\n  \"data\": [\"QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK\"]\n}, {\n  \"name\": \"LAPTOP-G5LJ7VN9\",\n  \"type\": \"A\",\n  \"class\": \"IN\",\n  \"ttl\": 120,\n  \"data\": \"127.0.0.1\"\n}, {\n  \"name\": \"LAPTOP-G5LJ7VN9\",\n  \"type\": \"AAAA\",\n  \"class\": \"IN\",\n  \"ttl\": 120,\n  \"data\": \"::1\"\n}]\n```\n\n# Install\n\n```console\n$ npm i @libp2p/mdns\n```\n\n# API Docs\n\n- <https://libp2p.github.io/js-libp2p/modules/_libp2p_mdns.html>\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](https://github.com/libp2p/js-libp2p/blob/main/packages/peer-discovery-mdns/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](https://github.com/libp2p/js-libp2p/blob/main/packages/peer-discovery-mdns/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n# Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","publish_time":1727194975523,"maintainers":[{"name":"daviddias","email":"mail@daviddias.me"},{"name":"alanshaw","email":"alan138@gmail.com"},{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"vascosantos","email":"santos.vasco10@gmail.com"},{"name":"npm-service-account-libp2p","email":"npm-service-account+libp2p@ipfs.tech"},{"name":"jacobheun","email":"jacobheun@gmail.com"}],"_cnpm_publish_time":1727194975523,"dist-tags":{"latest":"12.0.36","next":"12.0.36-fab409544"}}